forwarded 381394 [EMAIL PROTECTED] thanks Quoting Brandon Peirce ([EMAIL PROTECTED]): > I wrote: > >Hello, > > > >The fix from http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=198920 > >seems > >to have completely broken the -g option of useradd. (src/usradd.c $Id: > >1.100) > > The indents in the patch got lost in the cut & paste - sorry :( > Patch resent as attachment.
For the sake of it, here's the patch we use in Debian for that problem (bugs #381394, #381399, #381404, #381408, #381448 in Debian BTS). It seems, by the way, that, contrary to our usual policy, we did not send it to Tomasz. We use to send our patches directly to him. Maybe we should indeed send them to this list (which I, as one of shadow maintainers in Debian, am subscribed to) so that they're exposed to peer review, especially by maintainers of shadow in other distros. I'm not in the position of comparing both patches indeed but I guess that Tomasz will (though we haven't heard from him in the last weeks).
Goal: allow non numerical group identifier to be specified with useradd's and usermod's -g options Fixes: #381394, #381399, #381404, #381408, #381448 Status wrt upstream: not reported yet. Index: shadow-4.0.18.1/src/useradd.c =================================================================== --- shadow-4.0.18.1.orig/src/useradd.c 2006-09-17 12:18:05.004093135 +0200 +++ shadow-4.0.18.1/src/useradd.c 2006-09-17 12:18:15.280174838 +0200 @@ -206,11 +206,8 @@ char *errptr; gid = strtol (grname, &errptr, 10); - if (*errptr || errno == ERANGE || gid < 0) { - fprintf (stderr, - _("%s: invalid numeric argument '%s'\n"), Prog, grname); - exit (E_BAD_ARG); - } + if (*grname != '\0' && *errptr == '\0' && errno != ERANGE && gid >= 0) + return getgrgid (gid); return getgrnam (grname); } Index: shadow-4.0.18.1/src/usermod.c =================================================================== --- shadow-4.0.18.1.orig/src/usermod.c 2006-09-17 12:18:11.400143989 +0200 +++ shadow-4.0.18.1/src/usermod.c 2006-09-17 12:18:15.284174870 +0200 @@ -167,11 +167,8 @@ char *errptr; val = strtol (grname, &errptr, 10); - if (*errptr || errno == ERANGE || val < 0) { - fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, - grname); - exit (E_BAD_ARG); - } + if (*grname != '\0' && *errptr == '\0' && errno != ERANGE && val >= 0) + return getgrgid (val); return getgrnam (grname); }