Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 134334 - useradd does not respect -o option
Summary: useradd does not respect -o option
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
Depends on:
Reported: 2006-05-25 08:07 UTC by Zdenek Behan
Modified: 2006-06-11 07:45 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Behan 2006-05-25 08:07:15 UTC
'useradd' from shadow-4.0.14-r1 (and possibly other versions, too) has a bug, when attempting to create a user alias. Instead of creating, it whines about UID being duplicate.

It is a problem in useradd.c, where a function find_new_uid() is supposed to check if uid is valid, and eventually find a new one. In one place, it is called regardless of -o (--non-uniqe) option being specified.

simple patch should fix it: (i'd submit it as file, but didn't find how :) )

--- src/useradd.c.orig  2006-05-25 16:34:30.000000000 +0200
+++ src/useradd.c       2006-05-25 16:46:43.000000000 +0200
@@ -1758,7 +1758,13 @@
        /* first, seek for a valid uid to use for this user.
         * We do this because later we can use the uid we found as
         * gid too ... --gafton */
-       find_new_uid ();
+       /* however, ignore the case when -o is specified as this
+        * would make the -o option ignored completely.
+        * -o automatically enforces uid being specified on the
+        * cmdline, and such should be always valid */
+       if (!oflg )
+               find_new_uid ();

        /* do we have to add a group for that user? This is why we need to
         * open the group files in the open_files() function  --gafton */
Comment 1 SpanKY gentoo-dev 2006-05-25 21:14:40 UTC
4.0.15 already has this fixed ;)
Comment 2 Zdenek Behan 2006-05-26 03:23:34 UTC
You are right. I just upgraded, and it works. Thanks! However, isn't keyword unmasking a strange sort of fix? ;) I mean, it's a feature not working at all, maybe some sort of port into stable (or unmasking the working version) would be neat ;) Anyways, works for me too, so i'm fine with it.
Comment 3 SpanKY gentoo-dev 2006-06-11 07:45:47 UTC
we try and take the route of moving newer versions into stable instead of patching bombing the current stable version