* src/groupadd.c: Harmonize error & syslog messages.

* src/groupadd.c: Add logging to syslog in some error cases.
This commit is contained in:
nekral-guest 2008-08-06 15:53:30 +00:00
parent 2bf3f0c03c
commit 7eab6d9958
2 changed files with 22 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2008-08-01 Nicolas François <nicolas.francois@centraliens.net>
* src/groupadd.c: Harmonize error & syslog messages.
* src/groupadd.c: Add logging to syslog in some error cases.
2008-08-01 Nicolas François <nicolas.francois@centraliens.net> 2008-08-01 Nicolas François <nicolas.francois@centraliens.net>
* src/gpasswd.c: Harmonize error & syslog messages. * src/gpasswd.c: Harmonize error & syslog messages.

View File

@ -192,7 +192,8 @@ static void grp_update (void)
* Write out the new group file entry. * Write out the new group file entry.
*/ */
if (gr_update (&grp) == 0) { if (gr_update (&grp) == 0) {
fprintf (stderr, _("%s: error adding new group entry\n"), Prog); 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));
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
#ifdef SHADOWGRP #ifdef SHADOWGRP
@ -200,7 +201,8 @@ static void grp_update (void)
* Write out the new shadow group entries as well. * Write out the new shadow group entries as well.
*/ */
if (is_shadow_grp && (sgr_update (&sgrp) == 0)) { if (is_shadow_grp && (sgr_update (&sgrp) == 0)) {
fprintf (stderr, _("%s: error adding new group entry\n"), Prog); 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));
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
#endif /* SHADOWGRP */ #endif /* SHADOWGRP */
@ -229,7 +231,7 @@ static void check_new_name (void)
* All invalid group names land here. * All invalid group names land here.
*/ */
fprintf (stderr, _("%s: %s is not a valid group name\n"), fprintf (stderr, _("%s: '%s' is not a valid group name\n"),
Prog, group_name); Prog, group_name);
exit (E_BAD_ARG); exit (E_BAD_ARG);
@ -244,14 +246,16 @@ static void check_new_name (void)
static void close_files (void) static void close_files (void)
{ {
if (gr_close () == 0) { if (gr_close () == 0) {
fprintf (stderr, _("%s: cannot rewrite group file\n"), Prog); fprintf (stderr, _("%s: cannot rewrite the group file\n"), Prog);
SYSLOG ((LOG_WARN, "cannot rewrite the group file"));
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
gr_unlock (); gr_unlock ();
#ifdef SHADOWGRP #ifdef SHADOWGRP
if (is_shadow_grp && (sgr_close () == 0)) { if (is_shadow_grp && (sgr_close () == 0)) {
fprintf (stderr, fprintf (stderr,
_("%s: cannot rewrite shadow group file\n"), Prog); _("%s: cannot rewrite the shadow group file\n"), Prog);
SYSLOG ((LOG_WARN, "cannot rewrite the shadow group file"));
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
if (is_shadow_grp) { if (is_shadow_grp) {
@ -268,7 +272,8 @@ static void close_files (void)
static void open_files (void) static void open_files (void)
{ {
if (gr_lock () == 0) { if (gr_lock () == 0) {
fprintf (stderr, _("%s: unable to lock group file\n"), Prog); fprintf (stderr, _("%s: cannot lock the group file\n"), Prog);
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 group file", "locking group file",
@ -277,7 +282,8 @@ static void open_files (void)
exit (E_GRP_UPDATE); exit (E_GRP_UPDATE);
} }
if (gr_open (O_RDWR) == 0) { if (gr_open (O_RDWR) == 0) {
fprintf (stderr, _("%s: unable to open group file\n"), Prog); fprintf (stderr, _("%s: cannot open the group file\n"), Prog);
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 group file", "opening group file",
@ -288,12 +294,14 @@ static void open_files (void)
#ifdef SHADOWGRP #ifdef SHADOWGRP
if (is_shadow_grp && (sgr_lock () == 0)) { if (is_shadow_grp && (sgr_lock () == 0)) {
fprintf (stderr, fprintf (stderr,
_("%s: unable to lock shadow group file\n"), Prog); _("%s: cannot lock the shadow group file\n"), Prog);
SYSLOG ((LOG_WARN, "cannot lock the shadow group file"));
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
if (is_shadow_grp && (sgr_open (O_RDWR) == 0)) { if (is_shadow_grp && (sgr_open (O_RDWR) == 0)) {
fprintf (stderr, fprintf (stderr,
_("%s: unable to open shadow group file\n"), Prog); _("%s: cannot open the shadow group file\n"), Prog);
SYSLOG ((LOG_WARN, "cannot open the shadow group file"));
fail_exit (E_GRP_UPDATE); fail_exit (E_GRP_UPDATE);
} }
#endif /* SHADOWGRP */ #endif /* SHADOWGRP */