mirror of
https://github.com/sheumann/hush.git
synced 2025-01-11 08:29:54 +00:00
deluser: do not warn spuriously when deleting group by deluser
Signed-off-by: Tito Ragusa <farmatito@tiscali.it> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
e057b0f94f
commit
a8dc97cb82
@ -23,7 +23,7 @@ int deluser_main(int argc, char **argv)
|
|||||||
/* Name of shadow or gshadow file */
|
/* Name of shadow or gshadow file */
|
||||||
const char *sfile;
|
const char *sfile;
|
||||||
/* Are we deluser or delgroup? */
|
/* Are we deluser or delgroup? */
|
||||||
bool do_deluser = (ENABLE_DELUSER && (!ENABLE_DELGROUP || applet_name[3] == 'u'));
|
int do_deluser = (ENABLE_DELUSER && (!ENABLE_DELGROUP || applet_name[3] == 'u'));
|
||||||
|
|
||||||
if (geteuid() != 0)
|
if (geteuid() != 0)
|
||||||
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
|
||||||
@ -51,7 +51,13 @@ int deluser_main(int argc, char **argv)
|
|||||||
struct group *gr;
|
struct group *gr;
|
||||||
do_delgroup:
|
do_delgroup:
|
||||||
/* "delgroup GROUP" or "delgroup USER GROUP" */
|
/* "delgroup GROUP" or "delgroup USER GROUP" */
|
||||||
|
if (do_deluser < 0) { /* delgroup after deluser? */
|
||||||
|
gr = getgrnam(name);
|
||||||
|
if (!gr)
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
} else {
|
||||||
gr = xgetgrnam(name); /* bail out if GROUP is wrong */
|
gr = xgetgrnam(name); /* bail out if GROUP is wrong */
|
||||||
|
}
|
||||||
if (!member) {
|
if (!member) {
|
||||||
/* "delgroup GROUP" */
|
/* "delgroup GROUP" */
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
@ -79,13 +85,15 @@ int deluser_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
} while (ENABLE_FEATURE_SHADOWPASSWDS && pfile);
|
} while (ENABLE_FEATURE_SHADOWPASSWDS && pfile);
|
||||||
|
|
||||||
if (ENABLE_DELGROUP && do_deluser) {
|
if (ENABLE_DELGROUP && do_deluser > 0) {
|
||||||
/* "deluser USER" also should try to delete
|
/* "deluser USER" also should try to delete
|
||||||
* same-named group. IOW: do "delgroup USER"
|
* same-named group. IOW: do "delgroup USER"
|
||||||
*/
|
*/
|
||||||
//TODO: check how it actually works in upstream.
|
// On debian deluser is a perl script that calls userdel.
|
||||||
//I suspect it is only done if group has no more members.
|
// From man userdel:
|
||||||
do_deluser = 0;
|
// If USERGROUPS_ENAB is defined to yes in /etc/login.defs, userdel will
|
||||||
|
// delete the group with the same name as the user.
|
||||||
|
do_deluser = -1;
|
||||||
goto do_delgroup;
|
goto do_delgroup;
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user