+2008-08-25 Nicolas François <nicolas.francois@centraliens.net>
+
+ * src/groupmems.c: Check the return value of gr_update().
+ * src/chage.c, src/chfn.c, src/chgpasswd.c, src/chpasswd.c,
+ src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupmems.c,
+ src/groupmod.c, src/grpck.c, src/grpconv.c, src/grpunconv.c,
+ src/passwd.c, src/pwck.c, src/pwconv.c, src/pwunconv.c,
+ src/useradd.c, src/userdel.c, src/usermod.c: Harmonize the error
+ message sent to stderr in case of *_update () failure.
+ * src/chage.c, src/chsh.c, src/groupadd.c, src/passwd.c: Do not
+ log to syslog when pw_update() or spw_update() fail.
+ * src/newusers.c: Do not log specific error message to stderr when
+ sgr_update() fails.
+ * src/pwconv.c: Remove duplicated definition of Prog.
+
2008-08-25 Nicolas François <nicolas.francois@centraliens.net>
* src/chfn.c, src/chsh.c, src/expiry.c, src/gpasswd.c,
pwent.pw_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
if (pw_update (&pwent) == 0) {
fprintf (stderr,
- _("%s: cannot update %s\n"), Prog, pw_dbname ());
- SYSLOG ((LOG_WARN, "cannot update %s", pw_dbname ()));
+ _("%s: failed to prepare the new %s entry '%s'\n"), Prog, pw_dbname (), pwent.pw_name);
fail_exit (E_NOPERM);
}
} else {
if (spw_update (&spwent) == 0) {
fprintf (stderr,
- _("%s: cannot update %s\n"), Prog, spw_dbname ());
- SYSLOG ((LOG_WARN, "cannot update %s", spw_dbname ()));
+ _("%s: failed to prepare the new %s entry '%s'\n"), Prog, spw_dbname (), spwent.sp_namp);
fail_exit (E_NOPERM);
}
* entry as well.
*/
if (pw_update (&pwent) == 0) {
- fputs (_("Error updating the password entry.\n"), stderr);
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry\n"),
+ Prog, pw_dbname ());
fail_exit (E_NOPERM);
}
*/
#ifdef SHADOWGRP
if (NULL != sg) {
- ok = sgr_update (&newsg);
+ if (sgr_update (&newsg) == 0) {
+ fprintf (stderr,
+ _("%s: line %d: failed to prepare the new %s entry '%s'\n"),
+ Prog, line, sgr_dbname (), newsg.sg_name);
+ errors++;
+ continue;
+ }
} else
#endif
{
- ok = gr_update (&newgr);
- }
-
- if (0 == ok) {
- fprintf (stderr,
- _("%s: line %d: cannot update group entry\n"),
- Prog, line);
- errors++;
- continue;
+ if (gr_update (&newgr) == 0) {
+ fprintf (stderr,
+ _("%s: line %d: failed to prepare the new %s entry '%s'\n"),
+ Prog, line, gr_dbname (), newgr.gr_name);
+ errors++;
+ continue;
+ }
}
}
* other entries have been updated as well.
*/
if (NULL != sp) {
- ok = spw_update (&newsp);
+ if (spw_update (&newsp) == 0) {
+ fprintf (stderr,
+ _("%s: line %d: failed to prepare the new %s entry\n"),
+ Prog, line, spw_dbname ());
+ errors++;
+ continue;
+ }
} else {
- ok = pw_update (&newpw);
- }
-
- if (0 == ok) {
- fprintf (stderr,
- _("%s: line %d: cannot update password entry\n"),
- Prog, line);
- errors++;
- continue;
+ if (pw_update (&newsp) == 0) {
+ fprintf (stderr,
+ _("%s: line %d: failed to prepare the new %s entry\n"),
+ Prog, line, pw_dbname ());
+ errors++;
+ continue;
+ }
}
}
* that entry as well.
*/
if (pw_update (&pwent) == 0) {
- SYSLOG ((LOG_WARN, "error updating passwd entry"));
- fputs (_("Error updating the password entry.\n"), stderr);
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry\n"), Prog, pw_dbname ());
fail_exit (1);
}
{
if (gr_update (gr) == 0) {
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 ()));
+ _("%s: failed to prepare the new %s entry\n"), Prog, gr_dbname ());
+ SYSLOG ((LOG_WARN, "failed to prepare the new %s entry", gr_dbname ()));
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"updating /etc/group",
}
#ifdef SHADOWGRP
if (is_shadowgrp && (sgr_update (sg) == 0)) {
- 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 ()));
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry\n"), Prog, sgr_dbname ());
+ SYSLOG ((LOG_WARN, "failed to prepare the new %s entry", sgr_dbname ()));
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"updating /etc/gshadow",
* Write out the new group file entry.
*/
if (gr_update (&grp) == 0) {
- 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 ()));
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry\n"), Prog, gr_dbname ());
fail_exit (E_GRP_UPDATE);
}
#ifdef SHADOWGRP
* 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 %s\n"), Prog, sgrp.sg_name, sgr_dbname ());
- SYSLOG ((LOG_WARN, "error adding new entry '%s' in %s", sgrp.sg_name, sgr_dbname ()));
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry\n"), Prog, sgr_dbname ());
fail_exit (E_GRP_UPDATE);
}
#endif /* SHADOWGRP */
fail_exit (EXIT_MEMBER_EXISTS);
}
grp->gr_mem = add_list (grp->gr_mem, adduser);
- gr_update (grp);
+ if (gr_update (grp) == 0) {
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry\n"), Prog, gr_dbname ());
+ fail_exit (13);
+ }
} else if (NULL != deluser) {
if (!is_on_list (grp->gr_mem, adduser)) {
fprintf (stderr,
fail_exit (EXIT_NOT_MEMBER);
}
grp->gr_mem = del_list (grp->gr_mem, deluser);
- gr_update (grp);
+ if (gr_update (grp) == 0) {
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry\n"), Prog, gr_dbname ());
+ fail_exit (13);
+ }
} else if (purge) {
grp->gr_mem[0] = NULL;
- gr_update (grp);
+ if (gr_update (grp) == 0) {
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry\n"), Prog, gr_dbname ());
+ fail_exit (13);
+ }
}
if (gr_close () == 0) {
*/
if (gr_update (&grp) == 0) {
fprintf (stderr,
- _("%s: cannot add entry '%s' to %s\n"),
- Prog, grp.gr_name, gr_dbname ());
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, gr_dbname (), grp.gr_name);
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"adding group",
* 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 %s\n"), Prog, sgrp.sg_name, sgr_dbname ());
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, sgr_dbname (), sgrp.sg_name);
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"adding group",
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 %s.\n"),
- Prog, pwd->pw_name,
- (unsigned long) ogid,
- (unsigned long) ngid,
- pw_dbname ());
+ _("%s: user '%s' does not exist in %s\n"),
+ Prog, pwd->pw_name, pw_dbname ());
fail_exit (E_GRP_UPDATE);
} else {
npwd = *lpwd;
npwd.pw_gid = ngid;
if (pw_update (&npwd) == 0) {
fprintf (stderr,
- _("%s: cannot change the primary group of user '%s' from %lu to %lu.\n"),
- Prog, pwd->pw_name,
- (unsigned long) ogid,
- (unsigned long) ngid);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, pw_dbname (), npwd.pw_name);
fail_exit (E_GRP_UPDATE);
}
}
if (sgr_update (&sg) == 0) {
fprintf (stderr,
- _
- ("%s: can't update shadow entry for %s\n"),
- Prog, sg.sg_name);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, sgr_dbname (), sg.sg_name);
fail_exit (E_CANT_UPDATE);
}
/* remove password from /etc/group */
gr.gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
if (gr_update (&gr) == 0) {
fprintf (stderr,
- _
- ("%s: can't update entry for group %s\n"),
- Prog, gr.gr_name);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, gr_dbname (), gr.gr_name);
fail_exit (E_CANT_UPDATE);
}
}
if (sgr_update (&sgent) == 0) {
fprintf (stderr,
- _
- ("%s: can't update shadow entry for %s\n"),
- Prog, sgent.sg_name);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, sgr_dbname (), sgent.sg_name);
fail_exit (3);
}
/* remove password from /etc/group */
grent.gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
if (gr_update (&grent) == 0) {
fprintf (stderr,
- _
- ("%s: can't update entry for group %s\n"),
- Prog, grent.gr_name);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, gr_dbname (), grent.gr_name);
fail_exit (3);
}
}
grent.gr_passwd = sg->sg_passwd;
if (gr_update (&grent) == 0) {
fprintf (stderr,
- _
- ("%s: can't update entry for group %s\n"),
- Prog, grent.gr_name);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, gr_dbname (), grent.gr_name);
fail_exit (3);
}
}
sgrent.sg_mem = members;
if (sgr_update (&sgrent) == 0) {
- fprintf (stderr,
- _("%s: group %s created, failure during the creation of the corresponding gshadow group\n"),
- Prog, grent.gr_name);
return -1;
}
}
}
npw->pw_passwd = update_crypt_pw (npw->pw_passwd);
if (pw_update (npw) == 0) {
- fputs (_("Error updating the password entry.\n"), stderr);
- SYSLOG ((LOG_WARN, "error updating password entry"));
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, pw_dbname (), npw->pw_name);
fail_exit (E_FAILURE);
}
if (pw_close () == 0) {
nsp->sp_lstchg = 0;
if (spw_update (nsp) == 0) {
- fputs (_("Error updating the password entry.\n"), stderr);
- SYSLOG ((LOG_WARN, "error updating password entry"));
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, spw_dbname (), nsp->sp_namp);
fail_exit (E_FAILURE);
}
if (spw_close () == 0) {
if (spw_update (&sp) == 0) {
fprintf (stderr,
- _("%s: can't update shadow entry for %s\n"),
- Prog, sp.sp_namp);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, spw_dbname (), sp.sp_namp);
exit (E_CANTUPDATE);
}
/* remove password from /etc/passwd */
pw.pw_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
if (pw_update (&pw) == 0) {
fprintf (stderr,
- _("%s: can't update passwd entry for %s\n"),
- Prog, pw.pw_name);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, pw_dbname (), pw.pw_name);
exit (E_CANTUPDATE);
}
}
struct passwd pwent;
const struct spwd *sp;
struct spwd spent;
- char *Prog = argv[0];
Prog = Basename (argv[0]);
spent.sp_lstchg = (long) time ((time_t *) 0) / SCALE;
if (spw_update (&spent) == 0) {
fprintf (stderr,
- _
- ("%s: can't update shadow entry for %s\n"),
- Prog, spent.sp_namp);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, spw_dbname (), spent.sp_namp);
fail_exit (E_FAILURE);
}
pwent.pw_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
if (pw_update (&pwent) == 0) {
fprintf (stderr,
- _
- ("%s: can't update passwd entry for %s\n"),
- Prog, pwent.pw_name);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, pw_dbname (), pwent.pw_name);
fail_exit (E_FAILURE);
}
}
*/
if (pw_update (&pwent) == 0) {
fprintf (stderr,
- _("%s: can't update entry for user %s\n"),
- Prog, pwent.pw_name);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, pw_dbname (), pwent.pw_name);
fail_exit (3);
}
}
ngrp->gr_mem = add_list (ngrp->gr_mem, user_name);
if (gr_update (ngrp) == 0) {
fprintf (stderr,
- _("%s: error adding new group entry\n"), Prog);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, gr_dbname (), ngrp->gr_name);
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
nsgrp->sg_mem = add_list (nsgrp->sg_mem, user_name);
if (sgr_update (nsgrp) == 0) {
fprintf (stderr,
- _("%s: error adding new entry to %s\n"), Prog, sgr_dbname ());
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, sgr_dbname (), nsgrp->sg_name);
fail_exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
* Write out the new group file entry.
*/
if (gr_update (&grp) == 0) {
- fprintf (stderr, _("%s: error adding new group entry\n"), Prog);
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, gr_dbname (), grp.gr_name);
fail_exit (E_GRP_UPDATE);
}
#ifdef SHADOWGRP
* Write out the new shadow group entries as well.
*/
if (is_shadow_grp && (sgr_update (&sgrp) == 0)) {
- fprintf (stderr, _("%s: error adding new group entry\n"), Prog);
+ fprintf (stderr,
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, sgr_dbname (), sgrp.sg_name);
fail_exit (E_GRP_UPDATE);
}
#endif /* SHADOWGRP */
*/
if (pw_update (&pwent) == 0) {
fprintf (stderr,
- _("%s: error adding new password entry\n"), Prog);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, pw_dbname (), pwent.pw_name);
fail_exit (E_PW_UPDATE);
}
*/
if (is_shadow_pwd && (spw_update (&spent) == 0)) {
fprintf (stderr,
- _
- ("%s: error adding new shadow password entry\n"),
- Prog);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, spw_dbname (), spent.sp_namp);
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"adding shadow password",
ngrp->gr_mem = del_list (ngrp->gr_mem, user_name);
if (gr_update (ngrp) == 0) {
fprintf (stderr,
- _("%s: error updating group entry\n"), Prog);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, gr_dbname (), ngrp->gr_name);
exit (E_GRP_UPDATE);
}
if (sgr_update (nsgrp) == 0) {
fprintf (stderr,
- _("%s: error updating shadow group entry\n"), Prog);
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, sgr_dbname (), nsgrp->sg_name);
exit (E_GRP_UPDATE);
}
#ifdef WITH_AUDIT
changed = false;
if (gr_update (ngrp) == 0) {
fprintf (stderr,
- _("%s: error adding new entry '%s' in %s\n"),
- Prog, ngrp->gr_name, gr_dbname ());
- SYSLOG ((LOG_WARN, "error adding new entry '%s' in %s", ngrp->gr_name, gr_dbname ()));
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, gr_dbname (), ngrp->gr_name);
+ SYSLOG ((LOG_WARN, "failed to prepare the new %s entry '%s'", gr_dbname (), ngrp->gr_name));
fail_exit (E_GRP_UPDATE);
}
}
*/
if (sgr_update (nsgrp) == 0) {
fprintf (stderr,
- _("%s: error adding new entry '%s' in '%s\n"),
- Prog, nsgrp->sg_name, sgr_dbname ());
- SYSLOG ((LOG_WARN, "error adding new entry '%s' in %s",
- nsgrp->sg_name, sgr_dbname ()));
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, sgr_dbname (), nsgrp->sg_name);
+ SYSLOG ((LOG_WARN, "failed to prepare the new %s entry '%s'",
+ sgr_dbname (), nsgrp->sg_name));
fail_exit (E_GRP_UPDATE);
}
}
|| Lflg || Uflg) {
if (pw_update (&pwent) == 0) {
fprintf (stderr,
- _("%s: cannot add new entry '%s' in %s\n"),
- Prog, pwent.pw_name, pw_dbname ());
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, pw_dbname (), pwent.pw_name);
fail_exit (E_PW_UPDATE);
}
if (lflg && (pw_remove (user_name) == 0)) {
if ((NULL != spwd) && (lflg || eflg || fflg || pflg || Lflg || Uflg)) {
if (spw_update (&spent) == 0) {
fprintf (stderr,
- _("%s: cannot add new entry '%s' in %s\n"),
- Prog, spent.sp_namp, spw_dbname ());
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, spw_dbname (), spent.sp_namp);
fail_exit (E_PW_UPDATE);
}
if (lflg && (spw_remove (user_name) == 0)) {