]> granicus.if.org Git - shadow/commitdiff
* src/useradd.c: Get rid of strtol.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 10 Apr 2009 22:34:04 +0000 (22:34 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Fri, 10 Apr 2009 22:34:04 +0000 (22:34 +0000)
* src/useradd.c: Provide better warning in case a default GROUP or
INACTIVE value is not valid in /etc/default/useradd.

ChangeLog
src/useradd.c

index 6575fb2ef3e1f720a420cd9ba3bcdc8c6f89a548..e00d11106927e68dc39ad73b53693722ca415a41 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,9 @@
 
        * src/useradd.c: Re-indent.
        * src/useradd.c: Use getlong instead of get_number.
+       * src/useradd.c: Get rid of strtol.
+       * src/useradd.c: Provide better warning in case a default GROUP or
+       INACTIVE value is not valid in /etc/default/useradd.
 
 2009-04-06  Nicolas François  <nicolas.francois@centraliens.net>
 
index b277b8eb33e7473c9b2dd15d9bc075082867a63e..dce0d1f49fb129f121f9dc6c9a5426308a8f1441 100644 (file)
@@ -330,6 +330,9 @@ static void get_defaults (void)
                                fprintf (stderr,
                                         _("%s: group '%s' does not exist\n"),
                                         Prog, cp);
+                               fprintf (stderr,
+                                        _("%s: the %s configuration in %s will be ignored\n"),
+                                        Prog, DGROUP, def_file);
                        } else {
                                def_group = grp->gr_gid;
                                def_gname = xstrdup (grp->gr_name);
@@ -354,14 +357,14 @@ static void get_defaults (void)
                 * Default Password Inactive value
                 */
                else if (MATCH (buf, INACT)) {
-                       long val = strtol (cp, &ep, 10);
-
-                       if (   ('\0' != *cp)
-                           && ('\0' == *ep)
-                           && (ERANGE != errno)
-                           && (val >= 0)) {
-                               def_inactive = val;
-                       } else {
+                       if (   (getlong (cp, &def_inactive) == 0)
+                           || (def_inactive < -1)) {
+                               fprintf (stderr,
+                                        _("%s: invalid numeric argument '%s'\n"),
+                                        Prog, optarg);
+                               fprintf (stderr,
+                                        _("%s: the %s configuration in %s will be ignored\n"),
+                                        Prog, INACT, def_file);
                                def_inactive = -1;
                        }
                }
@@ -971,9 +974,9 @@ static void process_flags (int argc, char **argv)
                        {"user-group", no_argument, NULL, 'U'},
                        {NULL, 0, NULL, '\0'}
                };
-               while ((c =
-                       getopt_long (argc, argv, "b:c:d:De:f:g:G:k:K:lmMNop:rs:u:U",
-                                    long_options, NULL)) != -1) {
+               while ((c = getopt_long (argc, argv,
+                                        "b:c:d:De:f:g:G:k:K:lmMNop:rs:u:U",
+                                        long_options, NULL)) != -1) {
                        switch (c) {
                        case 'b':
                                if (   ( !VALID (optarg) )
@@ -1247,7 +1250,7 @@ static void process_flags (int argc, char **argv)
                        char *uh;
 
                        uh = xmalloc (strlen (def_home) +
-                                     strlen (user_name) + 2);
+                                     strlen (user_name) + 2);
                        sprintf (uh, "%s/%s", def_home, user_name);
                        user_home = uh;
                }