* src/chage.c, src/chgpasswd.c, src/chpasswd.c, src/chsh.c,

src/gpasswd.c, src/groupadd.c, src/groupdel.c, src/groupmems.c,
	src/groupmod.c, src/grpck.c, src/grpconv.c, src/grpunconv.c,
	src/newusers.c, src/passwd.c, src/pwck.c, src/pwconv.c,
	src/pwunconv.c, src/useradd.c, src/userdel.c, src/usermod.c: In
	case of a lock failure, indicate to the user that she can try
	again later. Do not log to syslog.
This commit is contained in:
nekral-guest 2008-08-22 02:20:53 +00:00
parent 130553a578
commit 82ed690817
21 changed files with 111 additions and 79 deletions

View File

@ -1,3 +1,13 @@
2008-08-17 Nicolas François <nicolas.francois@centraliens.net>
* src/chage.c, src/chgpasswd.c, src/chpasswd.c, src/chsh.c,
src/gpasswd.c, src/groupadd.c, src/groupdel.c, src/groupmems.c,
src/groupmod.c, src/grpck.c, src/grpconv.c, src/grpunconv.c,
src/newusers.c, src/passwd.c, src/pwck.c, src/pwconv.c,
src/pwunconv.c, src/useradd.c, src/userdel.c, src/usermod.c: In
case of a lock failure, indicate to the user that she can try
again later. Do not log to syslog.
2008-08-17 Nicolas François <nicolas.francois@centraliens.net>
* NEWS, src/passwd.c: For compatibility with other passwd version,

View File

@ -561,13 +561,13 @@ static void open_files (bool readonly)
* file entries into memory. Then we get a pointer to the password
* file entry for the requested user.
*/
if (!readonly && (pw_lock () == 0)) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, pw_dbname ());
SYSLOG ((LOG_ERR, "cannot lock %s", pw_dbname ()));
fail_exit (E_NOPERM);
}
if (!readonly) {
if (pw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
fail_exit (E_NOPERM);
}
pw_locked = true;
}
if (pw_open (readonly ? O_RDONLY: O_RDWR) == 0) {
@ -582,13 +582,13 @@ static void open_files (bool readonly)
* does not have to exist in this case; a new entry will be created
* for this user if one does not exist already.
*/
if (!readonly && (spw_lock () == 0)) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, spw_dbname ());
SYSLOG ((LOG_ERR, "cannot lock %s", spw_dbname ()));
fail_exit (E_NOPERM);
}
if (!readonly) {
if (spw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, spw_dbname ());
fail_exit (E_NOPERM);
}
spw_locked = true;
}
if (spw_open (readonly ? O_RDONLY: O_RDWR) == 0) {

View File

@ -290,7 +290,8 @@ static void open_files (void)
*/
if (gr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, gr_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
fail_exit (1);
}
group_locked = true;
@ -304,7 +305,8 @@ static void open_files (void)
/* Do the same for the shadowed database, if it exist */
if (is_shadow_grp) {
if (sgr_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"),
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
fail_exit (1);
}

View File

@ -284,7 +284,8 @@ static void open_files (void)
*/
if (pw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, pw_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
fail_exit (1);
}
passwd_locked = true;
@ -298,7 +299,7 @@ static void open_files (void)
if (is_shadow_pwd) {
if (spw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"),
_("%s: cannot lock %s; try again later.\n"),
Prog, spw_dbname ());
fail_exit (1);
}

View File

@ -365,7 +365,6 @@ static void update_shell (const char *user, char *newshell)
if (pw_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", pw_dbname ()));
fail_exit (1);
}
pw_locked = true;

View File

@ -368,8 +368,9 @@ static void check_flags (int argc, int opt_index)
static void open_files (void)
{
if (gr_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", gr_dbname ()));
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"locking /etc/group",
@ -382,8 +383,8 @@ static void open_files (void)
if (is_shadowgrp) {
if (sgr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, sgr_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ()));
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"locking /etc/gshadow",

View File

@ -298,8 +298,9 @@ static void close_files (void)
static void open_files (void)
{
if (gr_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", gr_dbname ()));
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"locking group file",
@ -322,8 +323,8 @@ static void open_files (void)
if (is_shadow_grp) {
if (sgr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, sgr_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ()));
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"locking gshadow file",

View File

@ -222,8 +222,8 @@ static void open_files (void)
{
if (gr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, gr_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s",gr_dbname ()));
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
fail_exit (E_GRP_UPDATE);
}
group_locked = true;
@ -237,9 +237,8 @@ static void open_files (void)
if (is_shadow_grp) {
if (sgr_lock () == 0)) {
fprintf (stderr,
_("%s: cannot lock %s\n"),
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ()));
fail_exit (E_GRP_UPDATE);
}
gshadow_locked = true;

View File

@ -254,7 +254,7 @@ int main (int argc, char **argv)
if (gr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"),
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
fail_exit (EXIT_GROUP_FILE);
}

View File

@ -586,8 +586,9 @@ static void close_files (void)
static void open_files (void)
{
if (gr_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", gr_dbname ()));
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
fail_exit (E_GRP_UPDATE);
}
group_locked = true;
@ -600,9 +601,8 @@ static void open_files (void)
if (is_shadow_grp) {
if (sgr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"),
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ()));
fail_exit (E_GRP_UPDATE);
}
gshadow_locked = true;
@ -618,9 +618,8 @@ static void open_files (void)
if (gflg) {
if (pw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"),
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", pw_dbname ()));
fail_exit (E_GRP_UPDATE);
}
passwd_locked = true;

View File

@ -211,21 +211,17 @@ static void open_files (void)
*/
if (!read_only) {
if (gr_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"),
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, grp_file);
if (use_system_grp_file) {
SYSLOG ((LOG_WARN, "cannot lock %s", grp_file));
}
closelog ();
exit (E_CANT_LOCK);
}
#ifdef SHADOWGRP
if (is_shadow && (sgr_lock () == 0)) {
fprintf (stderr, _("%s: cannot lock %s\n"),
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_file);
if (use_system_sgr_file) {
SYSLOG ((LOG_WARN, "cannot lock %s", sgr_file));
}
closelog ();
exit (E_CANT_LOCK);
}

View File

@ -83,7 +83,9 @@ int main (int argc, char **argv)
(void) textdomain (PACKAGE);
if (gr_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
fail_exit (5);
}
group_locked = true;
@ -93,7 +95,9 @@ int main (int argc, char **argv)
}
if (sgr_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, sgr_dbname ());
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
fail_exit (5);
}
gshadow_locked = true;

View File

@ -98,7 +98,8 @@ int main (int argc, char **argv)
if (gr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, gr_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
fail_exit (5);
}
group_locked = true;
@ -110,7 +111,8 @@ int main (int argc, char **argv)
if (sgr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, sgr_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
fail_exit (5);
}
gshadow_locked = true;

View File

@ -608,23 +608,31 @@ static void open_files (void)
* it gets locked, assume the others can be locked right away.
*/
if (pw_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, pw_dbname ());
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
fail_exit (1);
}
passwd_locked = true;
if (is_shadow && (spw_lock () == 0)) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, spw_dbname ());
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, spw_dbname ());
fail_exit (1);
}
shadow_locked = true;
if (gr_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
fail_exit (1);
}
group_locked = true;
#ifdef SHADOWGRP
if (is_shadow_grp && (sgr_lock () == 0)) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, sgr_dbname ());
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
fail_exit (1);
}
gshadow_locked = true;

View File

@ -515,7 +515,6 @@ static void update_noshadow (void)
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", pw_dbname ()));
exit (E_PWDBUSY);
}
if (pw_open (O_RDWR) == 0) {
@ -561,7 +560,6 @@ static void update_shadow (void)
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, spw_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", spw_dbname ()));
exit (E_PWDBUSY);
}
if (spw_open (O_RDWR) == 0) {

View File

@ -197,21 +197,17 @@ static void open_files (void)
*/
if (!read_only) {
if (pw_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"),
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, pwd_file);
if (use_system_pw_file) {
SYSLOG ((LOG_WARN, "cannot lock %s", pwd_file));
}
fail_exit (E_CANTLOCK);
}
pw_locked = true;
if (is_shadow) {
if (spw_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"),
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, spw_file);
if (use_system_spw_file) {
SYSLOG ((LOG_WARN, "cannot lock %s", spw_file));
}
fail_exit (E_CANTLOCK);
}
spw_locked = true;

View File

@ -127,7 +127,8 @@ int main (int argc, char **argv)
if (pw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, pw_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
fail_exit (E_PWDBUSY);
}
passwd_locked = true;
@ -139,7 +140,8 @@ int main (int argc, char **argv)
if (spw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, spw_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, spw_dbname ());
fail_exit (E_PWDBUSY);
}
shadow_locked = true;

View File

@ -93,7 +93,7 @@ int main (int argc, char **argv)
if (pw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"),
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
fail_exit (5);
}
@ -107,7 +107,7 @@ int main (int argc, char **argv)
if (spw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"),
_("%s: cannot lock %s; try again later.\n"),
Prog, spw_dbname ());
fail_exit (5);
}

View File

@ -1327,7 +1327,9 @@ static void close_files (void)
static void open_files (void)
{
if (pw_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, pw_dbname ());
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
exit (E_PW_UPDATE);
}
passwd_locked = true;
@ -1338,7 +1340,7 @@ static void open_files (void)
if (is_shadow_pwd) {
if (spw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"),
_("%s: cannot lock %s; try again later.\n"),
Prog, spw_dbname ());
fail_exit (E_PW_UPDATE);
}
@ -1355,7 +1357,9 @@ static void open_files (void)
* Lock and open the group file.
*/
if (gr_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
fail_exit (E_GRP_UPDATE);
}
group_locked = true;
@ -1367,7 +1371,7 @@ static void open_files (void)
if (is_shadow_grp) {
if (sgr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"),
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
fail_exit (E_GRP_UPDATE);
}

View File

@ -429,7 +429,9 @@ static void fail_exit (int code)
static void open_files (void)
{
if (pw_lock () == 0) {
fprintf (stderr, _("%s: cannot lock %s\n"), Prog, pw_dbname ());
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"locking password file",
@ -451,7 +453,8 @@ static void open_files (void)
if (is_shadow_pwd) {
if (spw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, spw_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, spw_dbname ());
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"locking shadow password file",
@ -462,7 +465,8 @@ static void open_files (void)
shadow_locked = true;
if (spw_open (O_RDWR) == 0) {
fprintf (stderr,
_("%s: cannot open %s\n"), Prog, spw_dbname ());
_("%s: cannot open %s\n"),
Prog, spw_dbname ());
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"opening shadow password file",
@ -473,7 +477,8 @@ static void open_files (void)
}
if (gr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, gr_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"locking group file",
@ -495,7 +500,8 @@ static void open_files (void)
if (is_shadow_grp) {
if (sgr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, sgr_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"locking shadow group file",

View File

@ -1197,7 +1197,8 @@ static void open_files (void)
{
if (pw_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, pw_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
fail_exit (E_PW_UPDATE);
}
pw_locked = true;
@ -1208,7 +1209,8 @@ static void open_files (void)
}
if (is_shadow_pwd && (spw_lock () == 0)) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, spw_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, spw_dbname ());
fail_exit (E_PW_UPDATE);
}
spw_locked = true;
@ -1225,7 +1227,8 @@ static void open_files (void)
*/
if (gr_lock () == 0) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, gr_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
fail_exit (E_GRP_UPDATE);
}
gr_locked = true;
@ -1237,7 +1240,8 @@ static void open_files (void)
#ifdef SHADOWGRP
if (is_shadow_grp && (sgr_lock () == 0)) {
fprintf (stderr,
_("%s: cannot lock %s\n"), Prog, sgr_dbname ());
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
fail_exit (E_GRP_UPDATE);
}
sgr_locked = true;