* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,

lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
	Added *_dbname() functions to retrieve the name of the databases.
	* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
	lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h:
	*_name() functions renamed *setname().
	* src/grpck.c, src/pwck.c: Likewise.
	* lib/groupio.h, lib/pwio.h, lib/sgroupio.h, lib/shadowio.h: Added
	the name of the arguments to the prototypes.
	* src/chage, src/chfn.c, src/chgpasswd.c, src/chpasswd.c,
	src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupdel.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:
	Harmonize the erro & syslog messages in case of failure of the
	*_lock(), *_open(), *_close(), *_unlock(), *_remove() functions.
	* src/chgpasswd.c, src/chpasswd.c, src/usermod.c: Avoid
	capitalized messages.
	* src/chpasswd.c, src/useradd.c, src/usermod.c: Harmonize messages
	in case of inexistent entries.
	* src/usermod.c:  Harmonize messages in case of already existing
	entries.
	* src/newusers.c, src/useradd.c: Simplify PAM error handling.
	* src/useradd.c: Report failures to unlock files (stderr, syslog,
	and audit). But do not fail (continue).
	* src/useradd.c (open_files): Do not report to syslog & audit
	failures to lock or open the databases. This might be harmless,
	and the logs were not already informed that a change was
	requested.
	* src/usermod.c: It's not the account which is unlocked, but its
	password.
This commit is contained in:
nekral-guest
2008-08-06 15:57:31 +00:00
parent b0fe7d3a0b
commit 7fc596fb8a
29 changed files with 703 additions and 528 deletions

View File

@ -417,16 +417,18 @@ static void update_gecos (const char *user, char *gecos)
* password file. Get a lock on the file and open it.
*/
if (pw_lock () == 0) {
fputs (_("Cannot lock the password file; try again later.\n"),
stderr);
SYSLOG ((LOG_WARN, "can't lock /etc/passwd"));
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, pw_dbname ());
SYSLOG ((LOG_WARN, "cannot lock %s", pw_dbname ()));
closelog ();
exit (E_NOPERM);
}
if (pw_open (O_RDWR) == 0) {
fputs (_("Cannot open the password file.\n"), stderr);
fprintf (stderr,
_("%s: cannot open %s\n"), Prog, pw_dbname ());
pw_unlock ();
SYSLOG ((LOG_ERR, "can't open /etc/passwd"));
SYSLOG ((LOG_ERR, "cannot open %s", pw_dbname ()));
closelog ();
exit (E_NOPERM);
}
@ -441,7 +443,8 @@ static void update_gecos (const char *user, char *gecos)
if (NULL == pw) {
pw_unlock ();
fprintf (stderr,
_("%s: %s not found in /etc/passwd\n"), Prog, user);
_("%s: user '%s' does not exist in %s\n"),
Prog, user, pw_dbname ());
exit (E_NOPERM);
}
@ -468,15 +471,15 @@ static void update_gecos (const char *user, char *gecos)
* Changes have all been made, so commit them and unlock the file.
*/
if (pw_close () == 0) {
fputs (_("Cannot commit password file changes.\n"), stderr);
fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
pw_unlock ();
SYSLOG ((LOG_ERR, "can't rewrite /etc/passwd"));
SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
closelog ();
exit (E_NOPERM);
}
if (pw_unlock () == 0) {
fputs (_("Cannot unlock the password file.\n"), stderr);
SYSLOG ((LOG_ERR, "can't unlock /etc/passwd"));
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
closelog ();
exit (E_NOPERM);
}
@ -633,7 +636,7 @@ int main (int argc, char **argv)
user = argv[optind];
pw = xgetpwnam (user);
if (NULL == pw) {
fprintf (stderr, _("%s: unknown user %s\n"), Prog,
fprintf (stderr, _("%s: user '%s' does not exist\n"), Prog,
user);
exit (E_NOPERM);
}
@ -641,8 +644,7 @@ int main (int argc, char **argv)
pw = get_my_pwent ();
if (NULL == pw) {
fprintf (stderr,
_
("%s: Cannot determine your user name.\n"),
_("%s: Cannot determine your user name.\n"),
Prog);
exit (E_NOPERM);
}