|
|
7c2775 |
From 37f90057792a0b4543f34684ed9a240fe8e869c1 Mon Sep 17 00:00:00 2001
|
|
|
7c2775 |
From: Alexey Tikhonov <atikhono@redhat.com>
|
|
|
7c2775 |
Date: Mon, 11 Apr 2022 22:48:19 +0200
|
|
|
7c2775 |
Subject: [PATCH 5/6] Revert "usertools: force local user for sssd process
|
|
|
7c2775 |
user"
|
|
|
7c2775 |
|
|
|
7c2775 |
This reverts commit 9c447dc85853116c035bbc2f9e3b8553a65be621.
|
|
|
7c2775 |
|
|
|
7c2775 |
Resolves: https://github.com/SSSD/sssd/issues/6107
|
|
|
7c2775 |
|
|
|
7c2775 |
Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
|
|
|
7c2775 |
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
|
|
7c2775 |
---
|
|
|
7c2775 |
Makefile.am | 3 -
|
|
|
7c2775 |
src/tests/cwrap/Makefile.am | 8 +--
|
|
|
7c2775 |
src/tests/cwrap/common_mock_nss_dl_load.c | 77 -----------------------
|
|
|
7c2775 |
src/tests/cwrap/common_mock_nss_dl_load.h | 30 ---------
|
|
|
7c2775 |
src/tests/cwrap/test_responder_common.c | 7 ---
|
|
|
7c2775 |
src/tests/cwrap/test_usertools.c | 6 --
|
|
|
7c2775 |
src/util/nss_dl_load.c | 13 +---
|
|
|
7c2775 |
src/util/nss_dl_load.h | 3 -
|
|
|
7c2775 |
src/util/nss_dl_load_extra.c | 40 ------------
|
|
|
7c2775 |
src/util/usertools.c | 32 +++-------
|
|
|
7c2775 |
10 files changed, 12 insertions(+), 207 deletions(-)
|
|
|
7c2775 |
delete mode 100644 src/tests/cwrap/common_mock_nss_dl_load.c
|
|
|
7c2775 |
delete mode 100644 src/tests/cwrap/common_mock_nss_dl_load.h
|
|
|
7c2775 |
delete mode 100644 src/util/nss_dl_load_extra.c
|
|
|
7c2775 |
|
|
|
7c2775 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
7c2775 |
index 1121a3fb2..e0dd5220c 100644
|
|
|
7c2775 |
--- a/Makefile.am
|
|
|
7c2775 |
+++ b/Makefile.am
|
|
|
7c2775 |
@@ -888,7 +888,6 @@ dist_noinst_HEADERS = \
|
|
|
7c2775 |
src/tests/cmocka/test_expire_common.h \
|
|
|
7c2775 |
src/tests/cmocka/test_sdap_access.h \
|
|
|
7c2775 |
src/tests/cmocka/data_provider/mock_dp.h \
|
|
|
7c2775 |
- src/tests/cwrap/common_mock_nss_dl_load.h \
|
|
|
7c2775 |
src/sss_client/pam_message.h \
|
|
|
7c2775 |
src/sss_client/ssh/sss_ssh_client.h \
|
|
|
7c2775 |
src/sss_client/sudo/sss_sudo.h \
|
|
|
7c2775 |
@@ -1271,8 +1270,6 @@ libsss_util_la_SOURCES = \
|
|
|
7c2775 |
src/util/sss_regexp.c \
|
|
|
7c2775 |
src/util/sss_chain_id_tevent.c \
|
|
|
7c2775 |
src/util/sss_chain_id.c \
|
|
|
7c2775 |
- src/util/nss_dl_load.c \
|
|
|
7c2775 |
- src/util/nss_dl_load_extra.c \
|
|
|
7c2775 |
$(NULL)
|
|
|
7c2775 |
libsss_util_la_CFLAGS = \
|
|
|
7c2775 |
$(AM_CFLAGS) \
|
|
|
7c2775 |
diff --git a/src/tests/cwrap/Makefile.am b/src/tests/cwrap/Makefile.am
|
|
|
7c2775 |
index 4ac24a492..f25d2e3c6 100644
|
|
|
7c2775 |
--- a/src/tests/cwrap/Makefile.am
|
|
|
7c2775 |
+++ b/src/tests/cwrap/Makefile.am
|
|
|
7c2775 |
@@ -142,17 +142,15 @@ endif
|
|
|
7c2775 |
|
|
|
7c2775 |
usertools_tests_SOURCES = \
|
|
|
7c2775 |
test_usertools.c \
|
|
|
7c2775 |
- common_mock_nss_dl_load.c \
|
|
|
7c2775 |
- ../../../src/util/usertools.c \
|
|
|
7c2775 |
$(NULL)
|
|
|
7c2775 |
usertools_tests_CFLAGS = \
|
|
|
7c2775 |
$(AM_CFLAGS) \
|
|
|
7c2775 |
$(NULL)
|
|
|
7c2775 |
usertools_tests_LDADD = \
|
|
|
7c2775 |
- $(LIBADD_DL) \
|
|
|
7c2775 |
$(CMOCKA_LIBS) \
|
|
|
7c2775 |
$(POPT_LIBS) \
|
|
|
7c2775 |
$(TALLOC_LIBS) \
|
|
|
7c2775 |
+ $(abs_top_builddir)/libsss_util.la \
|
|
|
7c2775 |
$(abs_top_builddir)/libsss_debug.la \
|
|
|
7c2775 |
$(abs_top_builddir)/libsss_test_common.la \
|
|
|
7c2775 |
$(NULL)
|
|
|
7c2775 |
@@ -162,10 +160,9 @@ endif
|
|
|
7c2775 |
|
|
|
7c2775 |
responder_common_tests_SOURCES =\
|
|
|
7c2775 |
test_responder_common.c \
|
|
|
7c2775 |
- common_mock_nss_dl_load.c \
|
|
|
7c2775 |
$(SSSD_RESPONDER_IFACE_OBJ) \
|
|
|
7c2775 |
../../../src/responder/common/negcache_files.c \
|
|
|
7c2775 |
- ../../../src/util/usertools.c \
|
|
|
7c2775 |
+ ../../../src/util/nss_dl_load.c \
|
|
|
7c2775 |
../../../src/responder/common/negcache.c \
|
|
|
7c2775 |
../../../src/responder/common/responder_common.c \
|
|
|
7c2775 |
../../../src/responder/common/responder_packet.c \
|
|
|
7c2775 |
@@ -183,6 +180,7 @@ responder_common_tests_LDADD = \
|
|
|
7c2775 |
$(SSSD_LIBS) \
|
|
|
7c2775 |
$(SELINUX_LIBS) \
|
|
|
7c2775 |
$(SYSTEMD_DAEMON_LIBS) \
|
|
|
7c2775 |
+ $(abs_top_builddir)/libsss_util.la \
|
|
|
7c2775 |
$(abs_top_builddir)/libsss_debug.la \
|
|
|
7c2775 |
$(abs_top_builddir)/libsss_test_common.la \
|
|
|
7c2775 |
$(abs_top_builddir)/libsss_iface.la \
|
|
|
7c2775 |
diff --git a/src/tests/cwrap/common_mock_nss_dl_load.c b/src/tests/cwrap/common_mock_nss_dl_load.c
|
|
|
7c2775 |
deleted file mode 100644
|
|
|
7c2775 |
index 72f6c39ac..000000000
|
|
|
7c2775 |
--- a/src/tests/cwrap/common_mock_nss_dl_load.c
|
|
|
7c2775 |
+++ /dev/null
|
|
|
7c2775 |
@@ -1,77 +0,0 @@
|
|
|
7c2775 |
-/*
|
|
|
7c2775 |
- Authors:
|
|
|
7c2775 |
- Iker Pedrosa <ipedrosa@redhat.com>
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- Copyright (C) 2021 Red Hat
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- SSSD tests: Fake nss dl load
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- This program is free software; you can redistribute it and/or modify
|
|
|
7c2775 |
- it under the terms of the GNU General Public License as published by
|
|
|
7c2775 |
- the Free Software Foundation; either version 3 of the License, or
|
|
|
7c2775 |
- (at your option) any later version.
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- This program is distributed in the hope that it will be useful,
|
|
|
7c2775 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
7c2775 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
7c2775 |
- GNU General Public License for more details.
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- You should have received a copy of the GNU General Public License
|
|
|
7c2775 |
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
7c2775 |
-*/
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-#include <sys/types.h>
|
|
|
7c2775 |
-#include <sys/stat.h>
|
|
|
7c2775 |
-#include <errno.h>
|
|
|
7c2775 |
-#include <stddef.h>
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-#include "common_mock_nss_dl_load.h"
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-static enum nss_status
|
|
|
7c2775 |
-mock_getpwnam_r(const char *name, struct passwd *result,
|
|
|
7c2775 |
- char *buffer, size_t buflen, int *errnop)
|
|
|
7c2775 |
-{
|
|
|
7c2775 |
- void *pwd_pointer = NULL;
|
|
|
7c2775 |
- int rc;
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- rc = getpwnam_r(name, result, buffer, buflen, (struct passwd **)&pwd_pointer);
|
|
|
7c2775 |
- if (rc == 0 && pwd_pointer == result) {
|
|
|
7c2775 |
- *errnop = 0;
|
|
|
7c2775 |
- return NSS_STATUS_SUCCESS;
|
|
|
7c2775 |
- } else if (rc == 0 && (pwd_pointer == NULL)) {
|
|
|
7c2775 |
- *errnop = ENOENT;
|
|
|
7c2775 |
- return NSS_STATUS_NOTFOUND;
|
|
|
7c2775 |
- } else {
|
|
|
7c2775 |
- *errnop = rc;
|
|
|
7c2775 |
- return NSS_STATUS_UNAVAIL;
|
|
|
7c2775 |
- }
|
|
|
7c2775 |
-}
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-static enum nss_status
|
|
|
7c2775 |
-mock_getpwuid_r(uid_t uid, struct passwd *result,
|
|
|
7c2775 |
- char *buffer, size_t buflen, int *errnop)
|
|
|
7c2775 |
-{
|
|
|
7c2775 |
- void *pwd_pointer = NULL;
|
|
|
7c2775 |
- int rc;
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- rc = getpwuid_r(uid, result, buffer, buflen, (struct passwd **)&pwd_pointer);
|
|
|
7c2775 |
- if (rc == 0 && pwd_pointer == result) {
|
|
|
7c2775 |
- *errnop = 0;
|
|
|
7c2775 |
- return NSS_STATUS_SUCCESS;
|
|
|
7c2775 |
- } else if (rc == 0 && (pwd_pointer == NULL)) {
|
|
|
7c2775 |
- *errnop = ENOENT;
|
|
|
7c2775 |
- return NSS_STATUS_NOTFOUND;
|
|
|
7c2775 |
- } else {
|
|
|
7c2775 |
- *errnop = rc;
|
|
|
7c2775 |
- return NSS_STATUS_UNAVAIL;
|
|
|
7c2775 |
- }
|
|
|
7c2775 |
-}
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-errno_t mock_sss_load_nss_pw_symbols(struct sss_nss_ops *ops)
|
|
|
7c2775 |
-{
|
|
|
7c2775 |
- ops->getpwnam_r = mock_getpwnam_r;
|
|
|
7c2775 |
- ops->getpwuid_r = mock_getpwuid_r;
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- return EOK;
|
|
|
7c2775 |
-}
|
|
|
7c2775 |
diff --git a/src/tests/cwrap/common_mock_nss_dl_load.h b/src/tests/cwrap/common_mock_nss_dl_load.h
|
|
|
7c2775 |
deleted file mode 100644
|
|
|
7c2775 |
index 6db411450..000000000
|
|
|
7c2775 |
--- a/src/tests/cwrap/common_mock_nss_dl_load.h
|
|
|
7c2775 |
+++ /dev/null
|
|
|
7c2775 |
@@ -1,30 +0,0 @@
|
|
|
7c2775 |
-/*
|
|
|
7c2775 |
- Authors:
|
|
|
7c2775 |
- Iker Pedrosa <ipedrosa@redhat.com>
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- Copyright (C) 2021 Red Hat
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- SSSD tests: Fake nss dl load
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- This program is free software; you can redistribute it and/or modify
|
|
|
7c2775 |
- it under the terms of the GNU General Public License as published by
|
|
|
7c2775 |
- the Free Software Foundation; either version 3 of the License, or
|
|
|
7c2775 |
- (at your option) any later version.
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- This program is distributed in the hope that it will be useful,
|
|
|
7c2775 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
7c2775 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
7c2775 |
- GNU General Public License for more details.
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- You should have received a copy of the GNU General Public License
|
|
|
7c2775 |
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
7c2775 |
-*/
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-#ifndef __COMMON_MOCK_NSS_DL_LOAD_H_
|
|
|
7c2775 |
-#define __COMMON_MOCK_NSS_DL_LOAD_H_
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-#include "util/nss_dl_load.h"
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-errno_t mock_sss_load_nss_pw_symbols(struct sss_nss_ops *ops);
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-#endif /* __COMMON_MOCK_NSS_DL_LOAD_H_ */
|
|
|
7c2775 |
diff --git a/src/tests/cwrap/test_responder_common.c b/src/tests/cwrap/test_responder_common.c
|
|
|
7c2775 |
index 571e95d36..11cc3abd8 100644
|
|
|
7c2775 |
--- a/src/tests/cwrap/test_responder_common.c
|
|
|
7c2775 |
+++ b/src/tests/cwrap/test_responder_common.c
|
|
|
7c2775 |
@@ -29,13 +29,6 @@
|
|
|
7c2775 |
#include "util/util.h"
|
|
|
7c2775 |
#include "responder/common/responder.h"
|
|
|
7c2775 |
#include "tests/cmocka/common_mock.h"
|
|
|
7c2775 |
-#include "tests/cwrap/common_mock_nss_dl_load.h"
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-errno_t sss_load_nss_pw_symbols(struct sss_nss_ops *ops)
|
|
|
7c2775 |
-{
|
|
|
7c2775 |
- return mock_sss_load_nss_pw_symbols(ops);
|
|
|
7c2775 |
-}
|
|
|
7c2775 |
|
|
|
7c2775 |
/* Just to satisfy dependencies */
|
|
|
7c2775 |
struct cli_protocol_version *register_cli_protocol_version(void)
|
|
|
7c2775 |
diff --git a/src/tests/cwrap/test_usertools.c b/src/tests/cwrap/test_usertools.c
|
|
|
7c2775 |
index eb30a540c..f61ae83e2 100644
|
|
|
7c2775 |
--- a/src/tests/cwrap/test_usertools.c
|
|
|
7c2775 |
+++ b/src/tests/cwrap/test_usertools.c
|
|
|
7c2775 |
@@ -27,12 +27,6 @@
|
|
|
7c2775 |
#include <popt.h>
|
|
|
7c2775 |
#include "util/util.h"
|
|
|
7c2775 |
#include "tests/cmocka/common_mock.h"
|
|
|
7c2775 |
-#include "tests/cwrap/common_mock_nss_dl_load.h"
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-errno_t sss_load_nss_pw_symbols(struct sss_nss_ops *ops)
|
|
|
7c2775 |
-{
|
|
|
7c2775 |
- return mock_sss_load_nss_pw_symbols(ops);
|
|
|
7c2775 |
-}
|
|
|
7c2775 |
|
|
|
7c2775 |
void test_get_user_num(void **state)
|
|
|
7c2775 |
{
|
|
|
7c2775 |
diff --git a/src/util/nss_dl_load.c b/src/util/nss_dl_load.c
|
|
|
7c2775 |
index 379ccfa65..442108307 100644
|
|
|
7c2775 |
--- a/src/util/nss_dl_load.c
|
|
|
7c2775 |
+++ b/src/util/nss_dl_load.c
|
|
|
7c2775 |
@@ -48,16 +48,6 @@ static void *proxy_dlsym(void *handle,
|
|
|
7c2775 |
return funcptr;
|
|
|
7c2775 |
}
|
|
|
7c2775 |
|
|
|
7c2775 |
-static void sss_close_handle(struct sss_nss_ops *ops, const char *libname)
|
|
|
7c2775 |
-{
|
|
|
7c2775 |
- if (dlclose(ops->dl_handle) != 0) {
|
|
|
7c2775 |
- DEBUG(SSSDBG_OP_FAILURE,
|
|
|
7c2775 |
- "Error closing the handle for the '%s' library, error: %s.\n",
|
|
|
7c2775 |
- libname, dlerror());
|
|
|
7c2775 |
- }
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- ops->dl_handle = NULL;
|
|
|
7c2775 |
-}
|
|
|
7c2775 |
|
|
|
7c2775 |
errno_t sss_load_nss_symbols(struct sss_nss_ops *ops, const char *libname,
|
|
|
7c2775 |
struct sss_nss_symbols *syms, size_t nsyms)
|
|
|
7c2775 |
@@ -82,7 +72,7 @@ errno_t sss_load_nss_symbols(struct sss_nss_ops *ops, const char *libname,
|
|
|
7c2775 |
|
|
|
7c2775 |
for (i = 0; i < nsyms; i++) {
|
|
|
7c2775 |
*(syms[i].fptr) = proxy_dlsym(ops->dl_handle, syms[i].fname,
|
|
|
7c2775 |
- libname);
|
|
|
7c2775 |
+ libname);
|
|
|
7c2775 |
|
|
|
7c2775 |
if (*(syms[i].fptr) == NULL) {
|
|
|
7c2775 |
if (syms[i].mandatory) {
|
|
|
7c2775 |
@@ -90,7 +80,6 @@ errno_t sss_load_nss_symbols(struct sss_nss_ops *ops, const char *libname,
|
|
|
7c2775 |
"mandatory symbol '%s', error: %s.\n", libpath,
|
|
|
7c2775 |
syms[i].fname, dlerror());
|
|
|
7c2775 |
ret = ELIBBAD;
|
|
|
7c2775 |
- sss_close_handle(ops, libname);
|
|
|
7c2775 |
goto out;
|
|
|
7c2775 |
} else {
|
|
|
7c2775 |
DEBUG(SSSDBG_OP_FAILURE, "Library '%s' did not provide "
|
|
|
7c2775 |
diff --git a/src/util/nss_dl_load.h b/src/util/nss_dl_load.h
|
|
|
7c2775 |
index 07c04e091..f1e882b96 100644
|
|
|
7c2775 |
--- a/src/util/nss_dl_load.h
|
|
|
7c2775 |
+++ b/src/util/nss_dl_load.h
|
|
|
7c2775 |
@@ -23,8 +23,6 @@
|
|
|
7c2775 |
#include <pwd.h>
|
|
|
7c2775 |
#include <grp.h>
|
|
|
7c2775 |
#include <netdb.h>
|
|
|
7c2775 |
-#include <stdbool.h>
|
|
|
7c2775 |
-
|
|
|
7c2775 |
#include "util/util_errors.h"
|
|
|
7c2775 |
#include "sss_client/nss_compat.h"
|
|
|
7c2775 |
|
|
|
7c2775 |
@@ -120,6 +118,5 @@ struct sss_nss_symbols {
|
|
|
7c2775 |
errno_t sss_load_nss_symbols(struct sss_nss_ops *ops, const char *libname,
|
|
|
7c2775 |
struct sss_nss_symbols *syms, size_t nsyms);
|
|
|
7c2775 |
|
|
|
7c2775 |
-errno_t sss_load_nss_pw_symbols(struct sss_nss_ops *ops);
|
|
|
7c2775 |
|
|
|
7c2775 |
#endif /* __SSSD_NSS_DL_LOAD_H__ */
|
|
|
7c2775 |
diff --git a/src/util/nss_dl_load_extra.c b/src/util/nss_dl_load_extra.c
|
|
|
7c2775 |
deleted file mode 100644
|
|
|
7c2775 |
index 162957025..000000000
|
|
|
7c2775 |
--- a/src/util/nss_dl_load_extra.c
|
|
|
7c2775 |
+++ /dev/null
|
|
|
7c2775 |
@@ -1,40 +0,0 @@
|
|
|
7c2775 |
-/*
|
|
|
7c2775 |
- SSSD
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- nss_dl_load_extra.c
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- Authors:
|
|
|
7c2775 |
- Sumit Bose <sbose@redhat.com>
|
|
|
7c2775 |
- Iker Pedrosa <ipedrosa@redhat.com>
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- Copyright (C) 2021 Red Hat
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- This program is free software; you can redistribute it and/or modify
|
|
|
7c2775 |
- it under the terms of the GNU General Public License as published by
|
|
|
7c2775 |
- the Free Software Foundation; either version 3 of the License, or
|
|
|
7c2775 |
- (at your option) any later version.
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- This program is distributed in the hope that it will be useful,
|
|
|
7c2775 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
7c2775 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
7c2775 |
- GNU General Public License for more details.
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- You should have received a copy of the GNU General Public License
|
|
|
7c2775 |
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
7c2775 |
-*/
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-#include "util/nss_dl_load.h"
|
|
|
7c2775 |
-
|
|
|
7c2775 |
-errno_t sss_load_nss_pw_symbols(struct sss_nss_ops *ops)
|
|
|
7c2775 |
-{
|
|
|
7c2775 |
- errno_t ret;
|
|
|
7c2775 |
- struct sss_nss_symbols syms[] = {
|
|
|
7c2775 |
- {(void*)&ops->getpwnam_r, true, "getpwnam_r" },
|
|
|
7c2775 |
- {(void*)&ops->getpwuid_r, true, "getpwuid_r" }
|
|
|
7c2775 |
- };
|
|
|
7c2775 |
- size_t nsyms = sizeof(syms) / sizeof(struct sss_nss_symbols);
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- ret = sss_load_nss_symbols(ops, "files", syms, nsyms);
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- return ret;
|
|
|
7c2775 |
-}
|
|
|
7c2775 |
diff --git a/src/util/usertools.c b/src/util/usertools.c
|
|
|
7c2775 |
index 33315a798..511fb2d5d 100644
|
|
|
7c2775 |
--- a/src/util/usertools.c
|
|
|
7c2775 |
+++ b/src/util/usertools.c
|
|
|
7c2775 |
@@ -27,14 +27,12 @@
|
|
|
7c2775 |
|
|
|
7c2775 |
#include "db/sysdb.h"
|
|
|
7c2775 |
#include "confdb/confdb.h"
|
|
|
7c2775 |
-#include "util/nss_dl_load.h"
|
|
|
7c2775 |
#include "util/strtonum.h"
|
|
|
7c2775 |
#include "util/util.h"
|
|
|
7c2775 |
#include "util/safe-format-string.h"
|
|
|
7c2775 |
#include "responder/common/responder.h"
|
|
|
7c2775 |
|
|
|
7c2775 |
#define NAME_DOMAIN_PATTERN_OPTIONS (SSS_REGEXP_DUPNAMES | SSS_REGEXP_EXTENDED)
|
|
|
7c2775 |
-#define NSS_BUFFER_SIZE 16384
|
|
|
7c2775 |
|
|
|
7c2775 |
/* Function returns given realm name as new uppercase string */
|
|
|
7c2775 |
char *get_uppercase_realm(TALLOC_CTX *memctx, const char *name)
|
|
|
7c2775 |
@@ -568,23 +566,10 @@ sss_fqname(char *str, size_t size, struct sss_names_ctx *nctx,
|
|
|
7c2775 |
|
|
|
7c2775 |
errno_t sss_user_by_name_or_uid(const char *input, uid_t *_uid, gid_t *_gid)
|
|
|
7c2775 |
{
|
|
|
7c2775 |
- static struct sss_nss_ops nss_ops;
|
|
|
7c2775 |
uid_t uid;
|
|
|
7c2775 |
errno_t ret;
|
|
|
7c2775 |
char *endptr;
|
|
|
7c2775 |
- struct passwd pwd = { 0 };
|
|
|
7c2775 |
- int errnop = 0;
|
|
|
7c2775 |
- enum nss_status status;
|
|
|
7c2775 |
- static char s_nss_buffer[NSS_BUFFER_SIZE];
|
|
|
7c2775 |
-
|
|
|
7c2775 |
- if (!nss_ops.dl_handle) {
|
|
|
7c2775 |
- ret = sss_load_nss_pw_symbols(&nss_ops);
|
|
|
7c2775 |
- if (ret != EOK) {
|
|
|
7c2775 |
- DEBUG(SSSDBG_OP_FAILURE, "Unable to load NSS symbols [%d]: %s\n",
|
|
|
7c2775 |
- ret, sss_strerror(ret));
|
|
|
7c2775 |
- return ret;
|
|
|
7c2775 |
- }
|
|
|
7c2775 |
- }
|
|
|
7c2775 |
+ struct passwd *pwd;
|
|
|
7c2775 |
|
|
|
7c2775 |
/* Try if it's an ID first */
|
|
|
7c2775 |
uid = strtouint32(input, &endptr, 10);
|
|
|
7c2775 |
@@ -596,27 +581,26 @@ errno_t sss_user_by_name_or_uid(const char *input, uid_t *_uid, gid_t *_gid)
|
|
|
7c2775 |
return ret;
|
|
|
7c2775 |
}
|
|
|
7c2775 |
|
|
|
7c2775 |
- status = nss_ops.getpwnam_r(input, &pwd, s_nss_buffer, NSS_BUFFER_SIZE, &errnop);
|
|
|
7c2775 |
+ /* Nope, maybe a username? */
|
|
|
7c2775 |
+ pwd = getpwnam(input);
|
|
|
7c2775 |
} else {
|
|
|
7c2775 |
- status = nss_ops.getpwuid_r(uid, &pwd, s_nss_buffer, NSS_BUFFER_SIZE, &errnop);
|
|
|
7c2775 |
+ pwd = getpwuid(uid);
|
|
|
7c2775 |
}
|
|
|
7c2775 |
|
|
|
7c2775 |
- if (status != NSS_STATUS_SUCCESS) {
|
|
|
7c2775 |
+ if (pwd == NULL) {
|
|
|
7c2775 |
DEBUG(SSSDBG_OP_FAILURE,
|
|
|
7c2775 |
"[%s] is neither a valid UID nor a user name which could be "
|
|
|
7c2775 |
- "resolved by getpwnam() [%d][%s]. status returned [%d]\n",
|
|
|
7c2775 |
- input, errnop, strerror(errnop), status);
|
|
|
7c2775 |
+ "resolved by getpwnam().\n", input);
|
|
|
7c2775 |
return EINVAL;
|
|
|
7c2775 |
}
|
|
|
7c2775 |
|
|
|
7c2775 |
if (_uid) {
|
|
|
7c2775 |
- *_uid = pwd.pw_uid;
|
|
|
7c2775 |
+ *_uid = pwd->pw_uid;
|
|
|
7c2775 |
}
|
|
|
7c2775 |
|
|
|
7c2775 |
if (_gid) {
|
|
|
7c2775 |
- *_gid = pwd.pw_gid;
|
|
|
7c2775 |
+ *_gid = pwd->pw_gid;
|
|
|
7c2775 |
}
|
|
|
7c2775 |
-
|
|
|
7c2775 |
return EOK;
|
|
|
7c2775 |
}
|
|
|
7c2775 |
|
|
|
7c2775 |
--
|
|
|
7c2775 |
2.26.3
|
|
|
7c2775 |
|