Merge pull request #234 from edneville/79_userdel

Adding run-parts for userdel
This commit is contained in:
Serge Hallyn
2020-06-10 00:31:10 -05:00
committed by GitHub
7 changed files with 140 additions and 5 deletions

View File

@@ -64,6 +64,7 @@
#include "prototypes.h"
#include "pwauth.h"
#include "pwio.h"
#include "run_part.h"
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
@@ -2420,6 +2421,11 @@ int main (int argc, char **argv)
(!user_id || (user_id <= uid_max && user_id >= uid_min));
#endif /* ENABLE_SUBIDS */
if (run_parts ("/etc/shadow-maint/useradd-pre.d", (char*)user_name,
"useradd")) {
exit(1);
}
#ifdef ACCT_TOOLS_SETUID
#ifdef USE_PAM
{
@@ -2634,6 +2640,11 @@ int main (int argc, char **argv)
}
#endif /* WITH_SELINUX */
if (run_parts ("/etc/shadow-maint/useradd-post.d", (char*)user_name,
"useradd")) {
exit(1);
}
nscd_flush_cache ("passwd");
nscd_flush_cache ("group");
sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);

View File

@@ -31,19 +31,17 @@
*/
#include <config.h>
#ident "$Id$"
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#ifdef ACCT_TOOLS_SETUID
#ifdef USE_PAM
#include "pam_defs.h"
@@ -65,6 +63,7 @@
#include <tcb.h>
#include "tcbfuncs.h"
#endif /* WITH_TCB */
#include "run_part.h"
/*@-exitarg@*/
#include "exitcodes.h"
#ifdef ENABLE_SUBIDS
@@ -1143,6 +1142,10 @@ int main (int argc, char **argv)
{
const struct passwd *pwd;
if (run_parts ("/etc/shadow-maint/userdel-pre.d", user_name,
"userdel")) {
exit(1);
}
pw_open(O_RDONLY);
pwd = pw_locate (user_name); /* we care only about local users */
if (NULL == pwd) {
@@ -1342,6 +1345,10 @@ int main (int argc, char **argv)
user_cancel (user_name);
close_files ();
if (run_parts ("/etc/shadow-maint/userdel-post.d", user_name, "userdel")) {
exit(1);
}
#ifdef WITH_TCB
errors += remove_tcbdir (user_name, user_id);
#endif /* WITH_TCB */