summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Zidek <mzidek@redhat.com>2012-12-13 17:44:36 +0100
committerJakub Hrozek <jhrozek@redhat.com>2012-12-13 20:50:31 +0100
commita9eff330a7fbd231e8cc28a6828a1e5014ddb0d2 (patch)
treeca685fc907ac88cfcb1d370b416c7c8c62cc45c9
parente61587a5d620310c09f226f43c9bb3008481bbe3 (diff)
downloadsssd-a9eff330a7fbd231e8cc28a6828a1e5014ddb0d2.tar.gz
sssd-a9eff330a7fbd231e8cc28a6828a1e5014ddb0d2.tar.bz2
sssd-a9eff330a7fbd231e8cc28a6828a1e5014ddb0d2.zip
tools: sss_userdel and groupdel remove entries from memory cache
https://fedorahosted.org/sssd/ticket/1659
-rw-r--r--Makefile.am8
-rw-r--r--src/tools/sss_groupdel.c24
-rw-r--r--src/tools/sss_userdel.c23
3 files changed, 55 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 3145f495..337fa635 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -680,12 +680,16 @@ 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)
sss_userdel_LDADD = \
libsss_util.la \
$(TOOLS_LIBS)
+sss_userdel_CFLAGS = $(AM_CFLAGS)
+sss_userdel_LDFLAGS = \
+ $(CLIENT_LIBS)
sss_groupadd_SOURCES = \
src/tools/sss_groupadd.c \
@@ -695,11 +699,15 @@ sss_groupadd_LDADD = \
$(TOOLS_LIBS)
sss_groupdel_SOURCES = \
+ src/sss_client/common.c \
src/tools/sss_groupdel.c \
$(SSSD_TOOLS_OBJ)
sss_groupdel_LDADD = \
libsss_util.la \
$(TOOLS_LIBS)
+sss_groupdel_CFLAGS = $(AM_CFLAGS)
+sss_groupdel_LDFLAGS = \
+ $(CLIENT_LIBS)
sss_usermod_SOURCES = \
src/tools/sss_usermod.c \
diff --git a/src/tools/sss_groupdel.c b/src/tools/sss_groupdel.c
index 57c3e700..66ea2926 100644
--- a/src/tools/sss_groupdel.c
+++ b/src/tools/sss_groupdel.c
@@ -19,6 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <nss.h>
#include <stdio.h>
#include <stdlib.h>
#include <talloc.h>
@@ -28,6 +29,7 @@
#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)
{
@@ -35,6 +37,10 @@ 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[] = {
@@ -106,6 +112,24 @@ int main(int argc, const char **argv)
/* groupdel */
ret = groupdel(tctx, tctx->sysdb, tctx->octx);
+ if (ret != EOK) {
+ 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);
+ }
+
+ ret = EOK;
done:
if (ret) {
diff --git a/src/tools/sss_userdel.c b/src/tools/sss_userdel.c
index 5d250f6c..53273f61 100644
--- a/src/tools/sss_userdel.c
+++ b/src/tools/sss_userdel.c
@@ -19,6 +19,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <nss.h>
#include <stdio.h>
#include <stdlib.h>
#include <talloc.h>
@@ -31,6 +32,7 @@
#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"
@@ -119,6 +121,10 @@ 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;
@@ -285,6 +291,21 @@ int main(int argc, const char **argv)
goto fini;
}
+ /* 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) {
+ ERROR("NSS request failed (%1$d). Entry might remain in memory "
+ "cache.\n",nret);
+ }
+
if (tctx->octx->remove_homedir) {
ret = remove_homedir(tctx,
tctx->octx->home,
@@ -301,6 +322,8 @@ int main(int argc, const char **argv)
}
}
+ ret = EOK;
+
done:
if (ret) {
DEBUG(1, ("sysdb operation failed (%d)[%s]\n", ret, strerror(ret)));