]> granicus.if.org Git - shadow/commitdiff
* NEWS, src/userdel.c: Make sure the user exists in the shadow
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 15 Mar 2009 21:29:16 +0000 (21:29 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Sun, 15 Mar 2009 21:29:16 +0000 (21:29 +0000)
database before calling spw_remove().
* NEWS, src/userdel.c: When the user's group is removed, make sure
the group is in the gshadow database before calling sgr_remove().
* src/userdel.c: Improve warning's wording.

ChangeLog
NEWS
src/userdel.c

index 0608a7f498d9fffcd8e44fb4831bd1c067db5ebb..21b4c976baf0cdf4040ccb39a3c6bda7dfec9633 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-03-15  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * NEWS, src/userdel.c: Make sure the user exists in the shadow
+       database before calling spw_remove().
+       * NEWS, src/userdel.c: When the user's group is removed, make sure
+       the group is in the gshadow database before calling sgr_remove().
+       * src/userdel.c: Improve warning's wording.
+
 2009-03-15  Nicolas François  <nicolas.francois@centraliens.net>
 
        * libmisc/cleanup.c: Fix del_cleanup. The arguments were not
diff --git a/NEWS b/NEWS
index 5b4b535cc4c3cb551521c4c3ca10077830cba9ae..1aaf14e1e80af76f1e3d3456b6c512586527f557 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -98,6 +98,9 @@ shadow-4.1.2.2 -> shadow-4.1.3                                                UNRELEASED
   * do not create users with UID set to (gid_t)-1.
 - userdel
   * audit logging improvements.
+  * Do not fail if the removed user is not in the shadow database.
+  * When the user's group shall be removed, do not fail if this group is
+    not in the gshadow file.
 - usermod
   * Allow adding LDAP users (or any user not present in the local passwd
     file) to local groups
index 4f6a3f1420a8b1740d64b0071d63203e099d7a33..907a3cd5bcb2d41820a5c9bf66258f1406129750 100644 (file)
@@ -216,7 +216,7 @@ static void update_groups (void)
                                }
                                if (pwd->pw_gid == grp->gr_gid) {
                                        fprintf (stderr,
-                                                _("%s: Cannot remove group %s which is a primary group for another user.\n"),
+                                                _("%s: group %s is the primary group of another user and is not removed.\n"),
                                                 Prog, grp->gr_name);
                                        break;
                                }
@@ -309,8 +309,8 @@ static void update_groups (void)
                         user_name, nsgrp->sg_name));
        }
 
-       if (deleted_user_group) {
-               /* FIXME: Test if the group is in gshadow first? */
+       if (   deleted_user_group
+           && (sgr_locate (user_name) != NULL)) {
                if (sgr_remove (user_name) == 0) {
                        fprintf (stderr,
                                 _("%s: cannot remove entry '%s' from %s\n"),
@@ -559,7 +559,9 @@ static void update_user (void)
                         Prog, user_name, pw_dbname ());
                fail_exit (E_PW_UPDATE);
        }
-       if (is_shadow_pwd && (spw_remove (user_name) == 0)) {
+       if (   is_shadow_pwd
+           && (spw_locate (user_name) != NULL)
+           && (spw_remove (user_name) == 0)) {
                fprintf (stderr,
                         _("%s: cannot remove entry '%s' from %s\n"),
                         Prog, user_name, spw_dbname ());