summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am17
-rw-r--r--src/tools/sss_groupdel.c22
-rw-r--r--src/tools/sss_userdel.c20
-rw-r--r--src/tools/tools_mc_util.c55
-rw-r--r--src/tools/tools_util.h3
5 files changed, 79 insertions, 38 deletions
diff --git a/Makefile.am b/Makefile.am
index 8c9cd32e..710c1016 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -285,11 +285,15 @@ SSSD_RESPONDER_OBJ = \
SSSD_TOOLS_OBJ = \
src/tools/sss_sync_ops.c \
src/tools/tools_util.c \
- src/tools/tools_mc_util.c \
src/tools/files.c \
src/tools/selinux.c \
src/tools/nscd.c
+SSSD_LCL_TOOLS_OBJ = \
+ src/sss_client/common.c \
+ src/tools/tools_mc_util.c \
+ $(SSSD_TOOLS_OBJ)
+
SSSD_RESOLV_OBJ = \
src/resolv/async_resolv.c
if BUILD_ARES_DATA
@@ -684,10 +688,9 @@ sss_useradd_LDADD = \
$(TOOLS_LIBS)
sss_userdel_SOURCES = \
- src/sss_client/common.c \
src/tools/sss_userdel.c \
src/util/find_uid.c \
- $(SSSD_TOOLS_OBJ)
+ $(SSSD_LCL_TOOLS_OBJ)
sss_userdel_LDADD = \
libsss_util.la \
$(TOOLS_LIBS)
@@ -703,9 +706,8 @@ sss_groupadd_LDADD = \
$(TOOLS_LIBS)
sss_groupdel_SOURCES = \
- src/sss_client/common.c \
src/tools/sss_groupdel.c \
- $(SSSD_TOOLS_OBJ)
+ $(SSSD_LCL_TOOLS_OBJ)
sss_groupdel_LDADD = \
libsss_util.la \
$(TOOLS_LIBS)
@@ -736,10 +738,13 @@ sss_groupshow_LDADD = \
sss_cache_SOURCES = \
src/tools/sss_cache.c \
- $(SSSD_TOOLS_OBJ)
+ $(SSSD_LCL_TOOLS_OBJ)
sss_cache_LDADD = \
libsss_util.la \
$(TOOLS_LIBS)
+sss_cache_CFLAGS = $(AM_CFLAGS)
+sss_cache_LDFLAGS = \
+ $(CLIENT_LIBS)
sss_debuglevel_SOURCES = \
src/tools/sss_debuglevel.c \
diff --git a/src/tools/sss_groupdel.c b/src/tools/sss_groupdel.c
index 66ea2926..456b2b48 100644
--- a/src/tools/sss_groupdel.c
+++ b/src/tools/sss_groupdel.c
@@ -29,7 +29,6 @@
#include "util/util.h"
#include "tools/tools_util.h"
#include "tools/sss_sync_ops.h"
-#include "sss_client/sss_cli.h"
int main(int argc, const char **argv)
{
@@ -37,10 +36,6 @@ int main(int argc, const char **argv)
int pc_debug = SSSDBG_DEFAULT;
const char *pc_groupname = NULL;
struct tools_ctx *tctx = NULL;
- struct sss_cli_req_data rd;
- uint8_t *repbuf = NULL;
- size_t replen;
- enum nss_status nret;
poptContext pc = NULL;
struct poptOption long_options[] = {
@@ -116,17 +111,12 @@ int main(int argc, const char **argv)
goto done;
}
- rd.data = pc_groupname;
- rd.len = strlen(pc_groupname) + 1;
-
- sss_nss_lock();
- nret = sss_nss_make_request(SSS_NSS_GETGRNAM, &rd,
- &repbuf, &replen, &ret);
- sss_nss_unlock();
- free(repbuf);
- if (nret != NSS_STATUS_SUCCESS && nret != NSS_STATUS_NOTFOUND) {
- ERROR("NSS request failed (%1$d). Entry might remain in memory"
- " cache.\n",nret);
+ /* Delete group from memory cache */
+ ret = sss_mc_refresh_group(pc_groupname);
+ if (ret != EOK) {
+ ERROR("NSS request failed (%1$d). Entry might remain in memory "
+ "cache.\n", ret);
+ /* Nothing we can do about it */
}
ret = EOK;
diff --git a/src/tools/sss_userdel.c b/src/tools/sss_userdel.c
index 53273f61..2cf77596 100644
--- a/src/tools/sss_userdel.c
+++ b/src/tools/sss_userdel.c
@@ -32,7 +32,6 @@
#include "util/find_uid.h"
#include "tools/tools_util.h"
#include "tools/sss_sync_ops.h"
-#include "sss_client/sss_cli.h"
#ifndef KILL_CMD
#define KILL_CMD "killall"
@@ -121,10 +120,6 @@ int main(int argc, const char **argv)
int ret = EXIT_SUCCESS;
struct tools_ctx *tctx = NULL;
const char *pc_username = NULL;
- struct sss_cli_req_data rd;
- uint8_t *repbuf = NULL;
- size_t replen;
- enum nss_status nret;
int pc_debug = SSSDBG_DEFAULT;
int pc_remove = 0;
@@ -292,18 +287,11 @@ int main(int argc, const char **argv)
}
/* Delete user from memory cache */
- rd.data = pc_username;
- rd.len = strlen(pc_username) + 1;
-
- sss_nss_lock();
- nret = sss_nss_make_request(SSS_NSS_GETPWNAM, &rd,
- &repbuf, &replen, &ret);
-
- sss_nss_unlock();
- free(repbuf);
- if (nret != NSS_STATUS_SUCCESS && nret != NSS_STATUS_NOTFOUND) {
+ ret = sss_mc_refresh_user(pc_username);
+ if (ret != EOK) {
ERROR("NSS request failed (%1$d). Entry might remain in memory "
- "cache.\n",nret);
+ "cache.\n", ret);
+ /* Nothing we can do about it */
}
if (tctx->octx->remove_homedir) {
diff --git a/src/tools/tools_mc_util.c b/src/tools/tools_mc_util.c
index 5348829e..a33dfb97 100644
--- a/src/tools/tools_mc_util.c
+++ b/src/tools/tools_mc_util.c
@@ -25,6 +25,7 @@
#include "util/util.h"
#include "tools/tools_util.h"
#include "util/mmap_cache.h"
+#include "sss_client/sss_cli.h"
static errno_t sss_mc_set_recycled(int fd)
{
@@ -185,3 +186,57 @@ errno_t sss_memcache_clear_all(void)
return EOK;
}
+
+enum sss_tools_ent {
+ SSS_TOOLS_USER,
+ SSS_TOOLS_GROUP
+};
+
+static errno_t sss_mc_refresh_ent(const char *name, enum sss_tools_ent ent)
+{
+ enum sss_cli_command cmd;
+ struct sss_cli_req_data rd;
+ uint8_t *repbuf = NULL;
+ size_t replen;
+ enum nss_status nret;
+ errno_t ret;
+
+ cmd = SSS_CLI_NULL;
+ switch (ent) {
+ case SSS_TOOLS_USER:
+ cmd = SSS_NSS_GETPWNAM;
+ break;
+ case SSS_TOOLS_GROUP:
+ cmd = SSS_NSS_GETGRNAM;
+ break;
+ }
+
+ if (cmd == SSS_CLI_NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, ("Unknown object %d to refresh\n", cmd));
+ return EINVAL;
+ }
+
+ rd.data = name;
+ rd.len = strlen(name) + 1;
+
+ sss_nss_lock();
+ nret = sss_nss_make_request(cmd, &rd, &repbuf, &replen, &ret);
+ sss_nss_unlock();
+
+ free(repbuf);
+ if (nret != NSS_STATUS_SUCCESS && nret != NSS_STATUS_NOTFOUND) {
+ return EIO;
+ }
+
+ return EOK;
+}
+
+errno_t sss_mc_refresh_user(const char *username)
+{
+ return sss_mc_refresh_ent(username, SSS_TOOLS_USER);
+}
+
+errno_t sss_mc_refresh_group(const char *groupname)
+{
+ return sss_mc_refresh_ent(groupname, SSS_TOOLS_GROUP);
+}
diff --git a/src/tools/tools_util.h b/src/tools/tools_util.h
index aa55bfaf..0ca52efd 100644
--- a/src/tools/tools_util.h
+++ b/src/tools/tools_util.h
@@ -109,6 +109,9 @@ errno_t sss_memcache_invalidate(const char *mc_filename);
errno_t sss_memcache_clear_all(void);
+errno_t sss_mc_refresh_user(const char *username);
+errno_t sss_mc_refresh_group(const char *groupname);
+
/* from files.c */
int remove_tree(const char *root);