[PATCH] Useradd -g problems
Johannes Winkelmann <[email protected]> Fri, 4 Aug 2006 08:47:23 +0200
| Newsgroups | gmane.linux.pld.shadow.general |
|---|---|
| Message-ID | <[email protected]> |
--HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, I see the following problem with shadow 4.0.18(.1): # cat /etc/group|grep video video:x:105:jw # useradd -g video testuser useradd: invalid numeric argument 'video' # useradd -g 105 testuser useradd: unknown group 105 # So neither way works here. Can anyone reproduce this? As far as I can see, the fix for http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=198920 broke it, in particular the getgr_nam_gid function. A possible solution is attached as patch. Regards, Johannes -- Johannes Winkelmann mailto:[email protected] Zurich, Switzerland http://jw.smts.ch --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="shadow-4.0.18.1-useradd.diff" --- shadow-4.0.18.1/src/useradd.c.orig 2006-08-04 08:22:46.000000000 +0200 +++ shadow-4.0.18.1/src/useradd.c 2006-08-04 08:39:49.000000000 +0200 @@ -203,13 +203,17 @@ long gid; char *errptr; + struct group* grp = getgrnam(grname); + if (grp) + return grp; + 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); } - return getgrnam (grname); + return getgrgid(gid); } static long get_number (const char *numstr) --HcAYCG3uE/tztfnV Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline