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