summaryrefslogtreecommitdiffstats
path: root/users.py
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2008-01-29 14:15:34 -0500
committerChris Lumens <clumens@redhat.com>2008-01-29 14:15:34 -0500
commit553f494dea845b8d3ae30af5977619ad05084af2 (patch)
treebe25c7872c8555f01c7542b2b68b9352ac079141 /users.py
parent6321f34ef68972e7e1ce3126fa69c7f493eb25f3 (diff)
downloadanaconda-553f494dea845b8d3ae30af5977619ad05084af2.tar.gz
anaconda-553f494dea845b8d3ae30af5977619ad05084af2.tar.xz
anaconda-553f494dea845b8d3ae30af5977619ad05084af2.zip
Don't traceback trying to raise an exception when making users (#430772).
Since we are chrooted when adding a user, it's impossible to find the glade files in the installation environment. It looks like the only thing we can really do is log an error message and keep going.
Diffstat (limited to 'users.py')
-rw-r--r--users.py62
1 files changed, 33 insertions, 29 deletions
diff --git a/users.py b/users.py
index 673a8029a..fe5751f23 100644
--- a/users.py
+++ b/users.py
@@ -80,46 +80,50 @@ class Users:
if not childpid:
os.chroot(root)
- if self.admin.lookupUserByName(name):
- os._exit(1)
+ try:
+ if self.admin.lookupUserByName(name):
+ os._exit(1)
- userEnt = self.admin.initUser(name)
- groupEnt = self.admin.initGroup(name)
+ userEnt = self.admin.initUser(name)
+ groupEnt = self.admin.initGroup(name)
- grpLst = filter(lambda grp: grp,
- map(lambda name: self.admin.lookupGroupByName(name), groups))
- userEnt.set(libuser.GIDNUMBER, [groupEnt.get(libuser.GIDNUMBER)[0]] +
- map(lambda grp: grp.get(libuser.GIDNUMBER)[0], grpLst))
+ grpLst = filter(lambda grp: grp,
+ map(lambda name: self.admin.lookupGroupByName(name), groups))
+ userEnt.set(libuser.GIDNUMBER, [groupEnt.get(libuser.GIDNUMBER)[0]] +
+ map(lambda grp: grp.get(libuser.GIDNUMBER)[0], grpLst))
- if not homedir:
- homedir = "/home/" + name
+ if not homedir:
+ homedir = "/home/" + name
- userEnt.set(libuser.HOMEDIRECTORY, homedir)
+ userEnt.set(libuser.HOMEDIRECTORY, homedir)
- if shell:
- userEnt.set(libuser.LOGINSHELL, shell)
+ if shell:
+ userEnt.set(libuser.LOGINSHELL, shell)
- if uid >= 0:
- userEnt.set(libuser.UIDNUMBER, uid)
+ if uid >= 0:
+ userEnt.set(libuser.UIDNUMBER, uid)
- self.admin.addUser(userEnt)
- self.admin.addGroup(groupEnt)
+ self.admin.addUser(userEnt)
+ self.admin.addGroup(groupEnt)
- if password:
- if isCrypted:
- self.admin.setpassUser(userEnt, password, isCrypted)
- else:
- self.admin.setpassUser(userEnt, cryptPassword(password, True), isCrypted)
+ if password:
+ if isCrypted:
+ self.admin.setpassUser(userEnt, password, isCrypted)
+ else:
+ self.admin.setpassUser(userEnt, cryptPassword(password, True), isCrypted)
- if lock:
- self.admin.lockUser(userEnt)
+ if lock:
+ self.admin.lockUser(userEnt)
- # Add the user to all the groups they should be part of.
- for grp in grpLst:
- grp.add(libuser.MEMBERNAME, name)
- self.admin.modifyGroup(grp)
+ # Add the user to all the groups they should be part of.
+ for grp in grpLst:
+ grp.add(libuser.MEMBERNAME, name)
+ self.admin.modifyGroup(grp)
- os._exit(0)
+ os._exit(0)
+ except Exception, e:
+ log.critical("Error when creating new user: %s" % str(e))
+ os._exit(1)
try:
(pid, status) = os.waitpid(childpid, 0)