* lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h,
lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h: Added *_dbname() functions to retrieve the name of the databases. * lib/groupio.c, lib/groupio.h, lib/pwio.c, lib/pwio.h, lib/sgroupio.c, lib/sgroupio.h, lib/shadowio.c, lib/shadowio.h: *_name() functions renamed *setname(). * src/grpck.c, src/pwck.c: Likewise. * lib/groupio.h, lib/pwio.h, lib/sgroupio.h, lib/shadowio.h: Added the name of the arguments to the prototypes. * src/chage, src/chfn.c, src/chgpasswd.c, src/chpasswd.c, src/chsh.c, src/gpasswd.c, src/groupadd.c, src/groupdel.c, src/groupmod.c, src/grpck.c, src/grpconv.c, src/grpunconv.c, src/newusers.c, src/passwd.c, src/pwck.c, src/pwconv.c, src/pwunconv.c, src/useradd.c, src/userdel.c, src/usermod.c: Harmonize the erro & syslog messages in case of failure of the *_lock(), *_open(), *_close(), *_unlock(), *_remove() functions. * src/chgpasswd.c, src/chpasswd.c, src/usermod.c: Avoid capitalized messages. * src/chpasswd.c, src/useradd.c, src/usermod.c: Harmonize messages in case of inexistent entries. * src/usermod.c: Harmonize messages in case of already existing entries. * src/newusers.c, src/useradd.c: Simplify PAM error handling. * src/useradd.c: Report failures to unlock files (stderr, syslog, and audit). But do not fail (continue). * src/useradd.c (open_files): Do not report to syslog & audit failures to lock or open the databases. This might be harmless, and the logs were not already informed that a change was requested. * src/usermod.c: It's not the account which is unlocked, but its password.
This commit is contained in:
parent
b0fe7d3a0b
commit
7fc596fb8a
34
ChangeLog
34
ChangeLog
@ -1,3 +1,37 @@
|
||||
2008-08-06 Nicolas François <nicolas.francois@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@centraliens.net>
|
||||
|
||||
* src/groupadd.c: Harmonize error & syslog messages.
|
||||
|
@ -126,11 +126,16 @@ static struct commonio_db group_db = {
|
||||
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);
|
||||
|
@ -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
|
||||
|
@ -108,11 +108,16 @@ static struct commonio_db passwd_db = {
|
||||
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);
|
||||
|
11
lib/pwio.h
11
lib/pwio.h
@ -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
|
||||
|
@ -161,11 +161,16 @@ static struct commonio_db gshadow_db = {
|
||||
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);
|
||||
|
@ -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
|
||||
|
@ -105,11 +105,16 @@ static struct commonio_db shadow_db = {
|
||||
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);
|
||||
|
@ -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
|
||||
|
36
src/chage.c
36
src/chage.c
@ -555,16 +555,16 @@ static void open_files (bool readonly)
|
||||
*/
|
||||
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 @@ static void open_files (bool readonly)
|
||||
*/
|
||||
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 @@ static void open_files (bool readonly)
|
||||
}
|
||||
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 @@ static void close_files (void)
|
||||
*/
|
||||
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 @@ static void close_files (void)
|
||||
* 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 @@ static void update_age (const struct spwd *sp, const struct passwd *pw)
|
||||
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 @@ static void update_age (const struct spwd *sp, const struct passwd *pw)
|
||||
|
||||
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 @@ int main (int argc, char **argv)
|
||||
|
||||
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);
|
||||
}
|
||||
|
28
src/chfn.c
28
src/chfn.c
@ -417,16 +417,18 @@ static void update_gecos (const char *user, char *gecos)
|
||||
* password file. Get a lock on the file and open it.
|
||||
*/
|
||||
if (pw_lock () == 0) {
|
||||
fputs (_("Cannot lock the password file; try again later.\n"),
|
||||
stderr);
|
||||
SYSLOG ((LOG_WARN, "can't lock /etc/passwd"));
|
||||
fprintf (stderr,
|
||||
_("%s: cannot lock %s; try again later.\n"),
|
||||
Prog, pw_dbname ());
|
||||
SYSLOG ((LOG_WARN, "cannot lock %s", pw_dbname ()));
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
if (pw_open (O_RDWR) == 0) {
|
||||
fputs (_("Cannot open the password file.\n"), stderr);
|
||||
fprintf (stderr,
|
||||
_("%s: cannot open %s\n"), Prog, pw_dbname ());
|
||||
pw_unlock ();
|
||||
SYSLOG ((LOG_ERR, "can't open /etc/passwd"));
|
||||
SYSLOG ((LOG_ERR, "cannot open %s", pw_dbname ()));
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
@ -441,7 +443,8 @@ static void update_gecos (const char *user, char *gecos)
|
||||
if (NULL == pw) {
|
||||
pw_unlock ();
|
||||
fprintf (stderr,
|
||||
_("%s: %s not found in /etc/passwd\n"), Prog, user);
|
||||
_("%s: user '%s' does not exist in %s\n"),
|
||||
Prog, user, pw_dbname ());
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
|
||||
@ -468,15 +471,15 @@ static void update_gecos (const char *user, char *gecos)
|
||||
* Changes have all been made, so commit them and unlock the file.
|
||||
*/
|
||||
if (pw_close () == 0) {
|
||||
fputs (_("Cannot commit password file changes.\n"), stderr);
|
||||
fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
|
||||
pw_unlock ();
|
||||
SYSLOG ((LOG_ERR, "can't rewrite /etc/passwd"));
|
||||
SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
if (pw_unlock () == 0) {
|
||||
fputs (_("Cannot unlock the password file.\n"), stderr);
|
||||
SYSLOG ((LOG_ERR, "can't unlock /etc/passwd"));
|
||||
fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
|
||||
SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
@ -633,7 +636,7 @@ int main (int argc, char **argv)
|
||||
user = argv[optind];
|
||||
pw = xgetpwnam (user);
|
||||
if (NULL == pw) {
|
||||
fprintf (stderr, _("%s: unknown user %s\n"), Prog,
|
||||
fprintf (stderr, _("%s: user '%s' does not exist\n"), Prog,
|
||||
user);
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
@ -641,8 +644,7 @@ int main (int argc, char **argv)
|
||||
pw = get_my_pwent ();
|
||||
if (NULL == pw) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: Cannot determine your user name.\n"),
|
||||
_("%s: Cannot determine your user name.\n"),
|
||||
Prog);
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ static void check_flags (void)
|
||||
{
|
||||
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 @@ static void open_files (void)
|
||||
* 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 @@ static void open_files (void)
|
||||
/* Do the same for the shadowed database, if it exist */
|
||||
if (is_shadow_grp) {
|
||||
if (sgr_lock () == 0) {
|
||||
fprintf (stderr, _("%s: 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 @@ static void close_files (void)
|
||||
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 @@ static void close_files (void)
|
||||
#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 @@ int main (int argc, char **argv)
|
||||
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;
|
||||
|
@ -175,7 +175,7 @@ static void check_flags (void)
|
||||
{
|
||||
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 @@ static void open_files (void)
|
||||
* 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 @@ static void open_files (void)
|
||||
/* 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 @@ static void close_files (void)
|
||||
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 @@ static void close_files (void)
|
||||
}
|
||||
|
||||
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 @@ int main (int argc, char **argv)
|
||||
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 @@ int main (int argc, char **argv)
|
||||
|
||||
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;
|
||||
|
24
src/chsh.c
24
src/chsh.c
@ -352,16 +352,16 @@ static void update_shell (const char *user, char *newshell)
|
||||
* 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 @@ static void update_shell (const char *user, char *newshell)
|
||||
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 @@ static void update_shell (const char *user, char *newshell)
|
||||
* 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 @@ int main (int argc, char **argv)
|
||||
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 {
|
||||
|
@ -162,8 +162,8 @@ static void fail_exit (int status)
|
||||
{
|
||||
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 @@ static void fail_exit (int status)
|
||||
#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 check_flags (int argc, int opt_index)
|
||||
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 @@ static void open_files (void)
|
||||
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 @@ static void open_files (void)
|
||||
}
|
||||
#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 @@ static void open_files (void)
|
||||
}
|
||||
#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 open_files (void)
|
||||
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 @@ static void close_files (void)
|
||||
#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 @@ static void close_files (void)
|
||||
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 @@ static void close_files (void)
|
||||
}
|
||||
#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 @@ static void update_group (struct group *gr)
|
||||
#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 @@ static void update_group (struct group *gr)
|
||||
}
|
||||
#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 @@ static void get_group (struct group *gr)
|
||||
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 @@ static void get_group (struct group *gr)
|
||||
|
||||
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 @@ static void get_group (struct group *gr)
|
||||
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 @@ static void get_group (struct group *gr)
|
||||
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 @@ static void get_group (struct group *gr)
|
||||
}
|
||||
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",
|
||||
|
@ -198,8 +198,8 @@ static void grp_update (void)
|
||||
* 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 @@ static void grp_update (void)
|
||||
* 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 check_new_name (void)
|
||||
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 @@ static void close_files (void)
|
||||
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 close_files (void)
|
||||
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 @@ static void open_files (void)
|
||||
}
|
||||
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 @@ static void open_files (void)
|
||||
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 @@ static void open_files (void)
|
||||
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 @@ static void fail_exit (int code)
|
||||
{
|
||||
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 @@ static void fail_exit (int code)
|
||||
#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 @@ static void process_flags (int argc, char **argv)
|
||||
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 @@ static void check_flags (void)
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ static void fail_exit (int code)
|
||||
{
|
||||
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 @@ static void fail_exit (int code)
|
||||
#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 fail_exit (int code)
|
||||
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 @@ static void grp_update (void)
|
||||
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 @@ static void close_files (void)
|
||||
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 @@ static void close_files (void)
|
||||
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 close_files (void)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -125,8 +125,8 @@ static void fail_exit (int status)
|
||||
{
|
||||
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 @@ static void fail_exit (int status)
|
||||
#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 @@ static void fail_exit (int status)
|
||||
#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 @@ static void grp_update (void)
|
||||
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 @@ static void grp_update (void)
|
||||
* 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 @@ static void grp_update (void)
|
||||
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",
|
||||