diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-11-07 17:51:58 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-11-07 17:51:58 +0100 |
commit | e057b0f94f679af834d5eb15e10c714c72c16740 (patch) | |
tree | eb13aa93ad9c9fdcc8dcb3377f9152a5edbbfbd9 | |
parent | f595d8ed46d627af9808a3c881a0e9a7fb88e3cb (diff) | |
download | busybox-w32-e057b0f94f679af834d5eb15e10c714c72c16740.tar.gz busybox-w32-e057b0f94f679af834d5eb15e10c714c72c16740.tar.bz2 busybox-w32-e057b0f94f679af834d5eb15e10c714c72c16740.zip |
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>
-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) |