* src/pwck.c: Only log to SYSLOG when acting on system files.

This commit is contained in:
nekral-guest 2010-03-18 10:35:11 +00:00
parent 657271eb04
commit 6a1dea6602
2 changed files with 59 additions and 26 deletions

View File

@ -1,3 +1,7 @@
2010-03-18 Nicolas François <nicolas.francois@centraliens.net>
* src/pwck.c: Only log to SYSLOG when acting on system files.
2010-03-18 Nicolas François <nicolas.francois@centraliens.net> 2010-03-18 Nicolas François <nicolas.francois@centraliens.net>
* src/pwck.c: Document the sections closed by #endif * src/pwck.c: Document the sections closed by #endif

View File

@ -3,7 +3,7 @@
* Copyright (c) 1996 - 2000, Marek Michałkiewicz * Copyright (c) 1996 - 2000, Marek Michałkiewicz
* Copyright (c) 2001 , Michał Moskal * Copyright (c) 2001 , Michał Moskal
* Copyright (c) 2001 - 2006, Tomasz Kłoczko * Copyright (c) 2001 - 2006, Tomasz Kłoczko
* Copyright (c) 2007 - 2009, Nicolas François * Copyright (c) 2007 - 2010, Nicolas François
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -101,7 +101,10 @@ static void fail_exit (int code)
if (spw_locked) { if (spw_locked) {
if (spw_unlock () == 0) { if (spw_unlock () == 0) {
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ())); if (use_system_spw_file) {
SYSLOG ((LOG_ERR, "failed to unlock %s",
spw_dbname ()));
}
/* continue */ /* continue */
} }
} }
@ -109,7 +112,10 @@ static void fail_exit (int code)
if (pw_locked) { if (pw_locked) {
if (pw_unlock () == 0) { if (pw_unlock () == 0) {
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ())); if (use_system_pw_file) {
SYSLOG ((LOG_ERR, "failed to unlock %s",
pw_dbname ()));
}
/* continue */ /* continue */
} }
} }
@ -283,9 +289,11 @@ static void close_files (bool changed)
fprintf (stderr, fprintf (stderr,
_("%s: failure while writing changes to %s\n"), _("%s: failure while writing changes to %s\n"),
Prog, pw_dbname ()); Prog, pw_dbname ());
if (use_system_pw_file) {
SYSLOG ((LOG_ERR, SYSLOG ((LOG_ERR,
"failure while writing changes to %s", "failure while writing changes to %s",
pw_dbname ())); pw_dbname ()));
}
fail_exit (E_CANTUPDATE); fail_exit (E_CANTUPDATE);
} }
pw_opened = false; pw_opened = false;
@ -293,9 +301,11 @@ static void close_files (bool changed)
fprintf (stderr, fprintf (stderr,
_("%s: failure while writing changes to %s\n"), _("%s: failure while writing changes to %s\n"),
Prog, spw_dbname ()); Prog, spw_dbname ());
if (use_system_spw_file) {
SYSLOG ((LOG_ERR, SYSLOG ((LOG_ERR,
"failure while writing changes to %s", "failure while writing changes to %s",
spw_dbname ())); spw_dbname ()));
}
fail_exit (E_CANTUPDATE); fail_exit (E_CANTUPDATE);
} }
spw_opened = false; spw_opened = false;
@ -306,16 +316,26 @@ static void close_files (bool changed)
*/ */
if (spw_locked) { if (spw_locked) {
if (spw_unlock () == 0) { if (spw_unlock () == 0) {
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); fprintf (stderr,
SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ())); _("%s: failed to unlock %s\n"),
Prog, spw_dbname ());
if (use_system_spw_file) {
SYSLOG ((LOG_ERR, "failed to unlock %s",
spw_dbname ()));
}
/* continue */ /* continue */
} }
} }
spw_locked = false; spw_locked = false;
if (pw_locked) { if (pw_locked) {
if (pw_unlock () == 0) { if (pw_unlock () == 0) {
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); fprintf (stderr,
SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ())); _("%s: failed to unlock %s\n"),
Prog, pw_dbname ());
if (use_system_pw_file) {
SYSLOG ((LOG_ERR, "failed to unlock %s",
pw_dbname ()));
}
/* continue */ /* continue */
} }
} }
@ -371,8 +391,10 @@ static void check_pw_file (int *errors, bool *changed)
* loop to try out the next list element. * loop to try out the next list element.
*/ */
delete_pw: delete_pw:
if (use_system_pw_file) {
SYSLOG ((LOG_INFO, "delete passwd line '%s'", SYSLOG ((LOG_INFO, "delete passwd line '%s'",
pfe->line)); pfe->line));
}
*changed = true; *changed = true;
__pw_del_entry (pfe); __pw_del_entry (pfe);
@ -522,10 +544,12 @@ static void check_pw_file (int *errors, bool *changed)
fprintf (stderr, fprintf (stderr,
_("%s: failed to unlock %s\n"), _("%s: failed to unlock %s\n"),
Prog, spw_dbname ()); Prog, spw_dbname ());
if (use_system_spw_file) {
SYSLOG ((LOG_ERR, SYSLOG ((LOG_ERR,
"failed to unlock %s", "failed to unlock %s",
spw_dbname ())); spw_dbname ()));
} }
}
continue; continue;
} }
spw_opened = true; spw_opened = true;
@ -595,9 +619,11 @@ static void check_pw_file (int *errors, bool *changed)
fprintf (stderr, fprintf (stderr,
_("%s: failure while writing changes to %s\n"), _("%s: failure while writing changes to %s\n"),
Prog, spw_dbname ()); Prog, spw_dbname ());
if (use_system_spw_file) {
SYSLOG ((LOG_ERR, SYSLOG ((LOG_ERR,
"failure while writing changes to %s", "failure while writing changes to %s",
spw_dbname ())); spw_dbname ()));
}
} else { } else {
spw_opened = false; spw_opened = false;
} }
@ -605,9 +631,10 @@ static void check_pw_file (int *errors, bool *changed)
fprintf (stderr, fprintf (stderr,
_("%s: failed to unlock %s\n"), _("%s: failed to unlock %s\n"),
Prog, spw_dbname ()); Prog, spw_dbname ());
SYSLOG ((LOG_ERR, if (use_system_spw_file) {
"failed to unlock %s", SYSLOG ((LOG_ERR, "failed to unlock %s",
spw_dbname ())); spw_dbname ()));
}
} else { } else {
spw_locked = false; spw_locked = false;
} }
@ -672,8 +699,10 @@ static void check_spw_file (int *errors, bool *changed)
* to try out the next list element. * to try out the next list element.
*/ */
delete_spw: delete_spw:
if (use_system_spw_file) {
SYSLOG ((LOG_INFO, "delete shadow line '%s'", SYSLOG ((LOG_INFO, "delete shadow line '%s'",
spe->line)); spe->line));
}
*changed = true; *changed = true;
__spw_del_entry (spe); __spw_del_entry (spe);