[Pkg-shadow-commits] r2243 - in upstream/trunk: . lib src

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Wed Aug 6 15:57:32 UTC 2008


Author: nekral-guest
Date: 2008-08-06 15:57:31 +0000 (Wed, 06 Aug 2008)
New Revision: 2243

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/lib/groupio.c
   upstream/trunk/lib/groupio.h
   upstream/trunk/lib/pwio.c
   upstream/trunk/lib/pwio.h
   upstream/trunk/lib/sgroupio.c
   upstream/trunk/lib/sgroupio.h
   upstream/trunk/lib/shadowio.c
   upstream/trunk/lib/shadowio.h
   upstream/trunk/src/chage.c
   upstream/trunk/src/chfn.c
   upstream/trunk/src/chgpasswd.c
   upstream/trunk/src/chpasswd.c
   upstream/trunk/src/chsh.c
   upstream/trunk/src/gpasswd.c
   upstream/trunk/src/groupadd.c
   upstream/trunk/src/groupdel.c
   upstream/trunk/src/groupmod.c
   upstream/trunk/src/grpck.c
   upstream/trunk/src/grpconv.c
   upstream/trunk/src/grpunconv.c
   upstream/trunk/src/newusers.c
   upstream/trunk/src/passwd.c
   upstream/trunk/src/pwck.c
   upstream/trunk/src/pwconv.c
   upstream/trunk/src/pwunconv.c
   upstream/trunk/src/useradd.c
   upstream/trunk/src/userdel.c
   upstream/trunk/src/usermod.c
Log:
	* 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.

Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/ChangeLog	2008-08-06 15:57:31 UTC (rev 2243)
@@ -1,3 +1,37 @@
+2008-08-06  Nicolas François  <nicolas.francois at centraliens.net>
+
+	* 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.
+
 2008-08-02  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* src/groupadd.c: Harmonize error & syslog messages.

Modified: upstream/trunk/lib/groupio.c
===================================================================
--- upstream/trunk/lib/groupio.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/lib/groupio.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -126,11 +126,16 @@
 	false			/* readonly */
 };
 
-int gr_name (const char *filename)
+int gr_setdbname (const char *filename)
 {
 	return commonio_setname (&group_db, filename);
 }
 
+const char *gr_dbname (void)
+{
+	return group_db.filename;
+}
+
 int gr_lock (void)
 {
 	return commonio_lock (&group_db);

Modified: upstream/trunk/lib/groupio.h
===================================================================
--- upstream/trunk/lib/groupio.h	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/lib/groupio.h	2008-08-06 15:57:31 UTC (rev 2243)
@@ -38,16 +38,17 @@
 #include <grp.h>
 
 extern int gr_close (void);
-extern const struct group *gr_locate (const char *);
+extern const struct group *gr_locate (const char *name);
 extern const struct group *gr_locate_gid (gid_t gid);
 extern int gr_lock (void);
-extern int gr_name (const char *);
+extern int gr_setdbname (const char *filename);
+extern const char *gr_dbname (void);
 extern const struct group *gr_next (void);
-extern int gr_open (int);
-extern int gr_remove (const char *);
+extern int gr_open (int mode);
+extern int gr_remove (const char *name);
 extern int gr_rewind (void);
 extern int gr_unlock (void);
-extern int gr_update (const struct group *);
+extern int gr_update (const struct group *gr);
 extern int gr_sort (void);
 
 #endif

Modified: upstream/trunk/lib/pwio.c
===================================================================
--- upstream/trunk/lib/pwio.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/lib/pwio.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -108,11 +108,16 @@
 	false			/* readonly */
 };
 
-int pw_name (const char *filename)
+int pw_setdbname (const char *filename)
 {
 	return commonio_setname (&passwd_db, filename);
 }
 
+const char *pw_dbname (void)
+{
+	return passwd_db.filename;
+}
+
 int pw_lock (void)
 {
 	return commonio_lock (&passwd_db);

Modified: upstream/trunk/lib/pwio.h
===================================================================
--- upstream/trunk/lib/pwio.h	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/lib/pwio.h	2008-08-06 15:57:31 UTC (rev 2243)
@@ -37,16 +37,17 @@
 
 #include <pwd.h>
 extern int pw_close (void);
-extern const struct passwd *pw_locate (const char *);
+extern const struct passwd *pw_locate (const char *name);
 extern const struct passwd *pw_locate_uid (uid_t uid);
 extern int pw_lock (void);
-extern int pw_name (const char *);
+extern int pw_setdbname (const char *filename);
+extern const char *pw_dbname (void);
 extern const struct passwd *pw_next (void);
-extern int pw_open (int);
-extern int pw_remove (const char *);
+extern int pw_open (int mode);
+extern int pw_remove (const char *name);
 extern int pw_rewind (void);
 extern int pw_unlock (void);
-extern int pw_update (const struct passwd *);
+extern int pw_update (const struct passwd *pw);
 extern int pw_sort (void);
 
 #endif

Modified: upstream/trunk/lib/sgroupio.c
===================================================================
--- upstream/trunk/lib/sgroupio.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/lib/sgroupio.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -161,11 +161,16 @@
 	false			/* readonly */
 };
 
-int sgr_name (const char *filename)
+int sgr_setdbname (const char *filename)
 {
 	return commonio_setname (&gshadow_db, filename);
 }
 
+const char *sgr_dbname (void)
+{
+	return gshadow_db.filename;
+}
+
 bool sgr_file_present (void)
 {
 	return commonio_present (&gshadow_db);

Modified: upstream/trunk/lib/sgroupio.h
===================================================================
--- upstream/trunk/lib/sgroupio.h	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/lib/sgroupio.h	2008-08-06 15:57:31 UTC (rev 2243)
@@ -37,15 +37,16 @@
 
 extern int sgr_close (void);
 extern bool sgr_file_present (void);
-extern const struct sgrp *sgr_locate (const char *);
+extern const struct sgrp *sgr_locate (const char *name);
 extern int sgr_lock (void);
-extern int sgr_name (const char *);
+extern int sgr_setdbname (const char *filename);
+extern const char *sgr_dbname (void);
 extern const struct sgrp *sgr_next (void);
-extern int sgr_open (int);
-extern int sgr_remove (const char *);
+extern int sgr_open (int mode);
+extern int sgr_remove (const char *name);
 extern int sgr_rewind (void);
 extern int sgr_unlock (void);
-extern int sgr_update (const struct sgrp *);
+extern int sgr_update (const struct sgrp *sg);
 extern int sgr_sort (void);
 
 #endif

Modified: upstream/trunk/lib/shadowio.c
===================================================================
--- upstream/trunk/lib/shadowio.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/lib/shadowio.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -105,11 +105,16 @@
 	false			/* readonly */
 };
 
-int spw_name (const char *filename)
+int spw_setdbname (const char *filename)
 {
 	return commonio_setname (&shadow_db, filename);
 }
 
+const char *spw_dbname (void)
+{
+	return shadow_db.filename;
+}
+
 bool spw_file_present (void)
 {
 	return commonio_present (&shadow_db);

Modified: upstream/trunk/lib/shadowio.h
===================================================================
--- upstream/trunk/lib/shadowio.h	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/lib/shadowio.h	2008-08-06 15:57:31 UTC (rev 2243)
@@ -38,15 +38,16 @@
 
 extern int spw_close (void);
 extern bool spw_file_present (void);
-extern const struct spwd *spw_locate (const char *);
+extern const struct spwd *spw_locate (const char *name);
 extern int spw_lock (void);
-extern int spw_name (const char *);
+extern int spw_setdbname (const char *filename);
+extern const char *spw_dbname (void);
 extern const struct spwd *spw_next (void);
-extern int spw_open (int);
-extern int spw_remove (const char *);
+extern int spw_open (int mode);
+extern int spw_remove (const char *name);
 extern int spw_rewind (void);
 extern int spw_unlock (void);
-extern int spw_update (const struct spwd *);
+extern int spw_update (const struct spwd *sp);
 extern int spw_sort (void);
 
 #endif

Modified: upstream/trunk/src/chage.c
===================================================================
--- upstream/trunk/src/chage.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/chage.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -555,16 +555,16 @@
 	 */
 	if (!readonly && (pw_lock () == 0)) {
 		fprintf (stderr,
-		         _("%s: can't lock password file\n"), Prog);
-		SYSLOG ((LOG_ERR, "failed locking %s", PASSWD_FILE));
+		         _("%s: cannot lock %s\n"), Prog, pw_dbname ());
+		SYSLOG ((LOG_ERR, "cannot lock %s", pw_dbname ()));
 		fail_exit (E_NOPERM);
 	}
 	if (!readonly) {
 		pw_locked = true;
 	}
 	if (pw_open (readonly ? O_RDONLY: O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open password file\n"), Prog);
-		SYSLOG ((LOG_ERR, "failed opening %s", PASSWD_FILE));
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ());
+		SYSLOG ((LOG_ERR, "cannot open %s", pw_dbname ()));
 		fail_exit (E_NOPERM);
 	}
 
@@ -576,8 +576,8 @@
 	 */
 	if (!readonly && (spw_lock () == 0)) {
 		fprintf (stderr,
-		         _("%s: can't lock shadow password file\n"), Prog);
-		SYSLOG ((LOG_ERR, "failed locking %s", SHADOW_FILE));
+		         _("%s: cannot lock %s\n"), Prog, spw_dbname ());
+		SYSLOG ((LOG_ERR, "cannot lock %s", spw_dbname ()));
 		fail_exit (E_NOPERM);
 	}
 	if (!readonly) {
@@ -585,8 +585,8 @@
 	}
 	if (spw_open (readonly ? O_RDONLY: O_RDWR) == 0) {
 		fprintf (stderr,
-		         _("%s: can't open shadow password file\n"), Prog);
-		SYSLOG ((LOG_ERR, "failed opening %s", SHADOW_FILE));
+		         _("%s: cannot open %s\n"), Prog, spw_dbname ());
+		SYSLOG ((LOG_ERR, "cannot open %s", spw_dbname ()));
 		fail_exit (E_NOPERM);
 	}
 }
@@ -602,8 +602,8 @@
 	 */
 	if (spw_close () == 0) {
 		fprintf (stderr,
-		         _("%s: can't rewrite shadow password file\n"), Prog);
-		SYSLOG ((LOG_ERR, "failed rewriting %s", SHADOW_FILE));
+		         _("%s: failure while writing changes to %s\n"), Prog, spw_dbname ());
+		SYSLOG ((LOG_ERR, "failure while writing changes to %s", spw_dbname ()));
 		fail_exit (E_NOPERM);
 	}
 
@@ -612,8 +612,8 @@
 	 * will be re-written.
 	 */
 	if (pw_close () == 0) {
-		fprintf (stderr, _("%s: can't rewrite password file\n"), Prog);
-		SYSLOG ((LOG_ERR, "failed rewriting %s", PASSWD_FILE));
+		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 (E_NOPERM);
 	}
 	spw_unlock ();
@@ -647,8 +647,8 @@
 		pwent.pw_passwd = SHADOW_PASSWD_STRING;	/* XXX warning: const */
 		if (pw_update (&pwent) == 0) {
 			fprintf (stderr,
-			         _("%s: can't update password file\n"), Prog);
-			SYSLOG ((LOG_ERR, "failed updating %s", PASSWD_FILE));
+			         _("%s: cannot update %s\n"), Prog, pw_dbname ());
+			SYSLOG ((LOG_ERR, "cannot update %s", pw_dbname ()));
 			fail_exit (E_NOPERM);
 		}
 	} else {
@@ -671,8 +671,8 @@
 
 	if (spw_update (&spwent) == 0) {
 		fprintf (stderr,
-		         _("%s: can't update shadow password file\n"), Prog);
-		SYSLOG ((LOG_ERR, "failed updating %s", SHADOW_FILE));
+		         _("%s: cannot update %s\n"), Prog, spw_dbname ());
+		SYSLOG ((LOG_ERR, "cannot update %s", spw_dbname ()));
 		fail_exit (E_NOPERM);
 	}
 
@@ -808,8 +808,8 @@
 
 	pw = pw_locate (argv[optind]);
 	if (NULL == pw) {
-		fprintf (stderr, _("%s: unknown user %s\n"), Prog,
-		         argv[optind]);
+		fprintf (stderr, _("%s: user '%s' does not exist in %s\n"),
+		         Prog, argv[optind], pw_dbname ());
 		closelog ();
 		exit (E_NOPERM);
 	}

Modified: upstream/trunk/src/chfn.c
===================================================================
--- upstream/trunk/src/chfn.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/chfn.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -417,16 +417,18 @@
 	 * 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 @@
 	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 @@
 	 * 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 @@
 		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 @@
 		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);
 		}

Modified: upstream/trunk/src/chgpasswd.c
===================================================================
--- upstream/trunk/src/chgpasswd.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/chgpasswd.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -178,7 +178,7 @@
 {
 	if (sflg && !cflg) {
 		fprintf (stderr,
-		         _("%s: %s flag is ONLY allowed with the %s flag\n"),
+		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-s", "-c");
 		usage ();
 	}
@@ -264,11 +264,13 @@
 	 * bring all of the entries into memory where they may be updated.
 	 */
 	if (gr_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock group file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"), Prog, gr_dbname ());
 		exit (1);
 	}
 	if (gr_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open group file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"), Prog, gr_dbname ());
 		gr_unlock ();
 		exit (1);
 	}
@@ -277,14 +279,14 @@
 	/* Do the same for the shadowed database, if it exist */
 	if (is_shadow_grp) {
 		if (sgr_lock () == 0) {
-			fprintf (stderr, _("%s: can't lock gshadow file\n"),
-			         Prog);
+			fprintf (stderr, _("%s: cannot lock %s\n"),
+			         Prog, sgr_dbname ());
 			gr_unlock ();
 			exit (1);
 		}
 		if (sgr_open (O_RDWR) == 0) {
-			fprintf (stderr, _("%s: can't open shadow file\n"),
-			         Prog);
+			fprintf (stderr, _("%s: cannot open %s\n"),
+			         Prog, sgr_dbname ());
 			gr_unlock ();
 			sgr_unlock ();
 			exit (1);
@@ -302,7 +304,8 @@
 	if (is_shadow_grp) {
 		if (sgr_close () == 0) {
 			fprintf (stderr,
-			         _("%s: error updating gshadow file\n"), Prog);
+			         _("%s: failure while writing changes to %s\n"),
+			         Prog, sgr_dbname ());
 			gr_unlock ();
 			exit (1);
 		}
@@ -311,7 +314,9 @@
 #endif
 
 	if (gr_close () == 0) {
-		fprintf (stderr, _("%s: error updating group file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: failure while writing changes to %s\n"),
+		         Prog, gr_dbname ());
 		exit (1);
 	}
 	gr_unlock ();
@@ -414,7 +419,7 @@
 		gr = gr_locate (name);
 		if (NULL == gr) {
 			fprintf (stderr,
-			         _("%s: line %d: unknown group %s\n"), Prog,
+			         _("%s: line %d: group '%s' does not exist\n"), Prog,
 			         line, name);
 			errors++;
 			continue;

Modified: upstream/trunk/src/chpasswd.c
===================================================================
--- upstream/trunk/src/chpasswd.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/chpasswd.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -175,7 +175,7 @@
 {
 	if (sflg && !cflg) {
 		fprintf (stderr,
-		         _("%s: %s flag is ONLY allowed with the %s flag\n"),
+		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-s", "-c");
 		usage ();
 	}
@@ -261,11 +261,13 @@
 	 * will bring all of the entries into memory where they may be updated.
 	 */
 	if (pw_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock password file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"), Prog, pw_dbname ());
 		exit (1);
 	}
 	if (pw_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open password file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"), Prog, pw_dbname ());
 		pw_unlock ();
 		exit (1);
 	}
@@ -273,14 +275,16 @@
 	/* Do the same for the shadowed database, if it exist */
 	if (is_shadow_pwd) {
 		if (spw_lock () == 0) {
-			fprintf (stderr, _("%s: can't lock shadow file\n"),
-			         Prog);
+			fprintf (stderr,
+			         _("%s: cannot lock %s\n"),
+			         Prog, spw_dbname ());
 			pw_unlock ();
 			exit (1);
 		}
 		if (spw_open (O_RDWR) == 0) {
-			fprintf (stderr, _("%s: can't open shadow file\n"),
-			         Prog);
+			fprintf (stderr,
+			         _("%s: cannot open %s\n"),
+			         Prog, spw_dbname ());
 			pw_unlock ();
 			spw_unlock ();
 			exit (1);
@@ -296,7 +300,8 @@
 	if (is_shadow_pwd) {
 		if (spw_close () == 0) {
 			fprintf (stderr,
-			         _("%s: error updating shadow file\n"), Prog);
+			         _("%s: failure while writing changes to %s\n"),
+			         Prog, spw_dbname ());
 			pw_unlock ();
 			exit (1);
 		}
@@ -304,7 +309,9 @@
 	}
 
 	if (pw_close () == 0) {
-		fprintf (stderr, _("%s: error updating password file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: failure while writing changes to %s\n"),
+		         Prog, pw_dbname ());
 		exit (1);
 	}
 	pw_unlock ();
@@ -407,7 +414,7 @@
 		pw = pw_locate (name);
 		if (NULL == pw) {
 			fprintf (stderr,
-			         _("%s: line %d: unknown user %s\n"), Prog,
+			         _("%s: line %d: user '%s' does not exist\n"), Prog,
 			         line, name);
 			errors++;
 			continue;
@@ -445,8 +452,7 @@
 
 		if (0 == ok) {
 			fprintf (stderr,
-			         _
-			         ("%s: line %d: cannot update password entry\n"),
+			         _("%s: line %d: cannot update password entry\n"),
 			         Prog, line);
 			errors++;
 			continue;

Modified: upstream/trunk/src/chsh.c
===================================================================
--- upstream/trunk/src/chsh.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/chsh.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -352,16 +352,16 @@
 	 * the password file. Get a lock on the file and open it.
 	 */
 	if (pw_lock () == 0) {
-		SYSLOG ((LOG_WARN, "can't lock /etc/passwd"));
+		SYSLOG ((LOG_WARN, "cannot lock %s", pw_dbname ()));
 		closelog ();
-		fputs (_("Cannot lock the password file; try again later.\n"),
-		       stderr);
+		fprintf (stderr, _("%s: cannot lock %s; try again later.\n"),
+		         Prog, pw_dbname ());
 		exit (1);
 	}
 	if (pw_open (O_RDWR) == 0) {
-		SYSLOG ((LOG_ERR, "can't open /etc/passwd"));
+		SYSLOG ((LOG_ERR, "cannot open %s", pw_dbname ()));
 		closelog ();
-		fputs (_("Cannot open the password file.\n"), stderr);
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ());
 		pw_unlock ();
 		exit (1);
 	}
@@ -376,7 +376,8 @@
 	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 (1);
 	}
 
@@ -403,16 +404,17 @@
 	 * Changes have all been made, so commit them and unlock the file.
 	 */
 	if (pw_close () == 0) {
-		SYSLOG ((LOG_ERR, "can't rewrite /etc/passwd"));
+		SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
 		closelog ();
-		fputs (_("Cannot commit password file changes.\n"), stderr);
+		fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
 		pw_unlock ();
 		exit (1);
 	}
 	if (pw_unlock () == 0) {
-		SYSLOG ((LOG_ERR, "can't unlock /etc/passwd"));
+		SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
 		closelog ();
-		fputs (_("Cannot unlock the password file.\n"), stderr);
+		fprintf (stderr,
+		         _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
 		exit (1);
 	}
 }
@@ -459,7 +461,7 @@
 		pw = xgetpwnam (user);
 		if (NULL == pw) {
 			fprintf (stderr,
-			         _("%s: unknown user %s\n"), Prog, user);
+			         _("%s: user '%s' does not exist\n"), Prog, user);
 			exit (1);
 		}
 	} else {

Modified: upstream/trunk/src/gpasswd.c
===================================================================
--- upstream/trunk/src/gpasswd.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/gpasswd.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -162,8 +162,8 @@
 {
 	if (group_locked) {
 		if (gr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking group file",
@@ -174,8 +174,8 @@
 #ifdef SHADOWGRP
 	if (gshadow_locked) {
 		if (sgr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the shadow group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking gshadow file",
@@ -368,8 +368,8 @@
 static void open_files (void)
 {
 	if (gr_lock () == 0) {
-		fprintf (stderr, _("%s: cannot lock the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot lock the group file"));
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot lock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "locking /etc/group",
@@ -382,8 +382,8 @@
 	if (is_shadowgrp) {
 		if (sgr_lock () == 0) {
 			fprintf (stderr,
-			         _("%s: cannot lock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot lock the shadow group file"));
+			         _("%s: cannot lock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "locking /etc/gshadow",
@@ -395,8 +395,8 @@
 	}
 #endif
 	if (gr_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: cannot open the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot open the group file"));
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "opening /etc/group",
@@ -406,8 +406,8 @@
 	}
 #ifdef SHADOWGRP
 	if (is_shadowgrp && (sgr_open (O_RDWR) == 0)) {
-		fprintf (stderr, _("%s: cannot open the shadow group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot open the shadow group file"));
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, sgr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "opening /etc/gshadow",
@@ -428,8 +428,8 @@
 static void close_files (void)
 {
 	if (gr_close () == 0) {
-		fprintf (stderr, _("%s: cannot rewrite the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot rewrite the group file"));
+		fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "rewriting /etc/group",
@@ -440,8 +440,8 @@
 #ifdef SHADOWGRP
 	if (is_shadowgrp) {
 		if (sgr_close () == 0) {
-			fprintf (stderr, _("%s: cannot rewrite the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot rewrite the shadow group file"));
+			fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "rewriting /etc/gshadow",
@@ -450,8 +450,8 @@
 			fail_exit (1);
 		}
 		if (sgr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the shadow group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking gshadow file",
@@ -463,8 +463,8 @@
 	}
 #endif
 	if (gr_unlock () == 0) {
-		fprintf (stderr, _("%s: cannot unlock the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot unlock the group file"));
+		fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "unlocking group file",
@@ -564,8 +564,10 @@
 #endif
 {
 	if (gr_update (gr) == 0) {
-		fprintf (stderr, _("%s: cannot update the entry of '%s' in the group file\n"), Prog, gr->gr_name);
-		SYSLOG ((LOG_WARN, "cannot update the entry of '%s' in the group file", gr->gr_name));
+		fprintf (stderr,
+		         _("%s: cannot update entry '%s' in %s\n"),
+		         Prog, gr->gr_name, gr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot update entry '%s' in %s", gr->gr_name, gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "updating /etc/group",
@@ -575,8 +577,8 @@
 	}
 #ifdef SHADOWGRP
 	if (is_shadowgrp && (sgr_update (sg) == 0)) {
-		fprintf (stderr, _("%s: cannot update the entry of '%s' in the shadow group file\n"), Prog, sg->sg_name);
-		SYSLOG ((LOG_WARN, "cannot update the entry of '%s' in the shadow group file", sg->sg_name));
+		fprintf (stderr, _("%s: cannot update entry '%s' in %s\n"), Prog, sg->sg_name, sgr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot update entry '%s' in %s", sg->sg_name, sgr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "updating /etc/gshadow",
@@ -605,8 +607,8 @@
 	struct sgrp const*tmpsg = NULL;
 
 	if (gr_open (O_RDONLY) == 0) {
-		fprintf (stderr, _("%s: cannot open the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot open the group file"));
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "opening /etc/group",
@@ -617,7 +619,7 @@
 
 	tmpgr = gr_locate (group);
 	if (NULL == tmpgr) {
-		fprintf (stderr, _("%s: group '%s' does not exist in the group file\n"), Prog, group);
+		fprintf (stderr, _("%s: group '%s' does not exist in %s\n"), Prog, group, gr_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "group lookup",
@@ -632,8 +634,8 @@
 	gr->gr_mem = dup_list (tmpgr->gr_mem);
 
 	if (gr_close () == 0) {
-		fprintf (stderr, _("%s: cannot rewrite the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot rewrite the group file"));
+		fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "closing /etc/group",
@@ -646,8 +648,8 @@
 	if (is_shadowgrp) {
 		if (sgr_open (O_RDONLY) == 0) {
 			fprintf (stderr,
-			         _("%s: cannot open the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot open the shadow group file"));
+			         _("%s: cannot open %s\n"), Prog, sgr_dbmane ());
+			SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "opening /etc/gshadow",
@@ -684,8 +686,8 @@
 		}
 		if (sgr_close () == 0) {
 			fprintf (stderr,
-			         _("%s: cannot rewrite the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot rewrite the shadow group file"));
+			         _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "closing /etc/gshadow",

Modified: upstream/trunk/src/groupadd.c
===================================================================
--- upstream/trunk/src/groupadd.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/groupadd.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -198,8 +198,8 @@
 	 * Write out the new group file entry.
 	 */
 	if (gr_update (&grp) == 0) {
-		fprintf (stderr, _("%s: error adding new entry '%s' in the group file\n"), Prog, grp.gr_name);
-		SYSLOG ((LOG_WARN, "error adding new entry '%s' in the group file", grp.gr_name));
+		fprintf (stderr, _("%s: error adding new entry '%s' in %s\n"), Prog, grp.gr_name, gr_dbname ());
+		SYSLOG ((LOG_WARN, "error adding new entry '%s' in %s", grp.gr_name, gr_dbname ()));
 		fail_exit (E_GRP_UPDATE);
 	}
 #ifdef	SHADOWGRP
@@ -207,8 +207,8 @@
 	 * Write out the new shadow group entries as well.
 	 */
 	if (is_shadow_grp && (sgr_update (&sgrp) == 0)) {
-		fprintf (stderr, _("%s: error adding new entry '%s' in the shadow group file\n"), Prog, sgrp.sg_name);
-		SYSLOG ((LOG_WARN, "error adding new entry '%s' in the shadow group file", sgrp.sg_name));
+		fprintf (stderr, _("%s: error adding new entry '%s' in %s\n"), Prog, sgrp.sg_name, sgr_dbname ());
+		SYSLOG ((LOG_WARN, "error adding new entry '%s' in %s", sgrp.sg_name, sgr_dbname ()));
 		fail_exit (E_GRP_UPDATE);
 	}
 #endif				/* SHADOWGRP */
@@ -252,13 +252,13 @@
 static void close_files (void)
 {
 	if (gr_close () == 0) {
-		fprintf (stderr, _("%s: cannot rewrite the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot rewrite the group file"));
+		fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
 		fail_exit (E_GRP_UPDATE);
 	}
 	if (gr_unlock () == 0) {
-		fprintf (stderr, _("%s: cannot unlock the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot unlock the group file"));
+		fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "unlocking group file",
@@ -271,13 +271,13 @@
 	if (is_shadow_grp) {
 		if (sgr_close () == 0) {
 			fprintf (stderr,
-			         _("%s: cannot rewrite the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot rewrite the shadow group file"));
+			         _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 		if (sgr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the shadow group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking gshadow file",
@@ -298,8 +298,8 @@
 static void open_files (void)
 {
 	if (gr_lock () == 0) {
-		fprintf (stderr, _("%s: cannot lock the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot lock the group file"));
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot lock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "locking group file",
@@ -309,8 +309,8 @@
 	}
 	group_locked = true;
 	if (gr_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: cannot open the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot open the group file"));
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "opening group file",
@@ -322,8 +322,8 @@
 	if (is_shadow_grp) {
 		if (sgr_lock () == 0) {
 			fprintf (stderr,
-			         _("%s: cannot lock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot lock the shadow group file"));
+			         _("%s: cannot lock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "locking gshadow file",
@@ -334,8 +334,8 @@
 		gshadow_locked = true;
 		if (sgr_open (O_RDWR) == 0) {
 			fprintf (stderr,
-			         _("%s: cannot open the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot open the shadow group file"));
+			         _("%s: cannot open %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "opening gshadow file",
@@ -354,8 +354,8 @@
 {
 	if (group_locked) {
 		if (gr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking group file",
@@ -367,8 +367,8 @@
 #ifdef	SHADOWGRP
 	if (gshadow_locked) {
 		if (sgr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the shadow group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking gshadow file",
@@ -469,8 +469,7 @@
 			cp = strchr (optarg, '=');
 			if (NULL == cp) {
 				fprintf (stderr,
-				         _
-				         ("%s: -K requires KEY=VALUE\n"),
+				         _("%s: -K requires KEY=VALUE\n"),
 				         Prog);
 				exit (E_BAD_ARG);
 			}
@@ -547,8 +546,8 @@
 			/* Turn off -g, we can use any GID */
 			gflg = false;
 		} else {
-			fprintf (stderr, _("%s: GID '%u' already exists\n"),
-			         Prog, (unsigned int) group_id);
+			fprintf (stderr, _("%s: GID '%lu' already exists\n"),
+			         Prog, (unsigned long int) group_id);
 			fail_exit (E_GID_IN_USE);
 		}
 	}

Modified: upstream/trunk/src/groupdel.c
===================================================================
--- upstream/trunk/src/groupdel.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/groupdel.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -96,8 +96,8 @@
 {
 	if (group_locked) {
 		if (gr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking group file",
@@ -109,8 +109,8 @@
 #ifdef	SHADOWGRP
 	if (gshadow_locked) {
 		if (sgr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the shadow group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking gshadow file",
@@ -138,7 +138,9 @@
 static void grp_update (void)
 {
 	if (gr_remove (group_name) == 0) {
-		fprintf (stderr, _("%s: cannot remove group '%s' from the group database\n"), Prog, group_name);
+		fprintf (stderr,
+		         _("%s: cannot remove entry '%s' from %s\n"),
+		         Prog, group_name, gr_dbname ());
 		fail_exit (E_GRP_UPDATE);
 	}
 #ifdef	SHADOWGRP
@@ -148,8 +150,8 @@
 	if (is_shadow_grp && (sgr_locate (group_name) != NULL)) {
 		if (sgr_remove (group_name) == 0) {
 			fprintf (stderr,
-			         _("%s: cannot remove group '%s' from the shadow group database\n"),
-			         Prog, group_name);
+			         _("%s: cannot remove entry '%s' from %s\n"),
+			         Prog, group_name, sgr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 	}
@@ -173,13 +175,13 @@
 	SYSLOG ((LOG_INFO, "remove group '%s'\n", group_name));
 
 	if (gr_close () == 0) {
-		fprintf (stderr, _("%s: cannot rewrite the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot rewrite the group file"));
+		fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
 		fail_exit (E_GRP_UPDATE);
 	}
 	if (gr_unlock () == 0) {
-		fprintf (stderr, _("%s: cannot unlock the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot unlock the group file"));
+		fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "unlocking group file",
@@ -192,13 +194,13 @@
 	if (is_shadow_grp) {
 		if (sgr_close () == 0)) {
 			fprintf (stderr,
-			         _("%s: cannot rewrite the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot rewrite the shadow group file"));
+			         _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 		if (sgr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the shadow group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking gshadow file",
@@ -219,29 +221,33 @@
 static void open_files (void)
 {
 	if (gr_lock () == 0) {
-		fprintf (stderr, _("%s: cannot lock the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot lock the group file"));
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot lock %s",gr_dbname ()));
 		fail_exit (E_GRP_UPDATE);
 	}
 	group_locked = true;
 	if (gr_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: cannot open the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot open the group file"));
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
 		fail_exit (E_GRP_UPDATE);
 	}
 #ifdef	SHADOWGRP
 	if (is_shadow_grp) {
 		if (sgr_lock () == 0)) {
 			fprintf (stderr,
-			         _("%s: cannot lock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot lock the shadow group file"));
+			         _("%s: cannot lock %s\n"),
+			         Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 		gshadow_locked = true;
 		if (sgr_open (O_RDWR) == 0)) {
 			fprintf (stderr,
-			         _("%s: cannot open the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot open the shadow group file"));
+			         _("%s: cannot open %s\n"),
+			         Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 	}

Modified: upstream/trunk/src/groupmod.c
===================================================================
--- upstream/trunk/src/groupmod.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/groupmod.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -125,8 +125,8 @@
 {
 	if (group_locked) {
 		if (gr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking group file",
@@ -138,8 +138,8 @@
 #ifdef	SHADOWGRP
 	if (gshadow_locked) {
 		if (sgr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the shadow group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking gshadow file",
@@ -151,8 +151,8 @@
 #endif				/* SHADOWGRP */
 	if (passwd_locked) {
 		if (pw_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the passwd file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the passwd file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", pw_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking passwd file",
@@ -225,8 +225,8 @@
 	ogrp = gr_locate (group_name);
 	if (!ogrp) {
 		fprintf (stderr,
-			 _("%s: group '%s' does not exist in the group file\n"),
-			 Prog, group_name);
+			 _("%s: group '%s' does not exist in %s\n"),
+			 Prog, group_name, gr_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "modifying group",
@@ -257,7 +257,9 @@
 	 * Write out the new group file entry.
 	 */
 	if (gr_update (&grp) == 0) {
-		fprintf (stderr, _("%s: cannot add entry '%s' to the group database\n"), Prog, grp.gr_name);
+		fprintf (stderr,
+		         _("%s: cannot add entry '%s' to %s\n"),
+		         Prog, grp.gr_name, gr_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "adding group",
@@ -266,7 +268,9 @@
 		fail_exit (E_GRP_UPDATE);
 	}
 	if (nflg && (gr_remove (group_name) == 0)) {
-		fprintf (stderr, _("%s: cannot remove the entry of '%s' from the group database\n"), Prog, grp.gr_name);
+		fprintf (stderr,
+		         _("%s: cannot remove entry '%s' from %s\n"),
+		         Prog, grp.gr_name, gr_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "deleting group",
@@ -281,14 +285,15 @@
 	 * "out" if there wasn't. Can't just return because there might be
 	 * some syslogging to do.
 	 */
-	if (NULL == osgrp)
+	if (NULL == osgrp) {
 		goto out;
+	}
 
 	/*
 	 * Write out the new shadow group entries as well.
 	 */
 	if (is_shadow_grp && (sgr_update (&sgrp) == 0)) {
-		fprintf (stderr, _("%s: cannot add entry '%s' to the shadow group database\n"), Prog, sgrp.sg_name);
+		fprintf (stderr, _("%s: cannot add entry '%s' to %s\n"), Prog, sgrp.sg_name, sgr_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "adding group",
@@ -297,7 +302,9 @@
 		fail_exit (E_GRP_UPDATE);
 	}
 	if (is_shadow_grp && nflg && (sgr_remove (group_name) == 0)) {
-		fprintf (stderr, _("%s: cannot remove the entry of '%s' from the shadow group database\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot remove entry '%s' from %s\n"),
+		         Prog, sgr_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "deleting group",
@@ -499,8 +506,8 @@
 static void close_files (void)
 {
 	if (gr_close () == 0) {
-		fprintf (stderr, _("%s: cannot rewrite group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot rewrite the group file"));
+		fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "rewrite group file",
@@ -509,8 +516,8 @@
 		fail_exit (E_GRP_UPDATE);
 	}
 	if (gr_unlock () == 0) {
-		fprintf (stderr, _("%s: cannot unlock the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot unlock the group file"));
+		fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "unlocking group file",
@@ -523,8 +530,8 @@
 	if (is_shadow_grp) {
 		if (sgr_close () == 0)) {
 			fprintf (stderr,
-			         _("%s: cannot rewrite the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot rewrite the shadow group file"));
+			         _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "rewrite gshadow file",
@@ -533,8 +540,8 @@
 			fail_exit (E_GRP_UPDATE);
 		}
 		if (sgr_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the shadow group file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the shadow group file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking gshadow file",
@@ -548,8 +555,8 @@
 	if (gflg) {
 		if (pw_close () == 0) {
 			fprintf (stderr,
-			         _("%s: cannot rewrite the passwd file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot rewrite the passwd file"));
+			         _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
+			SYSLOG ((LOG_WARN, "failure while writing changes to %s", pw_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "rewrite passwd file",
@@ -558,8 +565,8 @@
 			fail_exit (E_GRP_UPDATE);
 		}
 		if (pw_unlock () == 0) {
-			fprintf (stderr, _("%s: cannot unlock the passwd file\n"), Prog);
-			SYSLOG ((LOG_WARN, "cannot unlock the passwd file"));
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", pw_dbname ()));
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "unlocking passwd file",
@@ -579,31 +586,31 @@
 static void open_files (void)
 {
 	if (gr_lock () == 0) {
-		fprintf (stderr, _("%s: cannot lock the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot lock the group file"));
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot lock %s", gr_dbname ()));
 		fail_exit (E_GRP_UPDATE);
 	}
 	group_locked = true;
 	if (gr_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: cannot open the group file\n"), Prog);
-		SYSLOG ((LOG_WARN, "cannot open the group file"));
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
 		fail_exit (E_GRP_UPDATE);
 	}
 #ifdef	SHADOWGRP
 	if (is_shadow_grp) {
 		if (sgr_lock () == 0) {
 			fprintf (stderr,
-			         _("%s: cannot lock the shadow group file\n"),
-			         Prog);
-			SYSLOG ((LOG_WARN, "cannot lock the shadow group file"));
+			         _("%s: cannot lock %s\n"),
+			         Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 		gshadow_locked = true;
 		if (sgr_open (O_RDWR) == 0) {
 			fprintf (stderr,
-			         _("%s: cannot open the shadow group file\n"),
-			         Prog);
-			SYSLOG ((LOG_WARN, "cannot open the shadow group file"));
+			         _("%s: cannot open %s\n"),
+			         Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 	}
@@ -611,17 +618,17 @@
 	if (gflg) {
 		if (pw_lock () == 0) {
 			fprintf (stderr,
-			         _("%s: cannot lock the passwd file\n"),
-			         Prog);
-			SYSLOG ((LOG_WARN, "cannot lock the passwd file"));
+			         _("%s: cannot lock %s\n"),
+			         Prog, pw_dbname ());
+			SYSLOG ((LOG_WARN, "cannot lock %s", pw_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 		passwd_locked = true;
 		if (pw_open (O_RDWR) == 0) {
 			fprintf (stderr,
-			         _("%s: cannot open the passwd file\n"),
-			         Prog);
-			SYSLOG ((LOG_WARN, "cannot open the passwd file"));
+			         _("%s: cannot open %s\n"),
+			         Prog, pw_dbname ());
+			SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 	}
@@ -639,10 +646,11 @@
 			lpwd = pw_locate (pwd->pw_name);
 			if (NULL == lpwd) {
 				fprintf (stderr,
-				         _("%s: cannot change the primary group of user '%s' from %lu to %lu, since it is not in the passwd file.\n"),
+				         _("%s: cannot change the primary group of user '%s' from %lu to %lu, since it is not in %s.\n"),
 				         Prog, pwd->pw_name,
 				         (unsigned long) ogid,
-				         (unsigned long) ngid);
+				         (unsigned long) ngid,
+				         pw_dbname ());
 				fail_exit (E_GRP_UPDATE);
 			} else {
 				npwd = *lpwd;

Modified: upstream/trunk/src/grpck.c
===================================================================
--- upstream/trunk/src/grpck.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/grpck.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -183,13 +183,13 @@
 	 */
 	if (optind != argc) {
 		grp_file = argv[optind];
-		gr_name (grp_file);
+		gr_setdbname (grp_file);
 		use_system_grp_file = false;
 	}
 #ifdef	SHADOWGRP
 	if ((optind + 2) == argc) {
 		sgr_file = argv[optind + 1];
-		sgr_name (sgr_file);
+		sgr_setdbname (sgr_file);
 		is_shadow = true;
 		use_system_sgr_file = false;
 	} else if (optind == argc) {
@@ -211,7 +211,7 @@
 	 */
 	if (!read_only) {
 		if (gr_lock () == 0) {
-			fprintf (stderr, _("%s: cannot lock file %s\n"),
+			fprintf (stderr, _("%s: cannot lock %s\n"),
 			         Prog, grp_file);
 			if (use_system_grp_file) {
 				SYSLOG ((LOG_WARN, "cannot lock %s", grp_file));
@@ -221,7 +221,7 @@
 		}
 #ifdef	SHADOWGRP
 		if (is_shadow && (sgr_lock () == 0)) {
-			fprintf (stderr, _("%s: cannot lock file %s\n"),
+			fprintf (stderr, _("%s: cannot lock %s\n"),
 			         Prog, sgr_file);
 			if (use_system_sgr_file) {
 				SYSLOG ((LOG_WARN, "cannot lock %s", sgr_file));
@@ -237,7 +237,7 @@
 	 * O_RDWR otherwise.
 	 */
 	if (gr_open (read_only ? O_RDONLY : O_RDWR) == 0) {
-		fprintf (stderr, _("%s: cannot open file %s\n"), Prog,
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog,
 		         grp_file);
 		if (use_system_grp_file) {
 			SYSLOG ((LOG_WARN, "cannot open %s", grp_file));
@@ -247,7 +247,7 @@
 	}
 #ifdef	SHADOWGRP
 	if (is_shadow && (sgr_open (read_only ? O_RDONLY : O_RDWR) == 0)) {
-		fprintf (stderr, _("%s: cannot open file %s\n"), Prog,
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog,
 		         sgr_file);
 		if (use_system_sgr_file) {
 			SYSLOG ((LOG_WARN, "cannot open %s", sgr_file));
@@ -273,13 +273,13 @@
 	 */
 	if (changed) {
 		if (gr_close () == 0) {
-			fprintf (stderr, _("%s: cannot update file %s\n"),
+			fprintf (stderr, _("%s: failure while writing changes to %s\n"),
 			         Prog, grp_file);
 			exit (E_CANT_UPDATE);
 		}
 #ifdef	SHADOWGRP
 		if (is_shadow && (sgr_close () == 0)) {
-			fprintf (stderr, _("%s: cannot update file %s\n"),
+			fprintf (stderr, _("%s: failure while writing changes to %s\n"),
 			         Prog, sgr_file);
 			exit (E_CANT_UPDATE);
 		}

Modified: upstream/trunk/src/grpconv.c
===================================================================
--- upstream/trunk/src/grpconv.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/grpconv.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -83,22 +83,22 @@
 	(void) textdomain (PACKAGE);
 
 	if (gr_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock group file\n"), Prog);
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
 		fail_exit (5);
 	}
 	group_locked = true;
 	if (gr_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open group file\n"), Prog);
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
 		fail_exit (1);
 	}
 
 	if (sgr_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock shadow group file\n"), Prog);
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, sgr_dbname ());
 		fail_exit (5);
 	}
 	gshadow_locked = true;
 	if (sgr_open (O_CREAT | O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open shadow group file\n"), Prog);
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, sgr_dbname ());
 		fail_exit (1);
 	}
 
@@ -116,8 +116,8 @@
 			 * This shouldn't happen (the entry exists) but...
 			 */
 			fprintf (stderr,
-				 _("%s: can't remove shadow group %s\n"),
-				 Prog, sg->sg_name);
+			         _("%s: cannot remove entry '%s' from %s\n"),
+			         Prog, sg->sg_name, sgr_dbname ());
 			fail_exit (3);
 		}
 	}
@@ -171,12 +171,15 @@
 	}
 
 	if (sgr_close () == 0) {
-		fprintf (stderr, _("%s: can't update shadow group file\n"),
-			 Prog);
+		fprintf (stderr,
+		         _("%s: failure while writing changes to %s\n"),
+		         Prog, sgr_dbname ());
 		fail_exit (3);
 	}
 	if (gr_close () == 0) {
-		fprintf (stderr, _("%s: can't update group file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: failure while writing changes to %s\n"),
+		         Prog, gr_dbname ());
 		fail_exit (3);
 	}
 	sgr_unlock ();

Modified: upstream/trunk/src/grpunconv.c
===================================================================
--- upstream/trunk/src/grpunconv.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/grpunconv.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -2,6 +2,7 @@
  * Copyright (c) 1996       , Michael Meskes
  * Copyright (c) 1996 - 2000, Marek Michałkiewicz
  * Copyright (c) 2002 - 2006, Tomasz Kłoczko
+ * Copyright (c) 2008       , Nicolas François
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -86,22 +87,26 @@
 	}
 
 	if (gr_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock group file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"), Prog, gr_dbname ());
 		fail_exit (5);
 	}
 	group_locked = true;
 	if (gr_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open group file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"), Prog, gr_dbname ());
 		fail_exit (1);
 	}
 
 	if (sgr_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock shadow group file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"), Prog, sgr_dbname ());
 		fail_exit (5);
 	}
 	gshadow_locked = true;
 	if (sgr_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open shadow group file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"), Prog, sgr_dbname ());
 		fail_exit (1);
 	}
 
@@ -127,19 +132,23 @@
 	}
 
 	if (sgr_close () == 0) {
-		fprintf (stderr, _("%s: can't update shadow group file\n"),
-			 Prog);
+		fprintf (stderr,
+		         _("%s: failure while writing changes to %s\n"),
+		         Prog, sgr_dbname ());
 		fail_exit (3);
 	}
 
 	if (gr_close () == 0) {
-		fprintf (stderr, _("%s: can't update group file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: failure while writing changes to %s\n"),
+		         Prog, gr_dbname ());
 		fail_exit (3);
 	}
 
 	if (unlink (SGROUP_FILE) != 0) {
-		fprintf (stderr, _("%s: can't delete shadow group file\n"),
-			 Prog);
+		fprintf (stderr,
+		         _("%s: cannot delete %s\n"),
+		         Prog, SGROUP_FILE);
 		fail_exit (3);
 	}
 
@@ -158,3 +167,4 @@
 	exit (1);
 }
 #endif				/* !SHADOWGRP */
+

Modified: upstream/trunk/src/newusers.c
===================================================================
--- upstream/trunk/src/newusers.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/newusers.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -517,7 +517,7 @@
 {
 	if (sflg && !cflg) {
 		fprintf (stderr,
-		         _("%s: %s flag is ONLY allowed with the %s flag\n"),
+		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-s", "-c");
 		usage ();
 	}
@@ -556,29 +556,24 @@
 	struct passwd *pampw;
 
 	pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
-	if (pampw == NULL) {
+	if (NULL == pampw) {
 		retval = PAM_USER_UNKNOWN;
 	}
 
-	if (retval == PAM_SUCCESS) {
+	if (PAM_SUCCESS == retval) {
 		retval = pam_start ("newusers", pampw->pw_name, &conv, &pamh);
 	}
 
-	if (retval == PAM_SUCCESS) {
+	if (PAM_SUCCESS == retval) {
 		retval = pam_authenticate (pamh, 0);
-		if (retval != PAM_SUCCESS) {
-			(void) pam_end (pamh, retval);
-		}
 	}
 
-	if (retval == PAM_SUCCESS) {
+	if (PAM_SUCCESS == retval) {
 		retval = pam_acct_mgmt (pamh, 0);
-		if (retval != PAM_SUCCESS) {
-			(void) pam_end (pamh, retval);
-		}
 	}
 
-	if (retval != PAM_SUCCESS) {
+	if (PAM_SUCCESS != retval) {
+		(void) pam_end (pamh, retval);
 		fprintf (stderr, _("%s: PAM authentication failed\n"), Prog);
 		fail_exit (1);
 	}
@@ -597,23 +592,23 @@
 	 * it gets locked, assume the others can be locked right away.
 	 */
 	if (pw_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock /etc/passwd.\n"), Prog);
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, pw_dbname ());
 		fail_exit (1);
 	}
 	passwd_locked = true;
 	if (is_shadow && (spw_lock () == 0)) {
-		fprintf (stderr, _("%s: can't lock /etc/shadow.\n"), Prog);
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, spw_dbname ());
 		fail_exit (1);
 	}
 	shadow_locked = true;
 	if (gr_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock /etc/group.\n"), Prog);
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
 		fail_exit (1);
 	}
 	group_locked = true;
 #ifdef SHADOWGRP
 	if (is_shadow_grp && (sgr_lock () == 0)) {
-		fprintf (stderr, _("%s: can't lock /etc/gshadow.\n"), Prog);
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, sgr_dbname ());
 		fail_exit (1);
 	}
 	gshadow_locked = true;
@@ -800,8 +795,8 @@
 		pw = pw_locate (fields[0]);
 		if (NULL == pw) {
 			fprintf (stderr,
-			         _("%s: line %d: cannot find user %s\n"),
-			         Prog, line, fields[0]);
+			         _("%s: line %d: user '%s' does not exist in %s\n"),
+			         Prog, line, fields[0], pw_dbname ());
 			errors++;
 			continue;
 		}

Modified: upstream/trunk/src/passwd.c
===================================================================
--- upstream/trunk/src/passwd.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/passwd.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -512,20 +512,24 @@
 	struct passwd *npw;
 
 	if (pw_lock () == 0) {
-		fputs (_("Cannot lock the password file; try again later.\n"),
-		       stderr);
-		SYSLOG ((LOG_WARN, "can't lock password file"));
+		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) {
-		fputs (_("Cannot open the password file.\n"), stderr);
-		SYSLOG ((LOG_ERR, "can't open password file"));
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"),
+		         Prog, pw_dbname ());
+		SYSLOG ((LOG_ERR, "cannot open %s", pw_dbname ()));
 		fail_exit (E_MISSING);
 	}
 	pw = pw_locate (name);
 	if (NULL == pw) {
-		fprintf (stderr, _("%s: %s not found in /etc/passwd\n"),
-			 Prog, name);
+		fprintf (stderr,
+		         _("%s: user '%s' does not exist in %s\n"),
+		         Prog, name, pw_dbname ());
 		fail_exit (E_NOPERM);
 	}
 	npw = __pw_dup (pw);
@@ -539,8 +543,10 @@
 		fail_exit (E_FAILURE);
 	}
 	if (pw_close () == 0) {
-		fputs (_("Cannot commit password file changes.\n"), stderr);
-		SYSLOG ((LOG_ERR, "can't rewrite password file"));
+		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 (E_FAILURE);
 	}
 	pw_unlock ();
@@ -552,14 +558,15 @@
 	struct spwd *nsp;
 
 	if (spw_lock () == 0) {
-		fputs (_("Cannot lock the password file; try again later.\n"),
-		       stderr);
-		SYSLOG ((LOG_WARN, "can't lock password file"));
+		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) {
-		fputs (_("Cannot open the password file.\n"), stderr);
-		SYSLOG ((LOG_ERR, "can't open password file"));
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, spw_dbname ());
+		SYSLOG ((LOG_ERR, "cannot open %s", spw_dbname ()));
 		fail_exit (E_FAILURE);
 	}
 	sp = spw_locate (name);
@@ -614,8 +621,10 @@
 		fail_exit (E_FAILURE);
 	}
 	if (spw_close () == 0) {
-		fputs (_("Cannot commit password file changes.\n"), stderr);
-		SYSLOG ((LOG_ERR, "can't rewrite password file"));
+		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 (E_FAILURE);
 	}
 	spw_unlock ();
@@ -809,8 +818,7 @@
 				/* only "files" supported for now */
 				if (strcmp (optarg, "files") != 0) {
 					fprintf (stderr,
-						 _
-						 ("%s: repository %s not supported\n"),
+					         _("%s: repository %s not supported\n"),
 						 Prog, optarg);
 					exit (E_BAD_ARG);
 				}
@@ -920,7 +928,7 @@
 
 	pw = xgetpwnam (name);
 	if (NULL == pw) {
-		fprintf (stderr, _("%s: unknown user %s\n"), Prog, name);
+		fprintf (stderr, _("%s: user '%s' does not exist\n"), Prog, name);
 		exit (E_NOPERM);
 	}
 #ifdef WITH_SELINUX
@@ -949,9 +957,8 @@
 	 */
 	if (!amroot && (pw->pw_uid != getuid ())) {
 		fprintf (stderr,
-			 _
-			 ("%s: You may not view or modify password information for %s.\n"),
-			 Prog, name);
+		         _("%s: You may not view or modify password information for %s.\n"),
+		         Prog, name);
 		SYSLOG ((LOG_WARN,
 			 "%s: can't view or modify password information for %s",
 			 Prog, name));

Modified: upstream/trunk/src/pwck.c
===================================================================
--- upstream/trunk/src/pwck.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/pwck.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -141,12 +141,12 @@
 	 */
 	if (optind != argc) {
 		pwd_file = argv[optind];
-		pw_name (pwd_file);
+		pw_setdbname (pwd_file);
 		use_system_pw_file = false;
 	}
 	if ((optind + 2) == argc) {
 		spw_file = argv[optind + 1];
-		spw_name (spw_file);
+		spw_setdbname (spw_file);
 		is_shadow = true;
 		use_system_spw_file = false;
 	} else if (optind == argc) {
@@ -167,7 +167,7 @@
 	 */
 	if (!read_only) {
 		if (pw_lock () == 0) {
-			fprintf (stderr, _("%s: cannot lock file %s\n"),
+			fprintf (stderr, _("%s: cannot lock %s\n"),
 			         Prog, pwd_file);
 			if (use_system_pw_file) {
 				SYSLOG ((LOG_WARN, "cannot lock %s", pwd_file));
@@ -176,7 +176,7 @@
 			exit (E_CANTLOCK);
 		}
 		if (is_shadow && (spw_lock () == 0)) {
-			fprintf (stderr, _("%s: cannot lock file %s\n"),
+			fprintf (stderr, _("%s: cannot lock %s\n"),
 			         Prog, spw_file);
 			if (use_system_spw_file) {
 				SYSLOG ((LOG_WARN, "cannot lock %s", spw_file));
@@ -191,7 +191,7 @@
 	 * otherwise.
 	 */
 	if (pw_open (read_only ? O_RDONLY : O_RDWR) == 0) {
-		fprintf (stderr, _("%s: cannot open file %s\n"),
+		fprintf (stderr, _("%s: cannot open %s\n"),
 		         Prog, pwd_file);
 		if (use_system_pw_file) {
 			SYSLOG ((LOG_WARN, "cannot open %s", pwd_file));
@@ -200,7 +200,7 @@
 		exit (E_CANTOPEN);
 	}
 	if (is_shadow && (spw_open (read_only ? O_RDONLY : O_RDWR) == 0)) {
-		fprintf (stderr, _("%s: cannot open file %s\n"),
+		fprintf (stderr, _("%s: cannot open %s\n"),
 		         Prog, spw_file);
 		if (use_system_spw_file) {
 			SYSLOG ((LOG_WARN, "cannot open %s", spw_file));
@@ -225,16 +225,16 @@
 	 */
 	if (changed) {
 		if (pw_close () == 0) {
-			fprintf (stderr, _("%s: cannot update file %s\n"),
+			fprintf (stderr, _("%s: failure while writing changes to %s\n"),
 			         Prog, pwd_file);
-			SYSLOG ((LOG_WARN, "cannot update %s", pwd_file));
+			SYSLOG ((LOG_WARN, "failure while writing changes to %s", pwd_file));
 			closelog ();
 			exit (E_CANTUPDATE);
 		}
 		if (is_shadow && (spw_close () == 0)) {
-			fprintf (stderr, _("%s: cannot update file %s\n"),
+			fprintf (stderr, _("%s: failure while writing changes to %s\n"),
 			         Prog, spw_file);
-			SYSLOG ((LOG_WARN, "cannot update %s", spw_file));
+			SYSLOG ((LOG_WARN, "failure while writing changes to %s", spw_file));
 			closelog ();
 			exit (E_CANTUPDATE);
 		}

Modified: upstream/trunk/src/pwconv.c
===================================================================
--- upstream/trunk/src/pwconv.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/pwconv.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -113,22 +113,26 @@
 	(void) textdomain (PACKAGE);
 
 	if (pw_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock passwd file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"), Prog, pw_dbname ());
 		fail_exit (E_PWDBUSY);
 	}
 	passwd_locked = true;
 	if (pw_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open passwd file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"), Prog, pw_dbname ());
 		fail_exit (E_MISSING);
 	}
 
 	if (spw_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock shadow file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"), Prog, spw_dbname ());
 		fail_exit (E_PWDBUSY);
 	}
 	shadow_locked = true;
 	if (spw_open (O_CREAT | O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open shadow file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"), Prog, spw_dbname ());
 		fail_exit (E_FAILURE);
 	}
 
@@ -146,9 +150,8 @@
 			 * This shouldn't happen (the entry exists) but...
 			 */
 			fprintf (stderr,
-				 _
-				 ("%s: can't remove shadow entry for %s\n"),
-				 Prog, sp->sp_namp);
+			         _("%s: cannot remove entry '%s' from %s\n"),
+			         Prog, sp->sp_namp, spw_dbname ());
 			fail_exit (E_FAILURE);
 		}
 	}
@@ -201,11 +204,15 @@
 	}
 
 	if (spw_close () == 0) {
-		fprintf (stderr, _("%s: can't update shadow file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: failure while writing changes to %s\n"),
+		         Prog, spw_dbname ());
 		fail_exit (E_FAILURE);
 	}
 	if (pw_close () == 0) {
-		fprintf (stderr, _("%s: can't update passwd file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: failure while writing changes to %s\n"),
+		         Prog, pw_dbname ());
 		fail_exit (E_FAILURE);
 	}
 	chmod (PASSWD_FILE "-", 0600);	/* /etc/passwd- (backup file) */

Modified: upstream/trunk/src/pwunconv.c
===================================================================
--- upstream/trunk/src/pwunconv.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/pwunconv.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -83,22 +83,30 @@
 	}
 
 	if (pw_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock passwd file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"),
+		         Prog, pw_dbname ());
 		fail_exit (5);
 	}
 	passwd_locked = true;
 	if (pw_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open passwd file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"),
+		         Prog, pw_dbname ());
 		fail_exit (1);
 	}
 
 	if (spw_lock () == 0) {
-		fprintf (stderr, _("%s: can't lock shadow file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"),
+		         Prog, spw_dbname ());
 		fail_exit (5);
 	}
 	shadow_locked = true;
 	if (spw_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: can't open shadow file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"),
+		         Prog, spw_dbname ());
 		fail_exit (1);
 	}
 
@@ -138,18 +146,21 @@
 
 	if (spw_close () == 0) {
 		fprintf (stderr,
-			 _("%s: can't update shadow password file\n"), Prog);
+		         _("%s: failure while writing changes to %s\n"),
+		         Prog, spw_dbname ());
 		fail_exit (3);
 	}
 
 	if (pw_close () == 0) {
-		fprintf (stderr, _("%s: can't update password file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: failure while writing changes to %s\n"),
+		         Prog, pw_dbname ());
 		fail_exit (3);
 	}
 
 	if (unlink (SHADOW) != 0) {
 		fprintf (stderr,
-			 _("%s: can't delete shadow password file\n"), Prog);
+			 _("%s: cannot delete %s\n"), Prog, SHADOW);
 		fail_exit (3);
 	}
 

Modified: upstream/trunk/src/useradd.c
===================================================================
--- upstream/trunk/src/useradd.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/useradd.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -194,21 +194,58 @@
  */
 static void fail_exit (int code)
 {
-	if (home_added)
+	if (home_added) {
 		rmdir (user_home);
+	}
 
 	if (shadow_locked) {
-		spw_unlock ();
+		if (spw_unlock () == 0) {
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", spw_dbname ()));
+#ifdef WITH_AUDIT
+			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+			              "unlocking shadow file",
+			              user_name, AUDIT_NO_ID, 0);
+#endif
+			/* continue */
+		}
 	}
 	if (passwd_locked) {
-		pw_unlock ();
+		if (pw_unlock () == 0) {
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", pw_dbname ()));
+#ifdef WITH_AUDIT
+			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+			              "unlocking passwd file",
+			              user_name, AUDIT_NO_ID, 0);
+#endif
+			/* continue */
+		}
 	}
 	if (group_locked) {
-		gr_unlock ();
+		if (gr_unlock () == 0) {
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+#ifdef WITH_AUDIT
+			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+			              "unlocking group file",
+			              user_name, AUDIT_NO_ID, 0);
+#endif
+			/* continue */
+		}
 	}
 #ifdef	SHADOWGRP
 	if (gshadow_locked) {
-		sgr_unlock ();
+		if (sgr_unlock () == 0) {
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+#ifdef WITH_AUDIT
+			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+			              "unlocking gshadow file",
+			              user_name, AUDIT_NO_ID, 0);
+#endif
+			/* continue */
+		}
 	}
 #endif
 
@@ -318,7 +355,7 @@
 					def_gname = xstrdup (grp->gr_name);
 				} else {
 					fprintf (stderr,
-						 _("%s: unknown GID %s\n"),
+						 _("%s: GID '%s' does not exist\n"),
 						 Prog, cp);
 				}
 			/* local, no need for xgetgrnam */
@@ -327,7 +364,7 @@
 				def_gname = xstrdup (cp);
 			} else {
 				fprintf (stderr,
-					 _("%s: unknown group %s\n"), Prog, cp);
+					 _("%s: group '%s' does not exist\n"), Prog, cp);
 			}
 		}
 
@@ -599,7 +636,7 @@
 		 * string name.
 		 */
 		if (NULL == grp) {
-			fprintf (stderr, _("%s: unknown group %s\n"),
+			fprintf (stderr, _("%s: group '%s' does not exist\n"),
 				 Prog, list);
 			errors++;
 		}
@@ -703,10 +740,11 @@
 {
 	memzero (pwent, sizeof *pwent);
 	pwent->pw_name = (char *) user_name;
-	if (is_shadow_pwd)
+	if (is_shadow_pwd) {
 		pwent->pw_passwd = (char *) SHADOW_PASSWD_STRING;
-	else
+	} else {
 		pwent->pw_passwd = (char *) user_pass;
+	}
 
 	pwent->pw_uid = user_id;
 	pwent->pw_gid = user_gid;
@@ -717,8 +755,9 @@
 
 static long scale_age (long x)
 {
-	if (x <= 0)
+	if (x <= 0) {
 		return x;
+	}
 
 	return x * (DAY / SCALE);
 }
@@ -776,14 +815,15 @@
 	 * Scan through the entire group file looking for the groups that
 	 * the user is a member of.
 	 */
-	for (gr_rewind (), grp = gr_next (); grp; grp = gr_next ()) {
+	for (gr_rewind (), grp = gr_next (); NULL != grp; grp = gr_next ()) {
 
 		/*
 		 * See if the user specified this group as one of their
 		 * concurrent groups.
 		 */
-		if (!is_on_list (user_groups, grp->gr_name))
+		if (!is_on_list (user_groups, grp->gr_name)) {
 			continue;
+		}
 
 		/*
 		 * Make a copy - gr_update() will free() everything
@@ -831,11 +871,13 @@
 		 * See if the user specified this group as one of their
 		 * concurrent groups.
 		 */
-		if (gr_locate (sgrp->sg_name) == NULL)
+		if (gr_locate (sgrp->sg_name) == NULL) {
 			continue;
+		}
 
-		if (!is_on_list (user_groups, sgrp->sg_name))
+		if (!is_on_list (user_groups, sgrp->sg_name)) {
 			continue;
+		}
 
 		/*
 		 * Make a copy - sgr_update() will free() everything
@@ -844,8 +886,8 @@
 		nsgrp = __sgr_dup (sgrp);
 		if (NULL == nsgrp) {
 			fprintf (stderr,
-				 _("%s: Out of memory. Cannot update the shadow group database.\n"),
-				 Prog);
+				 _("%s: Out of memory. Cannot update %s.\n"),
+				 Prog, sgr_dbname ());
 			fail_exit (E_GRP_UPDATE);	/* XXX */
 		}
 
@@ -856,7 +898,7 @@
 		nsgrp->sg_mem = add_list (nsgrp->sg_mem, user_name);
 		if (sgr_update (nsgrp) == 0) {
 			fprintf (stderr,
-				 _("%s: error adding new group entry\n"), Prog);
+				 _("%s: error adding new entry to %s\n"), Prog, sgr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 #ifdef WITH_AUDIT
@@ -915,12 +957,11 @@
 				     long_options, NULL)) != -1) {
 			switch (c) {
 			case 'b':
-				if (!VALID (optarg)
-				    || optarg[0] != '/') {
+				if (   ( !VALID (optarg) )
+				    || ( optarg[0] != '/' )) {
 					fprintf (stderr,
-						 _
-						 ("%s: invalid base directory '%s'\n"),
-						 Prog, optarg);
+					         _("%s: invalid base directory '%s'\n"),
+					         Prog, optarg);
 					exit (E_BAD_ARG);
 				}
 				def_home = optarg;
@@ -929,29 +970,28 @@
 			case 'c':
 				if (!VALID (optarg)) {
 					fprintf (stderr,
-						 _
-						 ("%s: invalid comment '%s'\n"),
-						 Prog, optarg);
+					         _("%s: invalid comment '%s'\n"),
+					         Prog, optarg);
 					exit (E_BAD_ARG);
 				}
 				user_comment = optarg;
 				cflg = true;
 				break;
 			case 'd':
-				if (!VALID (optarg)
-				    || optarg[0] != '/') {
+				if (   ( !VALID (optarg) )
+				    || ( optarg[0] != '/' )) {
 					fprintf (stderr,
-						 _
-						 ("%s: invalid home directory '%s'\n"),
-						 Prog, optarg);
+					         _("%s: invalid home directory '%s'\n"),
+					         Prog, optarg);
 					exit (E_BAD_ARG);
 				}
 				user_home = optarg;
 				dflg = true;
 				break;
 			case 'D':
-				if (anyflag)
+				if (anyflag) {
 					usage ();
+				}
 				Dflg = true;
 				break;
 			case 'e':
@@ -959,26 +999,26 @@
 					user_expire = strtoday (optarg);
 					if (user_expire == -1) {
 						fprintf (stderr,
-							 _
-							 ("%s: invalid date '%s'\n"),
-							 Prog, optarg);
+						         _("%s: invalid date '%s'\n"),
+						         Prog, optarg);
 						exit (E_BAD_ARG);
 					}
-				} else
+				} else {
 					user_expire = -1;
+				}
 
 				/*
 				 * -e "" is allowed - it's a no-op without /etc/shadow
 				 */
 				if (('\0' != *optarg) && !is_shadow_pwd) {
 					fprintf (stderr,
-						 _
-						 ("%s: shadow passwords required for -e\n"),
-						 Prog);
+					         _("%s: shadow passwords required for -e\n"),
+					         Prog);
 					exit (E_USAGE);
 				}
-				if (Dflg)
+				if (Dflg) {
 					def_expire = optarg;
+				}
 				eflg = true;
 				break;
 			case 'f':
@@ -1037,16 +1077,16 @@
 				cp = strchr (optarg, '=');
 				if (NULL == cp) {
 					fprintf (stderr,
-						 _
-						 ("%s: -K requires KEY=VALUE\n"),
-						 Prog);
+					         _("%s: -K requires KEY=VALUE\n"),
+					         Prog);
 					exit (E_BAD_ARG);
 				}
 				/* terminate name, point to value */
 				*cp = '\0';
 				cp++;
-				if (putdef_str (optarg, cp) < 0)
+				if (putdef_str (optarg, cp) < 0) {
 					exit (E_BAD_ARG);
+				}
 				break;
 			case 'l':
 				lflg = true;
@@ -1063,9 +1103,8 @@
 			case 'p':	/* set encrypted password */
 				if (!VALID (optarg)) {
 					fprintf (stderr,
-						 _
-						 ("%s: invalid field '%s'\n"),
-						 Prog, optarg);
+					         _("%s: invalid field '%s'\n"),
+					         Prog, optarg);
 					exit (E_BAD_ARG);
 				}
 				user_pass = optarg;
@@ -1074,14 +1113,13 @@
 				rflg = true;
 				break;
 			case 's':
-				if (!VALID (optarg)
+				if (   ( !VALID (optarg) )
 				    || (   ('\0' != optarg[0])
 				        && ('/'  != optarg[0])
-				        && ('*'  != optarg[0]))) {
+				        && ('*'  != optarg[0]) )) {
 					fprintf (stderr,
-						 _
-						 ("%s: invalid shell '%s'\n"),
-						 Prog, optarg);
+					         _("%s: invalid shell '%s'\n"),
+					         Prog, optarg);
 					exit (E_BAD_ARG);
 				}
 				user_shell = optarg;
@@ -1113,13 +1151,13 @@
 	 */
 	if (oflg && !uflg) {
 		fprintf (stderr,
-		         _("%s: %s flag is ONLY allowed with the %s flag\n"),
+		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-o", "-u");
 		usage ();
 	}
 	if (kflg && !mflg) {
 		fprintf (stderr,
-		         _("%s: %s flag is ONLY allowed with the %s flag\n"),
+		         _("%s: %s flag is only allowed with the %s flag\n"),
 		         Prog, "-k", "-m");
 		usage ();
 	}
@@ -1141,21 +1179,23 @@
 	 * for the -b, -e, -f, -g, -s options only.
 	 */
 	if (Dflg) {
-		if (optind != argc)
+		if (optind != argc) {
 			usage ();
+		}
 
-		if (uflg || oflg || Gflg || dflg || cflg || mflg)
+		if (uflg || oflg || Gflg || dflg || cflg || mflg) {
 			usage ();
+		}
 	} else {
-		if (optind != argc - 1)
+		if (optind != argc - 1) {
 			usage ();
+		}
 
 		user_name = argv[optind];
 		if (!is_valid_user_name (user_name)) {
 			fprintf (stderr,
-				 _
-				 ("%s: invalid user name '%s'\n"),
-				 Prog, user_name);
+			         _("%s: invalid user name '%s'\n"),
+			         Prog, user_name);
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 			              "adding user",
@@ -1173,14 +1213,17 @@
 		}
 	}
 
-	if (!eflg)
+	if (!eflg) {
 		user_expire = strtoday (def_expire);
+	}
 
-	if (!gflg)
+	if (!gflg) {
 		user_gid = def_group;
+	}
 
-	if (!sflg)
+	if (!sflg) {
 		user_shell = def_shell;
+	}
 
 	/* TODO: add handle change default spool mail creation by 
 	   -K CREATE_MAIL_SPOOL={yes,no}. It need rewrite internal API for handle
@@ -1197,41 +1240,80 @@
 static void close_files (void)
 {
 	if (pw_close () == 0) {
-		fprintf (stderr, _("%s: cannot rewrite password file\n"), Prog);
+		fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
+		SYSLOG ((LOG_WARN, "failure while writing changes to %s", pw_dbname ()));
 		fail_exit (E_PW_UPDATE);
 	}
 	if (is_shadow_pwd && (spw_close () == 0)) {
 		fprintf (stderr,
-			 _("%s: cannot rewrite shadow password file\n"), Prog);
+		         _("%s: failure while writing changes to %s\n"), Prog, spw_dbname ());
+		SYSLOG ((LOG_WARN, "failure while writing changes to %s", spw_dbname ()));
 		fail_exit (E_PW_UPDATE);
 	}
 	if (do_grp_update) {
 		if (gr_close () == 0) {
 			fprintf (stderr,
-				 _("%s: cannot rewrite group file\n"), Prog);
+			         _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
+			SYSLOG ((LOG_WARN, "failure while writing changes to %s", gr_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 #ifdef	SHADOWGRP
 		if (is_shadow_grp && (sgr_close () == 0)) {
 			fprintf (stderr,
-				 _
-				 ("%s: cannot rewrite shadow group file\n"),
-				 Prog);
+			         _("%s: failure while writing changes to %s\n"),
+			         Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failure while writing changes to %s", sgr_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 #endif
 	}
 	if (is_shadow_pwd) {
-		spw_unlock ();
+		if (spw_unlock () == 0) {
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", spw_dbname ()));
+#ifdef WITH_AUDIT
+			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+			              "unlocking shadow file",
+			              user_name, AUDIT_NO_ID, 0);
+#endif
+			/* continue */
+		}
 		shadow_locked = false;
 	}
-	pw_unlock ();
+	if (pw_unlock () == 0) {
+		fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
+		SYSLOG ((LOG_WARN, "failed to unlock %s", pw_dbname ()));
+#ifdef WITH_AUDIT
+		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+		              "unlocking passwd file",
+		              user_name, AUDIT_NO_ID, 0);
+#endif
+		/* continue */
+	}
 	passwd_locked = false;
-	gr_unlock ();
+	if (gr_unlock () == 0) {
+		fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, gr_dbname ());
+		SYSLOG ((LOG_WARN, "failed to unlock %s", gr_dbname ()));
+#ifdef WITH_AUDIT
+		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+		              "unlocking group file",
+		              user_name, AUDIT_NO_ID, 0);
+#endif
+		/* continue */
+	}
 	group_locked = false;
 #ifdef	SHADOWGRP
 	if (is_shadow_grp) {
-		sgr_unlock ();
+		if (sgr_unlock () == 0) {
+			fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ());
+			SYSLOG ((LOG_WARN, "failed to unlock %s", sgr_dbname ()));
+#ifdef WITH_AUDIT
+			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+			              "unlocking gshadow file",
+			              user_name, AUDIT_NO_ID, 0);
+#endif
+			/* continue */
+		}
 		gshadow_locked = false;
 	}
 #endif
@@ -1245,46 +1327,26 @@
 static void open_files (void)
 {
 	if (pw_lock () == 0) {
-		fprintf (stderr, _("%s: unable to lock password file\n"), Prog);
-#ifdef WITH_AUDIT
-		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-		              "locking password file",
-		              user_name, (unsigned int) user_id, 0);
-#endif
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, pw_dbname ());
 		exit (E_PW_UPDATE);
 	}
 	passwd_locked = true;
 	if (pw_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: unable to open password file\n"), Prog);
-#ifdef WITH_AUDIT
-		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-		              "opening password file",
-		              user_name, (unsigned int) user_id, 0);
-#endif
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ());
 		fail_exit (E_PW_UPDATE);
 	}
 	if (is_shadow_pwd) {
 		if (spw_lock () == 0) {
 			fprintf (stderr,
-			         _("%s: cannot lock shadow password file\n"),
-			         Prog);
-#ifdef WITH_AUDIT
-			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			              "locking shadow password file",
-			              user_name, (unsigned int) user_id, 0);
-#endif
+			         _("%s: cannot lock %s\n"),
+			         Prog, spw_dbname ());
 			fail_exit (E_PW_UPDATE);
 		}
 		shadow_locked = true;
 		if (spw_open (O_RDWR) == 0) {
 			fprintf (stderr,
-			         _("%s: cannot open shadow password file\n"),
-			         Prog);
-#ifdef WITH_AUDIT
-			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			              "opening shadow password file",
-			              user_name, (unsigned int) user_id, 0);
-#endif
+			         _("%s: cannot open %s\n"),
+			         Prog, spw_dbname ());
 			fail_exit (E_PW_UPDATE);
 		}
 	}
@@ -1293,27 +1355,27 @@
 	 * Lock and open the group file.
 	 */
 	if (gr_lock () == 0) {
-		fprintf (stderr, _("%s: error locking group file\n"), Prog);
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ());
 		fail_exit (E_GRP_UPDATE);
 	}
 	group_locked = true;
 	if (gr_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: error opening group file\n"), Prog);
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
 		fail_exit (E_GRP_UPDATE);
 	}
 #ifdef  SHADOWGRP
 	if (is_shadow_grp) {
 		if (sgr_lock () == 0) {
 			fprintf (stderr,
-			         _("%s: error locking shadow group file\n"),
-			         Prog);
+			         _("%s: cannot lock %s\n"),
+			         Prog, sgr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 		gshadow_locked = true;
 		if (sgr_open (O_RDWR) == 0) {
 			fprintf (stderr,
-			         _("%s: error opening shadow group file\n"),
-			         Prog);
+			         _("%s: cannot open %s\n"),
+			         Prog, sgr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 	}
@@ -1419,6 +1481,8 @@
 		fprintf (stderr,
 		         _("%s: failed to reset the faillog entry of UID %lu: %s\n"),
 		         Prog, (unsigned long) uid, strerror (errno));
+		SYSLOG ((LOG_WARN, "failed to reset the faillog entry of UID %lu", (unsigned long) uid));
+		/* continue */
 	}
 }
 
@@ -1442,6 +1506,8 @@
 		fprintf (stderr,
 		         _("%s: failed to reset the lastlog entry of UID %lu: %s\n"),
 		         Prog, (unsigned long) uid, strerror (errno));
+		SYSLOG ((LOG_WARN, "failed to reset the lastlog entry of UID %lu", (unsigned long) uid));
+		/* continue */
 	}
 }
 
@@ -1665,19 +1731,14 @@
 
 	if (PAM_SUCCESS == retval) {
 		retval = pam_authenticate (pamh, 0);
-		if (PAM_SUCCESS != retval) {
-			(void) pam_end (pamh, retval);
-		}
 	}
 
 	if (PAM_SUCCESS == retval) {
 		retval = pam_acct_mgmt (pamh, 0);
-		if (PAM_SUCCESS != retval) {
-			(void) pam_end (pamh, retval);
-		}
 	}
 
 	if (PAM_SUCCESS != retval) {
+		(void) pam_end (pamh, retval);
 		fprintf (stderr, _("%s: PAM authentication failed\n"), Prog);
 		fail_exit (1);
 	}
@@ -1700,7 +1761,7 @@
 	 * Start with a quick check to see if the user exists.
 	 */
 	if (getpwnam (user_name) != NULL) { /* local, no need for xgetpwnam */
-		fprintf (stderr, _("%s: user %s exists\n"), Prog, user_name);
+		fprintf (stderr, _("%s: user '%s' already exists\n"), Prog, user_name);
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "adding user",
@@ -1719,8 +1780,7 @@
 		/* local, no need for xgetgrnam */
 		if (getgrnam (user_name) != NULL) {
 			fprintf (stderr,
-				 _
-				 ("%s: group %s exists - if you want to add this user to that group, use -g.\n"),
+				 _("%s: group %s exists - if you want to add this user to that group, use -g.\n"),
 				 Prog, user_name);
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
@@ -1818,9 +1878,7 @@
 	nscd_flush_cache ("group");
 
 #ifdef USE_PAM
-	if (PAM_SUCCESS == retval) {
-		(void) pam_end (pamh, PAM_SUCCESS);
-	}
+	(void) pam_end (pamh, PAM_SUCCESS);
 #endif				/* USE_PAM */
 
 	return E_SUCCESS;

Modified: upstream/trunk/src/userdel.c
===================================================================
--- upstream/trunk/src/userdel.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/userdel.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -146,8 +146,9 @@
 		 * See if the user specified this group as one of their
 		 * concurrent groups.
 		 */
-		if (!is_on_list (grp->gr_mem, user_name))
+		if (!is_on_list (grp->gr_mem, user_name)) {
 			continue;
+		}
 
 		/* 
 		 * Delete the username from the list of group members and
@@ -156,8 +157,8 @@
 		ngrp = __gr_dup (grp);
 		if (NULL == ngrp) {
 			fprintf (stderr,
-				 _("%s: Out of memory. Cannot update the group database.\n"),
-				 Prog);
+			         _("%s: Out of memory. Cannot update %s.\n"),
+			         Prog, gr_dbname ());
 			exit (13);	/* XXX */
 		}
 		ngrp->gr_mem = del_list (ngrp->gr_mem, user_name);
@@ -202,9 +203,8 @@
 				}
 				if (pwd->pw_gid == grp->gr_gid) {
 					fprintf (stderr,
-						 _
-						 ("%s: Cannot remove group %s which is a primary group for another user.\n"),
-						 Prog, grp->gr_name);
+					         _("%s: Cannot remove group %s which is a primary group for another user.\n"),
+					         Prog, grp->gr_name);
 					break;
 				}
 			}
@@ -261,8 +261,8 @@
 		nsgrp = __sgr_dup (sgrp);
 		if (NULL == nsgrp) {
 			fprintf (stderr,
-				 _("%s: Out of memory. Cannot update the shadow group database.\n"),
-				 Prog);
+			         _("%s: Out of memory. Cannot update %s.\n"),
+			         Prog, sgr_dbname ());
 			exit (13);	/* XXX */
 		}
 
@@ -288,8 +288,9 @@
 			 user_name, nsgrp->sg_name));
 	}
 
-	if (deleted_user_group)
+	if (deleted_user_group) {
 		sgr_remove (user_name);
+	}
 #endif				/* SHADOWGRP */
 }
 
@@ -301,19 +302,23 @@
  */
 static void close_files (void)
 {
-	if (pw_close () == 0)
-		fprintf (stderr, _("%s: cannot rewrite password file\n"), Prog);
-	if (is_shadow_pwd && (spw_close () == 0))
+	if (pw_close () == 0) {
+		fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
+	}
+	if (is_shadow_pwd && (spw_close () == 0)) {
 		fprintf (stderr,
-			 _("%s: cannot rewrite shadow password file\n"), Prog);
-	if (gr_close () == 0)
-		fprintf (stderr, _("%s: cannot rewrite group file\n"), Prog);
+		         _("%s: failure while writing changes to %s\n"), Prog, spw_dbname ());
+	}
+	if (gr_close () == 0) {
+		fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, gr_dbname ());
+	}
 
 	gr_unlock ();
 #ifdef	SHADOWGRP
-	if (is_shadow_grp && (sgr_close () == 0))
+	if (is_shadow_grp && (sgr_close () == 0)) {
 		fprintf (stderr,
-			 _("%s: cannot rewrite shadow group file\n"), Prog);
+		         _("%s: failure while writing changes to %s\n"), Prog, sgr_dbname ());
+	}
 
 	if (is_shadow_grp) {
 		sgr_unlock ();
@@ -357,7 +362,7 @@
 static void open_files (void)
 {
 	if (pw_lock () == 0) {
-		fprintf (stderr, _("%s: unable to lock password file\n"), Prog);
+		fprintf (stderr, _("%s: cannot lock %s\n"), Prog, pw_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "locking password file",
@@ -366,7 +371,8 @@
 		exit (E_PW_UPDATE);
 	}
 	if (pw_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: unable to open password file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"), Prog, pw_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "opening password file",
@@ -376,7 +382,7 @@
 	}
 	if (is_shadow_pwd && (spw_lock () == 0)) {
 		fprintf (stderr,
-			 _("%s: cannot lock shadow password file\n"), Prog);
+		         _("%s: cannot lock %s\n"), Prog, spw_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "locking shadow password file",
@@ -386,7 +392,7 @@
 	}
 	if (is_shadow_pwd && (spw_open (O_RDWR) == 0)) {
 		fprintf (stderr,
-			 _("%s: cannot open shadow password file\n"), Prog);
+		         _("%s: cannot open %s\n"), Prog, spw_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "opening shadow password file",
@@ -395,7 +401,8 @@
 		fail_exit (E_PW_UPDATE);
 	}
 	if (gr_lock () == 0) {
-		fprintf (stderr, _("%s: unable to lock group file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"), Prog, gr_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "locking group file",
@@ -404,7 +411,7 @@
 		fail_exit (E_GRP_UPDATE);
 	}
 	if (gr_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: cannot open group file\n"), Prog);
+		fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "opening group file",
@@ -415,7 +422,7 @@
 #ifdef	SHADOWGRP
 	if (is_shadow_grp && (sgr_lock () == 0)) {
 		fprintf (stderr,
-			 _("%s: unable to lock shadow group file\n"), Prog);
+		         _("%s: cannot lock %s\n"), Prog, sgr_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "locking shadow group file",
@@ -424,8 +431,8 @@
 		fail_exit (E_GRP_UPDATE);
 	}
 	if (is_shadow_grp && (sgr_open (O_RDWR) == 0)) {
-		fprintf (stderr, _("%s: cannot open shadow group file\n"),
-			 Prog);
+		fprintf (stderr, _("%s: cannot open %s\n"),
+		         Prog, sgr_dbname ());
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
 		              "opening shadow group file",
@@ -446,12 +453,14 @@
 {
 	if (pw_remove (user_name) == 0) {
 		fprintf (stderr,
-			 _("%s: error deleting password entry\n"), Prog);
+		         _("%s: cannot remove entry '%s' from %s\n"),
+		         Prog, user_name, pw_dbname ());
 		fail_exit (E_PW_UPDATE);
 	}
 	if (is_shadow_pwd && (spw_remove (user_name) == 0)) {
 		fprintf (stderr,
-			 _("%s: error deleting shadow password entry\n"), Prog);
+		         _("%s: cannot remove entry '%s' from %s\n"),
+		         Prog, user_name, spw_dbname ());
 		fail_exit (E_PW_UPDATE);
 	}
 #ifdef WITH_AUDIT
@@ -709,21 +718,16 @@
 		}
 	}
 
-	if (retval == PAM_SUCCESS) {
+	if (PAM_SUCCESS == retval) {
 		retval = pam_authenticate (pamh, 0);
-		if (retval != PAM_SUCCESS) {
-			(void) pam_end (pamh, retval);
-		}
 	}
 
-	if (retval == PAM_SUCCESS) {
+	if (PAM_SUCCESS == retval) {
 		retval = pam_acct_mgmt (pamh, 0);
-		if (retval != PAM_SUCCESS) {
-			(void) pam_end (pamh, retval);
-		}
 	}
 
-	if (retval != PAM_SUCCESS) {
+	if (PAM_SUCCESS != retval) {
+		(void) pam_end (pamh, retval);
 		fprintf (stderr, _("%s: PAM authentication failed\n"), Prog);
 		exit (E_PW_UPDATE);
 	}
@@ -858,9 +862,7 @@
 	nscd_flush_cache ("group");
 
 #ifdef USE_PAM
-	if (retval == PAM_SUCCESS) {
-		(void) pam_end (pamh, PAM_SUCCESS);
-	}
+	(void) pam_end (pamh, PAM_SUCCESS);
 #endif				/* USE_PAM */
 #ifdef WITH_AUDIT
 	if (0 != errors) {

Modified: upstream/trunk/src/usermod.c
===================================================================
--- upstream/trunk/src/usermod.c	2008-08-06 15:56:51 UTC (rev 2242)
+++ upstream/trunk/src/usermod.c	2008-08-06 15:57:31 UTC (rev 2243)
@@ -279,9 +279,8 @@
 
 		if (ngroups == sys_ngroups) {
 			fprintf (stderr,
-				 _
-				 ("%s: too many groups specified (max %d).\n"),
-				 Prog, ngroups);
+			         _("%s: too many groups specified (max %d).\n"),
+			         Prog, ngroups);
 			break;
 		}
 
@@ -358,8 +357,8 @@
 
 		if (pw_pass[1] == '\0') {
 			fprintf (stderr,
-				 _("%s: unlocking the user would result in a passwordless account.\n"
-				   "You should set a password with usermod -p to unlock this user account.\n"),
+				 _("%s: unlocking the user's password would result in a passwordless account.\n"
+				   "You should set a password with usermod -p to unlock this user's password.\n"),
 				 Prog);
 			return pw_pass;
 		}
@@ -569,8 +568,8 @@
 		ngrp = __gr_dup (grp);
 		if (NULL == ngrp) {
 			fprintf (stderr,
-				 _("%s: Out of memory. Cannot update the group database.\n"),
-				 Prog);
+			         _("%s: Out of memory. Cannot update %s.\n"),
+			         Prog, gr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 
@@ -619,8 +618,9 @@
 		changed = false;
 		if (gr_update (ngrp) == 0) {
 			fprintf (stderr,
-				 _("%s: error adding new group entry\n"), Prog);
-			SYSLOG ((LOG_ERR, "error adding new group entry"));
+			         _("%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 ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 	}
@@ -669,8 +669,8 @@
 		nsgrp = __sgr_dup (sgrp);
 		if (NULL == nsgrp) {
 			fprintf (stderr,
-				 _("%s: Out of memory. Cannot update the shadow group database.\n"),
-				 Prog);
+			         _("%s: Out of memory. Cannot update %s.\n"),
+			         Prog, sgr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 
@@ -737,8 +737,10 @@
 		 */
 		if (sgr_update (nsgrp) == 0) {
 			fprintf (stderr,
-				 _("%s: error adding new shadow group entry\n"), Prog);
-			SYSLOG ((LOG_ERR, "error adding shadow group entry"));
+			         _("%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",
+			        nsgrp->sg_name, sgr_dbname ()));
 			fail_exit (E_GRP_UPDATE);
 		}
 	}
@@ -1048,7 +1050,7 @@
 
 	if (aflg && (!Gflg)) {
 		fprintf (stderr,
-			 _("%s: %s flag is ONLY allowed with the %s flag\n"),
+			 _("%s: %s flag is only allowed with the %s flag\n"),
 			 Prog, "-a", "-G");
 		usage ();
 		exit (E_USAGE);
@@ -1064,7 +1066,7 @@
 
 	if (oflg && !uflg) {
 		fprintf (stderr,
-			 _("%s: %s flag is ONLY allowed with the %s flag\n"),
+			 _("%s: %s flag is only allowed with the %s flag\n"),
 			 Prog, "-o", "-u");
 		usage ();
 		exit (E_USAGE);
@@ -1072,7 +1074,7 @@
 
 	if (mflg && !dflg) {
 		fprintf (stderr,
-			 _("%s: %s flag is ONLY allowed with the %s flag\n"),
+			 _("%s: %s flag is only allowed with the %s flag\n"),
 			 Prog, "-m", "-d");
 		usage ();
 		exit (E_USAGE);
@@ -1080,13 +1082,13 @@
 
 	/* local, no need for xgetpwnam */
 	if (lflg && (getpwnam (user_newname) != NULL)) {
-		fprintf (stderr, _("%s: user %s exists\n"), Prog, user_newname);
+		fprintf (stderr, _("%s: user '%s' already exists\n"), Prog, user_newname);
 		exit (E_NAME_IN_USE);
 	}
 
 	/* local, no need for xgetpwuid */
 	if (uflg && !oflg && (getpwuid (user_newid) != NULL)) {
-		fprintf (stderr, _("%s: uid %lu is not unique\n"),
+		fprintf (stderr, _("%s: UID '%lu' already exists\n"),
 			 Prog, (unsigned long) user_newid);
 		exit (E_UID_IN_USE);
 	}
@@ -1101,26 +1103,28 @@
 static void close_files (void)
 {
 	if (pw_close () == 0) {
-		fprintf (stderr, _("%s: cannot rewrite password file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
 		fail_exit (E_PW_UPDATE);
 	}
 	if (is_shadow_pwd && (spw_close () == 0)) {
 		fprintf (stderr,
-			 _("%s: cannot rewrite shadow password file\n"), Prog);
+		         _("%s: failure while writing changes to %s\n"), Prog, spw_dbname ());
 		fail_exit (E_PW_UPDATE);
 	}
 
 	if (Gflg || lflg) {
 		if (gr_close () == 0) {
-			fprintf (stderr, _("%s: cannot rewrite group file\n"),
-				 Prog);
+			fprintf (stderr,
+			         _("%s: failure while writing changes to %s\n"),
+			         Prog, gr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 #ifdef SHADOWGRP
 		if (is_shadow_grp && (sgr_close () == 0)) {
 			fprintf (stderr,
-				 _("%s: cannot rewrite shadow group file\n"),
-				 Prog);
+			         _("%s: failure while writing changes to %s\n"),
+			         Prog, sgr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 		if (is_shadow_grp) {
@@ -1161,23 +1165,25 @@
 static void open_files (void)
 {
 	if (pw_lock () == 0) {
-		fprintf (stderr, _("%s: unable to lock password file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot lock %s\n"), Prog, pw_dbname ());
 		fail_exit (E_PW_UPDATE);
 	}
 	pw_locked = true;
 	if (pw_open (O_RDWR) == 0) {
-		fprintf (stderr, _("%s: unable to open password file\n"), Prog);
+		fprintf (stderr,
+		         _("%s: cannot open %s\n"), Prog, pw_dbname ());
 		fail_exit (E_PW_UPDATE);
 	}
 	if (is_shadow_pwd && (spw_lock () == 0)) {
 		fprintf (stderr,
-			 _("%s: cannot lock shadow password file\n"), Prog);
+		         _("%s: cannot lock %s\n"), Prog, spw_dbname ());
 		fail_exit (E_PW_UPDATE);
 	}
 	spw_locked = true;
 	if (is_shadow_pwd && (spw_open (O_RDWR) == 0)) {
 		fprintf (stderr,
-			 _("%s: cannot open shadow password file\n"), Prog);
+		         _("%s: cannot open %s\n"), Prog, spw_dbname ());
 		fail_exit (E_PW_UPDATE);
 	}
 
@@ -1187,28 +1193,26 @@
 		 * group entries.
 		 */
 		if (gr_lock () == 0) {
-			fprintf (stderr, _("%s: error locking group file\n"),
-				 Prog);
+			fprintf (stderr,
+			         _("%s: cannot lock %s\n"), Prog, gr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 		gr_locked = true;
 		if (gr_open (O_RDWR) == 0) {
-			fprintf (stderr, _("%s: error opening group file\n"),
-				 Prog);
+			fprintf (stderr,
+			         _("%s: cannot open %s\n"), Prog, gr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 #ifdef SHADOWGRP
 		if (is_shadow_grp && (sgr_lock () == 0)) {
 			fprintf (stderr,
-				 _("%s: error locking shadow group file\n"),
-				 Prog);
+			         _("%s: cannot lock %s\n"), Prog, sgr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 		sgr_locked = true;
 		if (is_shadow_grp && (sgr_open (O_RDWR) == 0)) {
 			fprintf (stderr,
-				 _("%s: error opening shadow group file\n"),
-				 Prog);
+			         _("%s: cannot open %s\n"), Prog, sgr_dbname ());
 			fail_exit (E_GRP_UPDATE);
 		}
 #endif
@@ -1234,8 +1238,8 @@
 	 */
 	pwd = pw_locate (user_name);
 	if (NULL == pwd) {
-		fprintf (stderr, _("%s: %s not found in /etc/passwd\n"),
-			 Prog, user_name);
+		fprintf (stderr, _("%s: user '%s' does not exist in %s\n"),
+		         Prog, user_name, pw_dbname ());
 		fail_exit (E_NOTFOUND);
 	}
 	pwent = *pwd;
@@ -1255,30 +1259,28 @@
 	    || Lflg || Uflg) {
 		if (pw_update (&pwent) == 0) {
 			fprintf (stderr,
-				 _("%s: error changing password entry\n"),
-				 Prog);
+			         _("%s: cannot add new entry '%s' in %s\n"),
+			         Prog, pwent.pw_name, pw_dbname ());
 			fail_exit (E_PW_UPDATE);
 		}
 		if (lflg && (pw_remove (user_name) == 0)) {
 			fprintf (stderr,
-				 _("%s: error removing password entry\n"),
-				 Prog);
+			         _("%s: cannot remove entry '%s' from %s\n"),
+			         Prog, user_name, pw_dbname ());
 			fail_exit (E_PW_UPDATE);
 		}
 	}
 	if ((NULL != spwd) && (lflg || eflg || fflg || pflg || Lflg || Uflg)) {
 		if (spw_update (&spent) == 0) {
 			fprintf (stderr,
-				 _
-				 ("%s: error adding new shadow password entry\n"),
-				 Prog);
+			         _("%s: cannot add new entry '%s' in %s\n"),
+			         Prog, spent.sp_namp, spw_dbname ());
 			fail_exit (E_PW_UPDATE);
 		}
 		if (lflg && (spw_remove (user_name) == 0)) {
 			fprintf (stderr,
-				 _
-				 ("%s: error removing shadow password entry\n"),
-				 Prog);
+			         _("%s: cannot remove entry '%s' from %s\n"),
+			         Prog, user_name, spw_dbname ());
 			fail_exit (E_PW_UPDATE);
 		}
 	}
@@ -1311,9 +1313,8 @@
 			if (errno == EXDEV) {
 				if (mkdir (user_newhome, sb.st_mode & 0777) != 0) {
 					fprintf (stderr,
-						 _
-						 ("%s: can't create %s\n"),
-						 Prog, user_newhome);
+					         _("%s: can't create %s\n"),
+					         Prog, user_newhome);
 				}
 				if (chown (user_newhome, sb.st_uid, sb.st_gid) != 0) {
 					fprintf (stderr,
@@ -1347,9 +1348,8 @@
 				(void) remove_tree (user_newhome);
 			}
 			fprintf (stderr,
-				 _
-				 ("%s: cannot rename directory %s to %s\n"),
-				 Prog, user_home, user_newhome);
+			         _("%s: cannot rename directory %s to %s\n"),
+			         Prog, user_home, user_newhome);
 			fail_exit (E_HOMEDIR);
 		}
 #ifdef WITH_AUDIT
@@ -1523,8 +1523,9 @@
 	fd = open (mailfile, O_RDONLY | O_NONBLOCK, 0);
 	if (fd < 0) {
 		/* no need for warnings if the mailbox doesn't exist */
-		if (errno != ENOENT)
+		if (errno != ENOENT) {
 			perror (mailfile);
+		}
 		return;
 	}
 	if (fstat (fd, &st) < 0) {
@@ -1626,19 +1627,14 @@
 
 	if (PAM_SUCCESS == retval) {
 		retval = pam_authenticate (pamh, 0);
-		if (PAM_SUCCESS != retval) {
-			(void) pam_end (pamh, retval);
-		}
 	}
 
 	if (PAM_SUCCESS == retval) {
 		retval = pam_acct_mgmt (pamh, 0);
-		if (PAM_SUCCESS != retval) {
-			(void) pam_end (pamh, retval);
-		}
 	}
 
 	if (PAM_SUCCESS != retval) {
+		(void) pam_end (pamh, retval);
 		fprintf (stderr, _("%s: PAM authentication failed\n"), Prog);
 		exit (1);
 	}
@@ -1685,9 +1681,7 @@
 	}
 
 #ifdef USE_PAM
-	if (PAM_SUCCESS == retval) {
-		(void) pam_end (pamh, PAM_SUCCESS);
-	}
+	(void) pam_end (pamh, PAM_SUCCESS);
 #endif				/* USE_PAM */
 
 	exit (E_SUCCESS);




More information about the Pkg-shadow-commits mailing list