run_parts for groupadd and groupdel

run_parts currently exists in useradd and userdel, this commit mirrors
the functionality with groupadd and groupdel

Hook for group{add,del} to include killing processes that have group
membership that would no longer exist to avoid membership ID reuse.
This commit is contained in:
ed neville
2023-03-27 20:23:03 +01:00
committed by Serge Hallyn
parent 15a64f9e7f
commit 4e1f674c41
3 changed files with 48 additions and 0 deletions

View File

@@ -34,6 +34,7 @@
#include "sgroupio.h"
#endif
#include "shadowlog.h"
#include "run_part.h"
/*
* exit status values
@@ -603,6 +604,11 @@ int main (int argc, char **argv)
check_perms ();
if (run_parts ("/etc/shadow-maint/groupadd-pre.d", group_name,
"groupadd")) {
exit(1);
}
#ifdef SHADOWGRP
is_shadow_grp = sgr_file_present ();
#endif
@@ -621,6 +627,11 @@ int main (int argc, char **argv)
grp_update ();
close_files ();
if (run_parts ("/etc/shadow-maint/groupadd-post.d", group_name,
"groupadd")) {
exit(1);
}
nscd_flush_cache ("group");
sssd_flush_cache (SSSD_DB_GROUP);

View File

@@ -32,6 +32,7 @@
#include "sgroupio.h"
#endif
#include "shadowlog.h"
#include "run_part.h"
/*
* Global variables
*/
@@ -461,6 +462,11 @@ int main (int argc, char **argv)
group_busy (group_id);
}
if (run_parts ("/etc/shadow-maint/groupdel-pre.d", group_name,
"groupdel")) {
exit(1);
}
/*
* Do the hard stuff - open the files, delete the group entries,
* then close and update the files.
@@ -471,6 +477,11 @@ int main (int argc, char **argv)
close_files ();
if (run_parts ("/etc/shadow-maint/groupdel-post.d", group_name,
"groupdel")) {
exit(1);
}
nscd_flush_cache ("group");
sssd_flush_cache (SSSD_DB_GROUP);