summaryrefslogtreecommitdiffstats
path: root/users.py
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2007-06-07 17:32:34 +0000
committerChris Lumens <clumens@redhat.com>2007-06-07 17:32:34 +0000
commit287401bdae1a48f900cadd4048e185ea46781734 (patch)
tree22dcb2ab43da0ae54b5b72740e513d4038be4e83 /users.py
parentdc97e9b70e553ef8cde6c926279e2e67de0bde2c (diff)
downloadanaconda-287401bdae1a48f900cadd4048e185ea46781734.tar.gz
anaconda-287401bdae1a48f900cadd4048e185ea46781734.tar.xz
anaconda-287401bdae1a48f900cadd4048e185ea46781734.zip
Lock accounts if asked (#240059).
Diffstat (limited to 'users.py')
-rw-r--r--users.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/users.py b/users.py
index a9a4c251b..b4b29a3e3 100644
--- a/users.py
+++ b/users.py
@@ -3,7 +3,7 @@
#
# Chris Lumens <clumens@redhat.com>
#
-# Copyright (c) 2006 Red Hat, Inc.
+# Copyright (c) 2006, 2007 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# general public license.
@@ -39,7 +39,6 @@ directory = %(instPath)s/etc
os.close(fd)
os.environ["LIBUSER_CONF"] = fn
-
def cryptPassword(password, useMD5):
if useMD5:
@@ -60,7 +59,8 @@ class Users:
self.admin = libuser.admin()
def createUser (self, name, password=None, isCrypted=False, groups=[],
- homedir=None, shell=None, uid=None, root="/mnt/sysimage"):
+ homedir=None, shell=None, uid=None, lock=False,
+ root="/mnt/sysimage"):
if self.admin.lookupUserByName(name):
return None
@@ -98,11 +98,14 @@ class Users:
else:
self.admin.setpassUser(userEnt, cryptPassword(password, True), isCrypted)
+ if lock:
+ self.admin.lockUser(userEnt)
+
# Now set the correct home directory to fix up passwd.
userEnt.set(libuser.HOMEDIRECTORY, homedir)
self.admin.modifyUser(userEnt)
- def setRootPassword(self, password, isCrypted, useMD5):
+ def setRootPassword(self, password, isCrypted, useMD5, lock):
rootUser = self.admin.lookupUserByName("root")
if isCrypted:
@@ -110,4 +113,7 @@ class Users:
else:
self.admin.setpassUser(rootUser, cryptPassword(password, useMD5), True)
+ if lock:
+ self.admin.lockUser(rootUser)
+
self.admin.modifyUser(rootUser)