FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 09-19-2011, 07:08 PM
"Brian C. Lane"
 
Default Fix createUser and createGroup to work with kickstart defaults (#739428)

From: "Brian C. Lane" <bcl@redhat.com>

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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 10:53 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org