]> granicus.if.org Git - shadow/commitdiff
* src/groupadd.c: Harmonize error & syslog messages.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Wed, 6 Aug 2008 15:53:30 +0000 (15:53 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Wed, 6 Aug 2008 15:53:30 +0000 (15:53 +0000)
* src/groupadd.c: Add logging to syslog in some error cases.

ChangeLog
src/groupadd.c

index 407b3c0c59738ff84362bed69307cf8c42a8fd1d..5d71e3b41ecf1ca1a877eec6d5a4f1403076fd87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * src/gpasswd.c: Harmonize error & syslog messages.
index beb3cf97ae093f307dcd342641652a87ea147ec9..e606397cb0c051553b01b22db5df4187e4b66299 100644 (file)
@@ -192,7 +192,8 @@ static void grp_update (void)
         * 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: 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);
        }
 #ifdef SHADOWGRP
@@ -200,7 +201,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 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);
        }
 #endif                         /* SHADOWGRP */
@@ -229,7 +231,7 @@ static void check_new_name (void)
         * 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);
 
        exit (E_BAD_ARG);
@@ -244,14 +246,16 @@ static void check_new_name (void)
 static void close_files (void)
 {
        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);
        }
        gr_unlock ();
 #ifdef SHADOWGRP
        if (is_shadow_grp && (sgr_close () == 0)) {
                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);
        }
        if (is_shadow_grp) {
@@ -268,7 +272,8 @@ static void close_files (void)
 static void open_files (void)
 {
        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
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "locking group file",
@@ -277,7 +282,8 @@ static void open_files (void)
                exit (E_GRP_UPDATE);
        }
        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
                audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
                              "opening group file",
@@ -288,12 +294,14 @@ static void open_files (void)
 #ifdef SHADOWGRP
        if (is_shadow_grp && (sgr_lock () == 0)) {
                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);
        }
        if (is_shadow_grp && (sgr_open (O_RDWR) == 0)) {
                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);
        }
 #endif                         /* SHADOWGRP */