Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 134334

Summary: useradd does not respect -o option
Product: Gentoo Linux Reporter: Zdenek Behan <rain>
Component: [OLD] baselayoutAssignee: Gentoo's Team for Core System packages <base-system>
Status: VERIFIED WORKSFORME    
Severity: normal    
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

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