]> granicus.if.org Git - shadow/commitdiff
* src/pwconv.c: Report failure to unlock the passwd or shadow file
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Thu, 7 Aug 2008 08:02:34 +0000 (08:02 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Thu, 7 Aug 2008 08:02:34 +0000 (08:02 +0000)
to stderr and syslog.
* src/pwconv.c: Report failure to chmod the backup file.

ChangeLog
src/pwconv.c

index d4dd47de1f3a0921a1f2633ac8c3abe0fe8e7fb6..84bcb145a6e770ec287d002ace59114d209082e3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-06  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * src/pwconv.c: Report failure to unlock the passwd or shadow file
+       to stderr and syslog.
+       * src/pwconv.c: Report failure to chmod the backup file.
+
 2008-08-06  Nicolas François  <nicolas.francois@centraliens.net>
 
        * src/grpunconv.c: Report failure to unlock the group or gshadow
index ac09f33c242779af4b6969fe172d5bd7dffeca1d..bd31160e091078b90159eca76f9d0b94ce1a5036 100644 (file)
@@ -87,16 +87,26 @@ static bool shadow_locked = false;
 static bool passwd_locked = false;
 
 /* local function prototypes */
-static void fail_exit (int);
+static void fail_exit (int status);
 
 static void fail_exit (int status)
 {
-       if (shadow_locked) {
-               spw_unlock ();
-       }
        if (passwd_locked) {
-               pw_unlock ();
+               if (pw_unlock () == 0) {
+                       fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
+                       /* continue */
+               }
+       }
+
+       if (shadow_locked) {
+               if (spw_unlock () == 0) {
+                       fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
+                       /* continue */
+               }
        }
+
        exit (status);
 }
 
@@ -207,17 +217,41 @@ int main (int argc, char **argv)
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, spw_dbname ());
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", spw_dbname ()));
                fail_exit (E_FAILURE);
        }
        if (pw_close () == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, pw_dbname ());
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
                fail_exit (E_FAILURE);
        }
-       chmod (PASSWD_FILE "-", 0600);  /* /etc/passwd- (backup file) */
-       spw_unlock ();
-       pw_unlock ();
+
+       /* /etc/passwd- (backup file) */
+       if (chmod (PASSWD_FILE "-", 0600) != 0) {
+               fprintf (stderr,
+                        _("%s: failed to change the mode of %s to 0600\n"),
+                        Prog, PASSWD_FILE "-");
+               SYSLOG ((LOG_ERR, "failed to change the mode of %s to 0600", PASSWD_FILE "-"));
+               /* continue */
+       }
+
+       if (passwd_locked) {
+               if (pw_unlock () == 0) {
+                       fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
+                       /* continue */
+               }
+       }
+
+       if (shadow_locked) {
+               if (spw_unlock () == 0) {
+                       fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
+                       /* continue */
+               }
+       }
 
        nscd_flush_cache ("passwd");