diff options
-rw-r--r-- | loginutils/deluser.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/loginutils/deluser.c b/loginutils/deluser.c index 12fbbc673..8ee72ef6f 100644 --- a/loginutils/deluser.c +++ b/loginutils/deluser.c | |||
@@ -48,21 +48,21 @@ int deluser_main(int argc, char **argv) | |||
48 | if (ENABLE_FEATURE_SHADOWPASSWDS) | 48 | if (ENABLE_FEATURE_SHADOWPASSWDS) |
49 | sfile = bb_path_shadow_file; | 49 | sfile = bb_path_shadow_file; |
50 | } else { | 50 | } else { |
51 | struct group *gr; | ||
51 | do_delgroup: | 52 | do_delgroup: |
52 | /* "delgroup GROUP" or "delgroup USER GROUP" */ | 53 | /* "delgroup GROUP" or "delgroup USER GROUP" */ |
53 | xgetgrnam(name); /* bail out if GROUP is wrong */ | 54 | gr = xgetgrnam(name); /* bail out if GROUP is wrong */ |
54 | if (!member) { | 55 | if (!member) { |
55 | /* "delgroup GROUP". | 56 | /* "delgroup GROUP" */ |
56 | * If user with the same name exists, | 57 | struct passwd *pw; |
57 | * bail out. | 58 | struct passwd pwent; |
58 | */ | 59 | /* Check if the group is in use */ |
59 | //BUG: check should be done by GID, not by matching name! | 60 | #define passwd_buf bb_common_bufsiz1 |
60 | //1. find GROUP's GID | 61 | while (!getpwent_r(&pwent, passwd_buf, sizeof(passwd_buf), &pw)) { |
61 | //2. check that /etc/passwd doesn't have lines of the form | 62 | if (pwent.pw_gid == gr->gr_gid) |
62 | // user:pwd:uid:GID:... | 63 | bb_error_msg_and_die("'%s' still has '%s' as their primary group!", pwent.pw_name, name); |
63 | //3. bail out if at least one such line exists | 64 | } |
64 | if (getpwnam(name) != NULL) | 65 | //endpwent(); |
65 | bb_error_msg_and_die("'%s' still has '%s' as their primary group!", name, name); | ||
66 | } | 66 | } |
67 | pfile = bb_path_group_file; | 67 | pfile = bb_path_group_file; |
68 | if (ENABLE_FEATURE_SHADOWPASSWDS) | 68 | if (ENABLE_FEATURE_SHADOWPASSWDS) |