Re: switch -u takes negative number
Peter Vrabec <[email protected]> Tue, 18 Jul 2006 14:25:21 +0200
| Newsgroups | gmane.linux.pld.shadow.general |
|---|---|
| Message-ID | <[email protected]> |
--MP_358yfr8dq7U5RXjvQ=fFafx Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline fixed and improved patch in attachment On Mon, 17 Jul 2006 16:50:48 +0200 (CEST) Tomasz Kłoczko <[email protected]> wrote: > On Mon, 17 Jul 2006, Peter Vrabec wrote: > > > Hi, > > > > could you look at: > > http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=198920 > > > > and consider applying this patch. > > Ouch .. looks bad :> > Probably the same is in on passing GID numbers in group{add,mode} and > with UID in usermod. All other tools must be also checked for this .. > > Looks like will be good prepare for next shadow release ASAP > (comming monday or next tuesday). > > Thank you. > > kloczek --MP_358yfr8dq7U5RXjvQ=fFafx Content-Type: text/x-patch; name=shadow-4.0.17-UID_GID.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=shadow-4.0.17-UID_GID.patch --- shadow-4.0.17/src/useradd.c.UID_GID 2006-06-22 13:30:32.000000000 +0200 +++ shadow-4.0.17/src/useradd.c 2006-07-18 14:22:30.000000000 +0200 @@ -203,9 +203,14 @@ gid_t gid; char *ep; - gid = strtoul (name, &ep, 10); - if (*name != '\0' && *ep == '\0') /* valid numeric GID */ - return getgrgid (gid); + gid = strtoul (name, &ep, 10); + if (*name != '\0' && *ep == '\0') { /* valid numeric GID */ + if (errno == ERANGE || *name == '-') { + fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, name); + exit (E_BAD_ARG); + } else + return getgrgid (gid); + } return getgrnam (name); } @@ -229,7 +234,7 @@ char *ep; val = strtoul (cp, &ep, 10); - if (*cp != '\0' && *ep == '\0') /* valid number */ + if (errno != ERANGE && *cp != '\0' && *ep == '\0' && *cp != '-') /* valid number */ return val; fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, cp); --- shadow-4.0.17/src/usermod.c.UID_GID 2006-06-25 15:10:29.000000000 +0200 +++ shadow-4.0.17/src/usermod.c 2006-07-18 14:22:30.000000000 +0200 @@ -166,9 +166,14 @@ char *ep; gid = strtoul (name, &ep, 10); - if (*name != '\0' && *ep == '\0') /* valid numeric GID */ - return getgrgid (gid); - + if (*name != '\0' && *ep == '\0') { /* valid numeric GID */ + if (errno == ERANGE || *name == '-') { + fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, name); + exit (E_BAD_ARG); + } else + return getgrgid (gid); + } + return getgrnam (name); } @@ -822,7 +827,7 @@ char *ep; val = strtoul (cp, &ep, 10); - if (*cp != '\0' && *ep == '\0') /* valid number */ + if (errno != ERANGE && *cp != '\0' && *ep == '\0' && *cp != '-') /* valid number */ return val; fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, cp); --- shadow-4.0.17/src/groupadd.c.UID_GID 2006-06-24 07:52:00.000000000 +0200 +++ shadow-4.0.17/src/groupadd.c 2006-07-18 14:22:30.000000000 +0200 @@ -431,7 +431,7 @@ usage (); group_id = strtoul (optarg, &cp, 10); - if (*cp != '\0') { + if (errno == ERANGE || *cp != '\0') { fprintf (stderr, _("%s: invalid group %s\n"), Prog, optarg); --- shadow-4.0.17/src/groupmod.c.UID_GID 2006-06-25 16:12:38.000000000 +0200 +++ shadow-4.0.17/src/groupmod.c 2006-07-18 14:22:30.000000000 +0200 @@ -326,7 +326,7 @@ case 'g': gflg++; group_newid = strtoul (optarg, &end, 10); - if (*end != '\0') { + if (errno == ERANGE || *end != '\0' || optarg[0] == '-') { fprintf (stderr, _("%s: invalid group %s\n"), Prog, optarg); --MP_358yfr8dq7U5RXjvQ=fFafx Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline