Allow deleting the group even if it is the primary group of a user
This is helpful when using configuration management tools such as Puppet, where you are managing the groups in a central location and you don't need this safeguard. Signed-off-by: "Jesse W. Hathaway" <jesse@mbuki-mvuki.org> Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
parent
ecb6f0c3e3
commit
3c32fd4a29
@ -60,6 +60,7 @@ const char *Prog;
|
||||
|
||||
static char *group_name;
|
||||
static gid_t group_id = -1;
|
||||
static bool check_group_busy = true;
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
static bool is_shadow_grp;
|
||||
@ -96,6 +97,7 @@ static /*@noreturn@*/void usage (int status)
|
||||
Prog);
|
||||
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
|
||||
(void) fputs (_(" -R, --root CHROOT_DIR directory to chroot into\n"), usageout);
|
||||
(void) fputs (_(" -f, --force delete group even if it is the primary group of a user\n"), usageout);
|
||||
(void) fputs ("\n", usageout);
|
||||
exit (status);
|
||||
}
|
||||
@ -321,7 +323,7 @@ static void process_flags (int argc, char **argv)
|
||||
{NULL, 0, NULL, '\0'}
|
||||
};
|
||||
|
||||
while ((c = getopt_long (argc, argv, "hR:",
|
||||
while ((c = getopt_long (argc, argv, "hfR:",
|
||||
long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
@ -329,6 +331,9 @@ static void process_flags (int argc, char **argv)
|
||||
/*@notreached@*/break;
|
||||
case 'R': /* no-op, handled in process_root_flag () */
|
||||
break;
|
||||
case 'f':
|
||||
check_group_busy = false;
|
||||
break;
|
||||
default:
|
||||
usage (E_USAGE);
|
||||
}
|
||||
@ -465,7 +470,9 @@ int main (int argc, char **argv)
|
||||
/*
|
||||
* Make sure this isn't the primary group of anyone.
|
||||
*/
|
||||
group_busy (group_id);
|
||||
if (check_group_busy) {
|
||||
group_busy (group_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the hard stuff - open the files, delete the group entries,
|
||||
|
Loading…
Reference in New Issue
Block a user