From a3be8ff0551e3b622d156fd669ef408b88c3bc8e Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Fri, 22 Aug 2008 02:30:33 +0000 Subject: [PATCH] * 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. --- ChangeLog | 13 +++++++++++++ src/chage.c | 10 +++++----- src/chfn.c | 4 ++-- src/chsh.c | 4 ++-- src/gpasswd.c | 16 ++++++++-------- src/groupadd.c | 12 ++++++------ src/groupdel.c | 12 ++++++------ src/groupmod.c | 20 ++++++++++---------- src/grpconv.c | 4 ++++ src/grpunconv.c | 5 +++++ src/passwd.c | 8 ++++---- src/pwck.c | 4 ++-- src/pwconv.c | 2 ++ src/pwunconv.c | 5 +++++ src/useradd.c | 24 ++++++++++++------------ src/usermod.c | 4 ++-- src/vipw.c | 5 +++++ 17 files changed, 93 insertions(+), 59 deletions(-) diff --git a/ChangeLog b/ChangeLog index 84946d8c..be3e100f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-08-20 Nicolas François + + * 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 * src/newusers.c: Open syslog with the right identification name. diff --git a/src/chage.c b/src/chage.c index 91a338ec..0396d293 100644 --- a/src/chage.c +++ b/src/chage.c @@ -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); } diff --git a/src/chfn.c b/src/chfn.c index d757c9e6..d614ad66 100644 --- a/src/chfn.c +++ b/src/chfn.c @@ -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; } /* diff --git a/src/chsh.c b/src/chsh.c index e1c68709..ffc771b0 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -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); } diff --git a/src/gpasswd.c b/src/gpasswd.c index 9e1edb47..909fe280 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -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", diff --git a/src/groupadd.c b/src/groupadd.c index 0cd799d1..de23adb3 100644 --- a/src/groupadd.c +++ b/src/groupadd.c @@ -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", diff --git a/src/groupdel.c b/src/groupdel.c index 08effa28..9a2a7164 100644 --- a/src/groupdel.c +++ b/src/groupdel.c @@ -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", diff --git a/src/groupmod.c b/src/groupmod.c index 3424053c..fe41f33f 100644 --- a/src/groupmod.c +++ b/src/groupmod.c @@ -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", diff --git a/src/grpconv.c b/src/grpconv.c index 9c463f65..a245a400 100644 --- a/src/grpconv.c +++ b/src/grpconv.c @@ -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) { diff --git a/src/grpunconv.c b/src/grpunconv.c index ea9d4634..18bf3c5c 100644 --- a/src/grpunconv.c +++ b/src/grpunconv.c @@ -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); } diff --git a/src/passwd.c b/src/passwd.c index 990e29a3..92873764 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -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) { diff --git a/src/pwck.c b/src/pwck.c index dac85557..ed6fd6c8 100644 --- a/src/pwck.c +++ b/src/pwck.c @@ -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); } } diff --git a/src/pwconv.c b/src/pwconv.c index 1e751ea6..cfa07504 100644 --- a/src/pwconv.c +++ b/src/pwconv.c @@ -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"), diff --git a/src/pwunconv.c b/src/pwunconv.c index a4896577..6481e729 100644 --- a/src/pwunconv.c +++ b/src/pwunconv.c @@ -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); } diff --git a/src/useradd.c b/src/useradd.c index da8ab5c5..3030c29b 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -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", diff --git a/src/usermod.c b/src/usermod.c index 99f53a57..025fd6a6 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -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); } diff --git a/src/vipw.c b/src/vipw.c index f57c106f..037808aa 100644 --- a/src/vipw.c +++ b/src/vipw.c @@ -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.