]> granicus.if.org Git - shadow/commitdiff
Abort if an error is found while updating the user or group database. No
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 16 Nov 2007 23:26:56 +0000 (23:26 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 16 Nov 2007 23:26:56 +0000 (23:26 +0000)
changes will be written in the databases.

ChangeLog
NEWS
src/userdel.c

index 82fbc25395f7bbd3779a87a124c661caf3517974..42c5ca3c6a0fd7b4fff7ecfa6066bb45a93ac4ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-11-17  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * NEWS, src/userdel.c: Abort if an error is found while updating the
+       user or group database. No changes will be written in the
+       databases.
+
 2007-11-17  Nicolas François  <nicolas.francois@centraliens.net>
 
        * src/useradd.c: It is no more needed to check that the user's
diff --git a/NEWS b/NEWS
index b5778f264f9cb724a2bbfa88f5eecb66d2447fdf..052d3536d8cdd20daac86f84464b54aa84c9e6e6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,8 @@ shadow-4.0.18.1 -> shadow-4.0.18.2                                    UNRELEASED
   containing two entries with the same name. (The fix strategy differs
   from 
   (https://bugzilla.redhat.com/show_bug.cgi?id=240915)
+- userdel: Abort if an error is detected while updating the passwd or group
+  databases. The passwd or group files will not be written.
 
 shadow-4.0.18.1 -> shadow-4.0.18.2                                     28-10-2007
 
index 5568df78082a74135be9ac81707f926396adbc7c..f0766cfd28e986cbd49841c917b5f38886c50564 100644 (file)
@@ -153,9 +153,11 @@ static void update_groups (void)
                        exit (13);      /* XXX */
                }
                ngrp->gr_mem = del_list (ngrp->gr_mem, user_name);
-               if (!gr_update (ngrp))
+               if (!gr_update (ngrp)) {
                        fprintf (stderr,
                                 _("%s: error updating group entry\n"), Prog);
+                       exit (E_GRP_UPDATE);
+               }
 
                /*
                 * Update the DBM group file with the new entry as well.
@@ -252,9 +254,11 @@ static void update_groups (void)
                if (was_admin)
                        nsgrp->sg_adm = del_list (nsgrp->sg_adm, user_name);
 
-               if (!sgr_update (nsgrp))
+               if (!sgr_update (nsgrp)) {
                        fprintf (stderr,
                                 _("%s: error updating group entry\n"), Prog);
+                       exit (E_GRP_UPDATE);
+               }
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "deleting user from shadow group", user_name,
@@ -411,12 +415,16 @@ static void open_files (void)
  */
 static void update_user (void)
 {
-       if (!pw_remove (user_name))
+       if (!pw_remove (user_name)) {
                fprintf (stderr,
                         _("%s: error deleting password entry\n"), Prog);
-       if (is_shadow_pwd && !spw_remove (user_name))
+               fail_exit (E_PW_UPDATE);
+       }
+       if (is_shadow_pwd && !spw_remove (user_name)) {
                fprintf (stderr,
                         _("%s: error deleting shadow password entry\n"), Prog);
+               fail_exit (E_PW_UPDATE);
+       }
 #ifdef WITH_AUDIT
        audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "deleting user entries",
                      user_name, user_id, 1);