* src/useradd.c: Use getlong instead of get_number.

This commit is contained in:
nekral-guest 2009-04-10 22:33:50 +00:00
parent c3f109556a
commit 06c81b67c2
2 changed files with 15 additions and 22 deletions

View File

@ -1,3 +1,7 @@
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
* src/useradd.c: Use getlong instead of get_number.
2009-04-06 Nicolas François <nicolas.francois@centraliens.net> 2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
* src/usermod.c: Re-indent. * src/usermod.c: Re-indent.

View File

@ -170,7 +170,6 @@ static bool home_added = false;
/* local function prototypes */ /* local function prototypes */
static void fail_exit (int); static void fail_exit (int);
static struct group *getgr_nam_gid (const char *); static struct group *getgr_nam_gid (const char *);
static long get_number (const char *);
static void get_defaults (void); static void get_defaults (void);
static void show_defaults (void); static void show_defaults (void);
static int set_defaults (void); static int set_defaults (void);
@ -281,22 +280,6 @@ static struct group *getgr_nam_gid (const char *grname)
return xgetgrnam (grname); return xgetgrnam (grname);
} }
static long get_number (const char *numstr)
{
long val;
char *endptr;
errno = 0;
val = strtol (numstr, &endptr, 10);
if (('\0' == *numstr) || ('\0' != *endptr) || (ERANGE == errno)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, numstr);
exit (E_BAD_ARG);
}
return val;
}
#define MATCH(x,y) (strncmp((x),(y),strlen(y)) == 0) #define MATCH(x,y) (strncmp((x),(y),strlen(y)) == 0)
/* /*
@ -1053,14 +1036,20 @@ static void process_flags (int argc, char **argv)
eflg = true; eflg = true;
break; break;
case 'f': case 'f':
def_inactive = get_number (optarg); if ( (getlong (optarg, &def_inactive) == 0)
|| (def_inactive < -1)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, optarg);
usage ();
}
/* /*
* -f -1 is allowed - it's a no-op without /etc/shadow * -f -1 is allowed
* it's a no-op without /etc/shadow
*/ */
if ((-1 != def_inactive) && !is_shadow_pwd) { if ((-1 != def_inactive) && !is_shadow_pwd) {
fprintf (stderr, fprintf (stderr,
_ _("%s: shadow passwords required for -f\n"),
("%s: shadow passwords required for -f\n"),
Prog); Prog);
exit (E_USAGE); exit (E_USAGE);
} }