* src/gpasswd.c: Harmonize error & syslog messages.
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
2008-08-01 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/gpasswd.c: Harmonize error & syslog messages.
|
||||||
|
|
||||||
2008-08-01 Nicolas François <nicolas.francois@centraliens.net>
|
2008-08-01 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/chfn.c, src/chsh.c, src/groupdel.c, src/groupmems.c,
|
* src/chfn.c, src/chsh.c, src/groupdel.c, src/groupmems.c,
|
||||||
|
@ -208,7 +208,7 @@ static bool is_valid_user_list (const char *users)
|
|||||||
|
|
||||||
/* local, no need for xgetpwnam */
|
/* local, no need for xgetpwnam */
|
||||||
if (getpwnam (username) == NULL) {
|
if (getpwnam (username) == NULL) {
|
||||||
fprintf (stderr, _("%s: unknown user %s\n"),
|
fprintf (stderr, _("%s: user '%s' does not exist\n"),
|
||||||
Prog, username);
|
Prog, username);
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
@ -236,8 +236,8 @@ static void process_flags (int argc, char **argv)
|
|||||||
/* local, no need for xgetpwnam */
|
/* local, no need for xgetpwnam */
|
||||||
if (getpwnam (user) == NULL) {
|
if (getpwnam (user) == NULL) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: unknown user %s\n"), Prog,
|
_("%s: user '%s' does not exist\n"), Prog,
|
||||||
user);
|
user);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"adding to group",
|
"adding to group",
|
||||||
@ -259,8 +259,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if (!is_shadowgrp) {
|
if (!is_shadowgrp) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_
|
_("%s: shadow group passwords required for -A\n"),
|
||||||
("%s: shadow group passwords required for -A\n"),
|
|
||||||
Prog);
|
Prog);
|
||||||
fail_exit (2);
|
fail_exit (2);
|
||||||
}
|
}
|
||||||
@ -353,8 +352,8 @@ static void check_flags (int argc, int opt_index)
|
|||||||
static void open_files (void)
|
static void open_files (void)
|
||||||
{
|
{
|
||||||
if (gr_lock () == 0) {
|
if (gr_lock () == 0) {
|
||||||
fprintf (stderr, _("%s: can't get lock\n"), Prog);
|
fprintf (stderr, _("%s: cannot lock the group file\n"), Prog);
|
||||||
SYSLOG ((LOG_WARN, "failed to get lock for /etc/group"));
|
SYSLOG ((LOG_WARN, "cannot lock the group file"));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"locking /etc/group",
|
"locking /etc/group",
|
||||||
@ -367,8 +366,8 @@ static void open_files (void)
|
|||||||
if (is_shadowgrp) {
|
if (is_shadowgrp) {
|
||||||
if (sgr_lock () == 0) {
|
if (sgr_lock () == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: can't get shadow lock\n"), Prog);
|
_("%s: cannot lock the shadow group file\n"), Prog);
|
||||||
SYSLOG ((LOG_WARN, "failed to get lock for /etc/gshadow"));
|
SYSLOG ((LOG_WARN, "cannot lock the shadow group file"));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"locking /etc/gshadow",
|
"locking /etc/gshadow",
|
||||||
@ -380,8 +379,8 @@ static void open_files (void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (gr_open (O_RDWR) == 0) {
|
if (gr_open (O_RDWR) == 0) {
|
||||||
fprintf (stderr, _("%s: can't open file\n"), Prog);
|
fprintf (stderr, _("%s: cannot open the group file\n"), Prog);
|
||||||
SYSLOG ((LOG_WARN, "cannot open /etc/group"));
|
SYSLOG ((LOG_WARN, "cannot open the group file"));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"opening /etc/group",
|
"opening /etc/group",
|
||||||
@ -391,8 +390,8 @@ static void open_files (void)
|
|||||||
}
|
}
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
if (is_shadowgrp && (sgr_open (O_RDWR) == 0)) {
|
if (is_shadowgrp && (sgr_open (O_RDWR) == 0)) {
|
||||||
fprintf (stderr, _("%s: can't open shadow file\n"), Prog);
|
fprintf (stderr, _("%s: cannot open the shadow group file\n"), Prog);
|
||||||
SYSLOG ((LOG_WARN, "cannot open /etc/gshadow"));
|
SYSLOG ((LOG_WARN, "cannot open the shadow group file"));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"opening /etc/gshadow",
|
"opening /etc/gshadow",
|
||||||
@ -413,8 +412,8 @@ static void open_files (void)
|
|||||||
static void close_files (void)
|
static void close_files (void)
|
||||||
{
|
{
|
||||||
if (gr_close () == 0) {
|
if (gr_close () == 0) {
|
||||||
fprintf (stderr, _("%s: can't re-write file\n"), Prog);
|
fprintf (stderr, _("%s: cannot rewrite the group file\n"), Prog);
|
||||||
SYSLOG ((LOG_WARN, "cannot re-write /etc/group"));
|
SYSLOG ((LOG_WARN, "cannot rewrite the group file"));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"rewriting /etc/group",
|
"rewriting /etc/group",
|
||||||
@ -424,8 +423,8 @@ static void close_files (void)
|
|||||||
}
|
}
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
if (is_shadowgrp && (sgr_close () == 0)) {
|
if (is_shadowgrp && (sgr_close () == 0)) {
|
||||||
fprintf (stderr, _("%s: can't re-write shadow file\n"), Prog);
|
fprintf (stderr, _("%s: cannot rewrite the shadow group file\n"), Prog);
|
||||||
SYSLOG ((LOG_WARN, "cannot re-write /etc/gshadow"));
|
SYSLOG ((LOG_WARN, "cannot rewrite the shadow group file"));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"rewriting /etc/gshadow",
|
"rewriting /etc/gshadow",
|
||||||
@ -440,7 +439,7 @@ static void close_files (void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (gr_unlock () == 0) {
|
if (gr_unlock () == 0) {
|
||||||
fprintf (stderr, _("%s: can't unlock file\n"), Prog);
|
fprintf (stderr, _("%s: cannot unlock the group file\n"), Prog);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"unlocking group file",
|
"unlocking group file",
|
||||||
@ -540,8 +539,8 @@ static void update_group (struct group *gr)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (gr_update (gr) == 0) {
|
if (gr_update (gr) == 0) {
|
||||||
fprintf (stderr, _("%s: can't update entry\n"), Prog);
|
fprintf (stderr, _("%s: cannot update the entry of '%s' in the group file\n"), Prog, gr->gr_name);
|
||||||
SYSLOG ((LOG_WARN, "cannot update /etc/group"));
|
SYSLOG ((LOG_WARN, "cannot update the entry of '%s' in the group file", gr->gr_name));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"updating /etc/group",
|
"updating /etc/group",
|
||||||
@ -551,8 +550,8 @@ static void update_group (struct group *gr)
|
|||||||
}
|
}
|
||||||
#ifdef SHADOWGRP
|
#ifdef SHADOWGRP
|
||||||
if (is_shadowgrp && (sgr_update (sg) == 0)) {
|
if (is_shadowgrp && (sgr_update (sg) == 0)) {
|
||||||
fprintf (stderr, _("%s: can't update shadow entry\n"), Prog);
|
fprintf (stderr, _("%s: cannot update the entry of '%s' in the shadow group file\n"), Prog, sg->sg_name);
|
||||||
SYSLOG ((LOG_WARN, "cannot update /etc/gshadow"));
|
SYSLOG ((LOG_WARN, "cannot update the entry of '%s' in the shadow group file", sg->sg_name));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"updating /etc/gshadow",
|
"updating /etc/gshadow",
|
||||||
@ -581,8 +580,8 @@ static void get_group (struct group *gr)
|
|||||||
struct sgrp const*tmpsg = NULL;
|
struct sgrp const*tmpsg = NULL;
|
||||||
|
|
||||||
if (gr_open (O_RDONLY) == 0) {
|
if (gr_open (O_RDONLY) == 0) {
|
||||||
fprintf (stderr, _("%s: can't open file\n"), Prog);
|
fprintf (stderr, _("%s: cannot open the group file\n"), Prog);
|
||||||
SYSLOG ((LOG_WARN, "cannot open /etc/group"));
|
SYSLOG ((LOG_WARN, "cannot open the group file"));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"opening /etc/group",
|
"opening /etc/group",
|
||||||
@ -593,7 +592,7 @@ static void get_group (struct group *gr)
|
|||||||
|
|
||||||
tmpgr = gr_locate (group);
|
tmpgr = gr_locate (group);
|
||||||
if (NULL == tmpgr) {
|
if (NULL == tmpgr) {
|
||||||
fprintf (stderr, _("unknown group: %s\n"), group);
|
fprintf (stderr, _("%s: group '%s' does not exist in the group file\n"), Prog, group);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"group lookup",
|
"group lookup",
|
||||||
@ -608,8 +607,8 @@ static void get_group (struct group *gr)
|
|||||||
gr->gr_mem = dup_list (tmpgr->gr_mem);
|
gr->gr_mem = dup_list (tmpgr->gr_mem);
|
||||||
|
|
||||||
if (gr_close () == 0) {
|
if (gr_close () == 0) {
|
||||||
fprintf (stderr, _("%s: can't close file\n"), Prog);
|
fprintf (stderr, _("%s: cannot rewrite the group file\n"), Prog);
|
||||||
SYSLOG ((LOG_WARN, "cannot close /etc/group"));
|
SYSLOG ((LOG_WARN, "cannot rewrite the group file"));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"closing /etc/group",
|
"closing /etc/group",
|
||||||
@ -622,8 +621,8 @@ static void get_group (struct group *gr)
|
|||||||
if (is_shadowgrp) {
|
if (is_shadowgrp) {
|
||||||
if (sgr_open (O_RDONLY) == 0) {
|
if (sgr_open (O_RDONLY) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: can't open shadow file\n"), Prog);
|
_("%s: cannot open the shadow group file\n"), Prog);
|
||||||
SYSLOG ((LOG_WARN, "cannot open /etc/gshadow"));
|
SYSLOG ((LOG_WARN, "cannot open the shadow group file"));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"opening /etc/gshadow",
|
"opening /etc/gshadow",
|
||||||
@ -660,8 +659,8 @@ static void get_group (struct group *gr)
|
|||||||
}
|
}
|
||||||
if (sgr_close () == 0) {
|
if (sgr_close () == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: can't close shadow file\n"), Prog);
|
_("%s: cannot rewrite the shadow group file\n"), Prog);
|
||||||
SYSLOG ((LOG_WARN, "cannot close /etc/gshadow"));
|
SYSLOG ((LOG_WARN, "cannot rewrite the shadow group file"));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"closing /etc/gshadow",
|
"closing /etc/gshadow",
|
||||||
@ -919,8 +918,8 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
fprintf (stderr, _("%s: unknown member %s\n"),
|
fprintf (stderr, _("%s: user '%s' is not a member of '%s'\n"),
|
||||||
Prog, user);
|
Prog, user, group);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"deleting member",
|
"deleting member",
|
||||||
|
Reference in New Issue
Block a user