]> granicus.if.org Git - shadow/commitdiff
* src/chfn.c: Do not exit on pw_unlock failures.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 22 Aug 2008 02:30:33 +0000 (02:30 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 22 Aug 2008 02:30:33 +0000 (02:30 +0000)
* src/grpconv.c, src/grpunconv.c, src/pwconv.c, src/pwunconv.c,
src/vipw.c: Open syslog with the right identification name.
* src/vipw.c: Log unlock errors to syslog.
* src/vipw.c: Log edits to syslog.
* src/chage.c, src/chfn.c, src/chsh.c, src/gpasswd.c,
src/groupadd.c, src/groupdel.c, src/groupmod.c, src/grpconv.c,
src/grpunconv.c, src/passwd.c, src/pwck.c, src/pwunconv.c,
src/useradd.c, src/usermod.c: Harmonize the syslog levels. Failure
to close or unlock are errors. Failure to open files are warnings.

17 files changed:
ChangeLog
src/chage.c
src/chfn.c
src/chsh.c
src/gpasswd.c
src/groupadd.c
src/groupdel.c
src/groupmod.c
src/grpconv.c
src/grpunconv.c
src/passwd.c
src/pwck.c
src/pwconv.c
src/pwunconv.c
src/useradd.c
src/usermod.c
src/vipw.c

index 84946d8c6637df95c6d48b4437a0bc797ade7077..be3e100f89cb7ccf77694866cfce5a20a1443b8c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-08-20  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * src/chfn.c: Do not exit on pw_unlock failures.
+       * src/grpconv.c, src/grpunconv.c, src/pwconv.c, src/pwunconv.c,
+       src/vipw.c: Open syslog with the right identification name.
+       * src/vipw.c: Log unlock errors to syslog.
+       * src/vipw.c: Log edits to syslog.
+       * src/chage.c, src/chfn.c, src/chsh.c, src/gpasswd.c,
+       src/groupadd.c, src/groupdel.c, src/groupmod.c, src/grpconv.c,
+       src/grpunconv.c, src/passwd.c, src/pwck.c, src/pwunconv.c,
+       src/useradd.c, src/usermod.c: Harmonize the syslog levels. Failure
+       to close or unlock are errors. Failure to open files are warnings.
+
 2008-08-20  Nicolas François  <nicolas.francois@centraliens.net>
 
        * src/newusers.c: Open syslog with the right identification name.
index 91a338ecfe3ae8bfcad835577cd71ad86381b565..0396d293d4277a9bcd2d0d72bf25fb1a97d56a5f 100644 (file)
@@ -572,7 +572,7 @@ static void open_files (bool readonly)
        }
        if (pw_open (readonly ? O_RDONLY: O_RDWR) == 0) {
                fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ());
-               SYSLOG ((LOG_ERR, "cannot open %s", pw_dbname ()));
+               SYSLOG ((LOG_WARN, "cannot open %s", pw_dbname ()));
                fail_exit (E_NOPERM);
        }
 
@@ -594,7 +594,7 @@ static void open_files (bool readonly)
        if (spw_open (readonly ? O_RDONLY: O_RDWR) == 0) {
                fprintf (stderr,
                         _("%s: cannot open %s\n"), Prog, spw_dbname ());
-               SYSLOG ((LOG_ERR, "cannot open %s", spw_dbname ()));
+               SYSLOG ((LOG_WARN, "cannot open %s", spw_dbname ()));
                fail_exit (E_NOPERM);
        }
 }
@@ -664,7 +664,7 @@ static void update_age (const struct spwd *sp, const struct passwd *pw)
                if (pw_update (&pwent) == 0) {
                        fprintf (stderr,
                                 _("%s: cannot update %s\n"), Prog, pw_dbname ());
-                       SYSLOG ((LOG_ERR, "cannot update %s", pw_dbname ()));
+                       SYSLOG ((LOG_WARN, "cannot update %s", pw_dbname ()));
                        fail_exit (E_NOPERM);
                }
        } else {
@@ -688,7 +688,7 @@ static void update_age (const struct spwd *sp, const struct passwd *pw)
        if (spw_update (&spwent) == 0) {
                fprintf (stderr,
                         _("%s: cannot update %s\n"), Prog, spw_dbname ());
-               SYSLOG ((LOG_ERR, "cannot update %s", spw_dbname ()));
+               SYSLOG ((LOG_WARN, "cannot update %s", spw_dbname ()));
                fail_exit (E_NOPERM);
        }
 
@@ -808,7 +808,7 @@ int main (int argc, char **argv)
                fprintf (stderr,
                         _("%s: the shadow password file is not present\n"),
                         Prog);
-               SYSLOG ((LOG_ERR, "can't find the shadow password file"));
+               SYSLOG ((LOG_WARN, "can't find the shadow password file"));
                closelog ();
                exit (E_SHADOW_NOTFOUND);
        }
index d757c9e6d27b90bf06b1c1aff883ccfaa28ccd64..d614ad6601217b100804f93af57bd17b42471275 100644 (file)
@@ -487,12 +487,12 @@ static void update_gecos (const char *user, char *gecos)
                SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
                fail_exit (E_NOPERM);
        }
-       pw_locked = false; /* If we fail to unlock, do not retry */
        if (pw_unlock () == 0) {
                fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
                SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
-               fail_exit (E_NOPERM);
+               /* continue */
        }
+       pw_locked = false;
 }
 
 /*
index e1c687095a2f2891810cd4f92650f367e45a260f..ffc771b04e1b6599b882cb882a9a517339cc84cb 100644 (file)
@@ -370,7 +370,7 @@ static void update_shell (const char *user, char *newshell)
        pw_locked = true;
        if (pw_open (O_RDWR) == 0) {
                fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ());
-               SYSLOG ((LOG_ERR, "cannot open %s", pw_dbname ()));
+               SYSLOG ((LOG_WARN, "cannot open %s", pw_dbname ()));
                fail_exit (1);
        }
 
@@ -400,7 +400,7 @@ static void update_shell (const char *user, char *newshell)
         * that entry as well.
         */
        if (pw_update (&pwent) == 0) {
-               SYSLOG ((LOG_ERR, "error updating passwd entry"));
+               SYSLOG ((LOG_WARN, "error updating passwd entry"));
                fputs (_("Error updating the password entry.\n"), stderr);
                fail_exit (1);
        }
index 9e1edb470caa55871a473dffe73736abad90691e..909fe280554ce8371de51309b2969ec24118f61a 100644 (file)
@@ -164,7 +164,7 @@ static void fail_exit (int status)
        if (gr_locked) {
                if (gr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking group file",
@@ -176,7 +176,7 @@ static void fail_exit (int status)
        if (sgr_locked) {
                if (sgr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking gshadow file",
@@ -441,7 +441,7 @@ static void close_files (void)
 {
        if (gr_close () == 0) {
                fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
-               SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "rewriting /etc/group",
@@ -453,7 +453,7 @@ static void close_files (void)
        if (is_shadowgrp) {
                if (sgr_close () == 0) {
                        fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "rewriting /etc/gshadow",
@@ -463,7 +463,7 @@ static void close_files (void)
                }
                if (sgr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking gshadow file",
@@ -476,7 +476,7 @@ static void close_files (void)
 #endif
        if (gr_unlock () == 0) {
                fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
-               SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+               SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "unlocking group file",
@@ -649,7 +649,7 @@ static void get_group (struct group *gr)
 
        if (gr_close () == 0) {
                fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
-               SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "closing /etc/group",
@@ -701,7 +701,7 @@ static void get_group (struct group *gr)
                if (sgr_close () == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "closing /etc/gshadow",
index 0cd799d126c22508d5df85ed610962af57b9c825..de23adb3179ac58c4c37fbce25040fda137a6c42 100644 (file)
@@ -253,12 +253,12 @@ static void close_files (void)
 {
        if (gr_close () == 0) {
                fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
-               SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
                fail_exit (E_GRP_UPDATE);
        }
        if (gr_unlock () == 0) {
                fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
-               SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+               SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "unlocking group file",
@@ -272,12 +272,12 @@ static void close_files (void)
                if (sgr_close () == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
                        fail_exit (E_GRP_UPDATE);
                }
                if (sgr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking gshadow file",
@@ -356,7 +356,7 @@ static void fail_exit (int code)
        if (gr_locked) {
                if (gr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking group file",
@@ -369,7 +369,7 @@ static void fail_exit (int code)
        if (sgr_locked) {
                if (sgr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking gshadow file",
index 08effa28a53fc3d99811d4be198370407a10b82c..9a2a716493e590ceacd5040f8966db0d80fcba4b 100644 (file)
@@ -97,7 +97,7 @@ static void fail_exit (int code)
        if (gr_locked) {
                if (gr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking group file",
@@ -110,7 +110,7 @@ static void fail_exit (int code)
        if (sgr_locked) {
                if (sgr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking gshadow file",
@@ -176,12 +176,12 @@ static void close_files (void)
 
        if (gr_close () == 0) {
                fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
-               SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
                fail_exit (E_GRP_UPDATE);
        }
        if (gr_unlock () == 0) {
                fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
-               SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+               SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "unlocking group file",
@@ -195,12 +195,12 @@ static void close_files (void)
                if (sgr_close () == 0)) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
                        fail_exit (E_GRP_UPDATE);
                }
                if (sgr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking gshadow file",
index 3424053cfb069ac733c9639aa0acbf0ee44fb22b..fe41f33fa101f35bccae5fdd483bca3cf538041e 100644 (file)
@@ -126,7 +126,7 @@ static void fail_exit (int status)
        if (gr_locked) {
                if (gr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking group file",
@@ -139,7 +139,7 @@ static void fail_exit (int status)
        if (sgr_locked) {
                if (sgr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking gshadow file",
@@ -152,7 +152,7 @@ static void fail_exit (int status)
        if (pw_locked) {
                if (pw_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", pw_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking passwd file",
@@ -322,7 +322,7 @@ static void grp_update (void)
 #endif
        if (nflg) {
                SYSLOG ((LOG_INFO, "change group '%s' to '%s'",
-                        group_name, group_newname));
+                        group_name, group_newname));
        }
 
        if (gflg) {
@@ -507,7 +507,7 @@ static void close_files (void)
 {
        if (gr_close () == 0) {
                fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
-               SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "rewrite group file",
@@ -517,7 +517,7 @@ static void close_files (void)
        }
        if (gr_unlock () == 0) {
                fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
-               SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+               SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "unlocking group file",
@@ -531,7 +531,7 @@ static void close_files (void)
                if (sgr_close () == 0)) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "rewrite gshadow file",
@@ -541,7 +541,7 @@ static void close_files (void)
                }
                if (sgr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking gshadow file",
@@ -556,7 +556,7 @@ static void close_files (void)
                if (pw_close () == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
-                       SYSLOG ((LOG_WARN, "failure while writing changes to %s", pw_dbname ()));
+                       SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "rewrite passwd file",
@@ -566,7 +566,7 @@ static void close_files (void)
                }
                if (pw_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", pw_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking passwd file",
index 9c463f654b98b551f01bdcdf1f8944d678cc821f..a245a400910d4ba5d28df15fc17e8fcac86a0fa3 100644 (file)
@@ -92,6 +92,8 @@ int main (int argc, char **argv)
        (void) bindtextdomain (PACKAGE, LOCALEDIR);
        (void) textdomain (PACKAGE);
 
+       OPENLOG ("grpconv");
+
        if (gr_lock () == 0) {
                fprintf (stderr,
                         _("%s: cannot lock %s; try again later.\n"),
@@ -188,12 +190,14 @@ int main (int argc, char **argv)
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, sgr_dbname ());
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
                fail_exit (3);
        }
        if (gr_close () == 0) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, gr_dbname ());
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
                fail_exit (3);
        }
        if (sgr_unlock () == 0) {
index ea9d463402e6e8a02b01a9f98763ccd249b58166..18bf3c5cad7f099b5112a97359809027195cb477 100644 (file)
@@ -92,6 +92,8 @@ int main (int argc, char **argv)
        (void) bindtextdomain (PACKAGE, LOCALEDIR);
        (void) textdomain (PACKAGE);
 
+       OPENLOG ("grpunconv");
+
        if (sgr_file_present () == 0) {
                exit (0);       /* no /etc/gshadow, nothing to do */
        }
@@ -147,6 +149,7 @@ int main (int argc, char **argv)
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, sgr_dbname ());
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
                fail_exit (3);
        }
 
@@ -154,6 +157,7 @@ int main (int argc, char **argv)
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"),
                         Prog, gr_dbname ());
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
                fail_exit (3);
        }
 
@@ -161,6 +165,7 @@ int main (int argc, char **argv)
                fprintf (stderr,
                         _("%s: cannot delete %s\n"),
                         Prog, SGROUP_FILE);
+               SYSLOG ((LOG_ERR, "cannot delete %s", SGROUP_FILE));
                fail_exit (3);
        }
 
index 990e29a387f90360703fcac32b0cc913f9845d92..92873764c86ed60c86987078be6f55a9dbe2bcd0 100644 (file)
@@ -539,7 +539,7 @@ static void update_noshadow (void)
                fprintf (stderr,
                         _("%s: cannot open %s\n"),
                         Prog, pw_dbname ());
-               SYSLOG ((LOG_ERR, "cannot open %s", pw_dbname ()));
+               SYSLOG ((LOG_WARN, "cannot open %s", pw_dbname ()));
                fail_exit (E_MISSING);
        }
        pw = pw_locate (name);
@@ -556,7 +556,7 @@ static void update_noshadow (void)
        npw->pw_passwd = update_crypt_pw (npw->pw_passwd);
        if (pw_update (npw) == 0) {
                fputs (_("Error updating the password entry.\n"), stderr);
-               SYSLOG ((LOG_ERR, "error updating password entry"));
+               SYSLOG ((LOG_WARN, "error updating password entry"));
                fail_exit (E_FAILURE);
        }
        if (pw_close () == 0) {
@@ -588,7 +588,7 @@ static void update_shadow (void)
        spw_locked = true;
        if (spw_open (O_RDWR) == 0) {
                fprintf (stderr, _("%s: cannot open %s\n"), Prog, spw_dbname ());
-               SYSLOG ((LOG_ERR, "cannot open %s", spw_dbname ()));
+               SYSLOG ((LOG_WARN, "cannot open %s", spw_dbname ()));
                fail_exit (E_FAILURE);
        }
        sp = spw_locate (name);
@@ -635,7 +635,7 @@ static void update_shadow (void)
 
        if (spw_update (nsp) == 0) {
                fputs (_("Error updating the password entry.\n"), stderr);
-               SYSLOG ((LOG_ERR, "error updating password entry"));
+               SYSLOG ((LOG_WARN, "error updating password entry"));
                fail_exit (E_FAILURE);
        }
        if (spw_close () == 0) {
index dac8555744bb23d4298aabe36df709c47f56fc9a..ed6fd6c84179e699c4c0b91f0e166693f8be75ce 100644 (file)
@@ -253,13 +253,13 @@ static void close_files (bool changed)
                if (pw_close () == 0) {
                        fprintf (stderr, _("%s: failure while writing changes to %s\n"),
                                 Prog, pwd_file);
-                       SYSLOG ((LOG_WARN, "failure while writing changes to %s", pwd_file));
+                       SYSLOG ((LOG_ERR, "failure while writing changes to %s", pwd_file));
                        fail_exit (E_CANTUPDATE);
                }
                if (is_shadow && (spw_close () == 0)) {
                        fprintf (stderr, _("%s: failure while writing changes to %s\n"),
                                 Prog, spw_file);
-                       SYSLOG ((LOG_WARN, "failure while writing changes to %s", spw_file));
+                       SYSLOG ((LOG_ERR, "failure while writing changes to %s", spw_file));
                        fail_exit (E_CANTUPDATE);
                }
        }
index 1e751ea6b289eeb89842e1b384cee9989ac6aca8..cfa07504161b5271992fb1b334a313e60c4e10b3 100644 (file)
@@ -125,6 +125,8 @@ int main (int argc, char **argv)
        (void) bindtextdomain (PACKAGE, LOCALEDIR);
        (void) textdomain (PACKAGE);
 
+       OPENLOG ("pwconv");
+
        if (pw_lock () == 0) {
                fprintf (stderr,
                         _("%s: cannot lock %s; try again later.\n"),
index a4896577b61657acdce316af7dd7d0db9392379f..6481e7298a7d39df5ff36511a7c635b7b3aa175d 100644 (file)
@@ -86,6 +86,8 @@ int main (int argc, char **argv)
        (void) bindtextdomain (PACKAGE, LOCALEDIR);
        (void) textdomain (PACKAGE);
 
+       OPENLOG ("pwunconv");
+
        if (!spw_file_present ()) {
                /* shadow not installed, do nothing */
                exit (0);
@@ -157,6 +159,7 @@ 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 (3);
        }
 
@@ -164,12 +167,14 @@ int main (int argc, char **argv)
                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 (3);
        }
 
        if (unlink (SHADOW) != 0) {
                fprintf (stderr,
                         _("%s: cannot delete %s\n"), Prog, SHADOW);
+               SYSLOG ((LOG_ERR, "cannot delete %s", SHADOW));
                fail_exit (3);
        }
 
index da8ab5c5d088d97ea380bd1092780b6db5c03cc4..3030c29b6fab9485f219d62cc68d7cd34c666b58 100644 (file)
@@ -201,7 +201,7 @@ static void fail_exit (int code)
        if (spw_locked) {
                if (spw_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", spw_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking shadow file",
@@ -213,7 +213,7 @@ static void fail_exit (int code)
        if (pw_locked) {
                if (pw_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", pw_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking passwd file",
@@ -225,7 +225,7 @@ static void fail_exit (int code)
        if (gr_locked) {
                if (gr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking group file",
@@ -238,7 +238,7 @@ static void fail_exit (int code)
        if (sgr_locked) {
                if (sgr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking gshadow file",
@@ -1241,20 +1241,20 @@ static void close_files (void)
 {
        if (pw_close () == 0) {
                fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
-               SYSLOG ((LOG_WARN, "failure while writing changes to %s", pw_dbname ()));
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
                fail_exit (E_PW_UPDATE);
        }
        if (is_shadow_pwd && (spw_close () == 0)) {
                fprintf (stderr,
                         _("%s: failure while writing changes to %s\n"), Prog, spw_dbname ());
-               SYSLOG ((LOG_WARN, "failure while writing changes to %s", spw_dbname ()));
+               SYSLOG ((LOG_ERR, "failure while writing changes to %s", spw_dbname ()));
                fail_exit (E_PW_UPDATE);
        }
        if (do_grp_update) {
                if (gr_close () == 0) {
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
-                       SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
                        fail_exit (E_GRP_UPDATE);
                }
 #ifdef SHADOWGRP
@@ -1262,7 +1262,7 @@ static void close_files (void)
                        fprintf (stderr,
                                 _("%s: failure while writing changes to %s\n"),
                                 Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
                        fail_exit (E_GRP_UPDATE);
                }
 #endif
@@ -1270,7 +1270,7 @@ static void close_files (void)
        if (is_shadow_pwd) {
                if (spw_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", spw_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking shadow file",
@@ -1282,7 +1282,7 @@ static void close_files (void)
        }
        if (pw_unlock () == 0) {
                fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
-               SYSLOG ((LOG_WARN, "failed to unlock %s", pw_dbname ()));
+               SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "unlocking passwd file",
@@ -1293,7 +1293,7 @@ static void close_files (void)
        pw_locked = false;
        if (gr_unlock () == 0) {
                fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
-               SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+               SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "unlocking group file",
@@ -1306,7 +1306,7 @@ static void close_files (void)
        if (is_shadow_grp) {
                if (sgr_unlock () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
-                       SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                                      "unlocking gshadow file",
index 99f53a5748d82adad32b453328fcbd2ecbfc6f19..025fd6a61793d3ffcc64ac49591a61bc4924b19f 100644 (file)
@@ -636,7 +636,7 @@ static void update_group (void)
                        fprintf (stderr,
                                 _("%s: error adding new entry '%s' in %s\n"),
                                 Prog, ngrp->gr_name, gr_dbname ());
-                       SYSLOG ((LOG_ERR, "error adding new entry '%s' in %s", ngrp->gr_name, gr_dbname ()));
+                       SYSLOG ((LOG_WARN, "error adding new entry '%s' in %s", ngrp->gr_name, gr_dbname ()));
                        fail_exit (E_GRP_UPDATE);
                }
        }
@@ -755,7 +755,7 @@ static void update_gshadow (void)
                        fprintf (stderr,
                                 _("%s: error adding new entry '%s' in '%s\n"),
                                 Prog, nsgrp->sg_name, sgr_dbname ());
-                       SYSLOG ((LOG_ERR, "error adding new entry '%s' in %s",
+                       SYSLOG ((LOG_WARN, "error adding new entry '%s' in %s",
                                nsgrp->sg_name, sgr_dbname ()));
                        fail_exit (E_GRP_UPDATE);
                }
index f57c106ffc731a91426196e4e06255a04664cd7b..037808aa79daaa319a5856a0d773bdb0d29dd0a9 100644 (file)
@@ -144,6 +144,7 @@ static void vipwexit (const char *msg, int syserr, int ret)
        if (filelocked) {
                if ((*unlock) () == 0) {
                        fprintf (stderr, _("%s: failed to unlock %s\n"), progname, fileeditname);
+                       SYSLOG ((LOG_ERR, "failed to unlock %s", fileeditname));
                        /* continue */
                }
        }
@@ -276,8 +277,10 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
 
        if ((*file_unlock) () == 0) {
                fprintf (stderr, _("%s: failed to unlock %s\n"), progname, fileeditname);
+               SYSLOG ((LOG_ERR, "failed to unlock %s", fileeditname));
                /* continue */
        }
+       SYSLOG ((LOG_INFO, "file %s edited", fileeditname));
 }
 
 int main (int argc, char **argv)
@@ -293,6 +296,8 @@ int main (int argc, char **argv)
        progname = ((a = strrchr (*argv, '/')) ? a + 1 : *argv);
        do_vipw = (strcmp (progname, "vigr") != 0);
 
+       OPENLOG (do_vipw ? "vipw" : "vigr");
+
        {
                /*
                 * Parse the command line options.