[F16 PATCH 2/2] Fix createUser and createGroup to work with kickstart defaults (#739428)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Brian C. Lane" <bcl@xxxxxxxxxx>

When the kickstart data is passed to crateUser and createGroup it
already has defaults for the attributes. Instead of only checking for
their presence in kwargs also check for non-default values.
---
 pyanaconda/users.py |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/pyanaconda/users.py b/pyanaconda/users.py
index 255c046..defab35 100644
--- a/pyanaconda/users.py
+++ b/pyanaconda/users.py
@@ -99,7 +99,7 @@ class Users:
         self.admin = libuser.admin()
         self.rootPassword = { "isCrypted": False, "password": "", "lock": False }
 
-    def createGroup (self, name, **kwargs):
+    def createGroup (self, group_name, **kwargs):
         """Create a new user on the system with the given name.  Optional kwargs:
 
            gid       -- The GID for the new user.  If none is given, the next
@@ -120,10 +120,10 @@ class Users:
             self.admin = libuser.admin()
 
             try:
-                if self.admin.lookupGroupByName(name):
+                if self.admin.lookupGroupByName(group_name):
                     os._exit(1)
 
-                groupEnt = self.admin.initGroup(name)
+                groupEnt = self.admin.initGroup(group_name)
 
                 if "gid" in kwargs and kwargs["gid"] >= 0:
                     groupEnt.set(libuser.GIDNUMBER, kwargs["gid"])
@@ -191,25 +191,25 @@ class Users:
                 userEnt.set(libuser.GIDNUMBER, [groupEnt.get(libuser.GIDNUMBER)[0]] +
                             map(lambda grp: grp.get(libuser.GIDNUMBER)[0], grpLst))
 
-                if "homedir" in kwargs:
+                if kwargs.get("homedir", False):
                     userEnt.set(libuser.HOMEDIRECTORY, kwargs["homedir"])
                 else:
                     iutil.mkdirChain(root+'/home')
                     userEnt.set(libuser.HOMEDIRECTORY, "/home/" + user_name)
 
-                if "shell" in kwargs:
+                if kwargs.get("shell", False):
                     userEnt.set(libuser.LOGINSHELL, kwargs["shell"])
 
-                if "uid" in kwargs and kwargs["uid"] >= 0:
+                if kwargs.get("uid", -1) >= 0:
                     userEnt.set(libuser.UIDNUMBER, kwargs["uid"])
 
-                if "gecos" in kwargs:
+                if kwargs.get("gecos", False):
                     userEnt.set(libuser.GECOS, kwargs["gecos"])
 
                 self.admin.addUser(userEnt, mkmailspool=kwargs.get("mkmailspool", True))
                 self.admin.addGroup(groupEnt)
 
-                if "password" in kwargs:
+                if kwargs.get("password", False):
                     if kwargs.get("isCrypted", False):
                         password = kwargs["password"]
                     else:
-- 
1.7.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux