delgroup: correct the check for users who still use the group
Signed-off-by: Tito <farmatito@tiscali.it> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
f595d8ed46
commit
e057b0f94f
@ -48,21 +48,21 @@ int deluser_main(int argc, char **argv)
|
|||||||
if (ENABLE_FEATURE_SHADOWPASSWDS)
|
if (ENABLE_FEATURE_SHADOWPASSWDS)
|
||||||
sfile = bb_path_shadow_file;
|
sfile = bb_path_shadow_file;
|
||||||
} else {
|
} else {
|
||||||
|
struct group *gr;
|
||||||
do_delgroup:
|
do_delgroup:
|
||||||
/* "delgroup GROUP" or "delgroup USER GROUP" */
|
/* "delgroup GROUP" or "delgroup USER GROUP" */
|
||||||
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" */
|
||||||
* If user with the same name exists,
|
struct passwd *pw;
|
||||||
* bail out.
|
struct passwd pwent;
|
||||||
*/
|
/* Check if the group is in use */
|
||||||
//BUG: check should be done by GID, not by matching name!
|
#define passwd_buf bb_common_bufsiz1
|
||||||
//1. find GROUP's GID
|
while (!getpwent_r(&pwent, passwd_buf, sizeof(passwd_buf), &pw)) {
|
||||||
//2. check that /etc/passwd doesn't have lines of the form
|
if (pwent.pw_gid == gr->gr_gid)
|
||||||
// user:pwd:uid:GID:...
|
bb_error_msg_and_die("'%s' still has '%s' as their primary group!", pwent.pw_name, name);
|
||||||
//3. bail out if at least one such line exists
|
}
|
||||||
if (getpwnam(name) != NULL)
|
//endpwent();
|
||||||
bb_error_msg_and_die("'%s' still has '%s' as their primary group!", name, name);
|
|
||||||
}
|
}
|
||||||
pfile = bb_path_group_file;
|
pfile = bb_path_group_file;
|
||||||
if (ENABLE_FEATURE_SHADOWPASSWDS)
|
if (ENABLE_FEATURE_SHADOWPASSWDS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user