[f19-branch/master] Create user account with no password (#968915)

Brian C. Lane bcl at redhat.com
Tue Jun 4 15:44:50 UTC 2013


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

This is a dangerous feature, but gdm depends on it for its passwordless
login 'feature'. If the password is set to "" it will unlock the user
account. Note that only "" will work -- if it is set to None or False it
will create a locked account.
---
 pyanaconda/users.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/pyanaconda/users.py b/pyanaconda/users.py
index 212184b..c704b33 100644
--- a/pyanaconda/users.py
+++ b/pyanaconda/users.py
@@ -230,6 +230,9 @@ class Users:
            lock      -- Is the new account locked by default?  Defaults to
                         False.
            password  -- The password.  See isCrypted for how this is interpreted.
+                        If the password is "" then the account is created
+                        with a blank password. If None or False the account will
+                        be left in its initial state (locked)
            root      -- The directory of the system to create the new user
                         in.  homedir will be interpreted relative to this.
                         Defaults to /mnt/sysimage.
@@ -283,16 +286,22 @@ class Users:
                 self.admin.addUser(userEnt, mkmailspool=kwargs.get("mkmailspool", True))
                 self.admin.addGroup(groupEnt)
 
-                if kwargs.get("password", False):
+                pw = kwargs.get("password", False)
+                if pw:
                     if kwargs.get("isCrypted", False):
                         password = kwargs["password"]
                     else:
                         password = cryptPassword(kwargs["password"], algo=kwargs.get("algo", None))
-
                     self.admin.setpassUser(userEnt, password, True)
+                elif pw == "":
+                    # Setup the account with *NO* password
+                    self.admin.unlockUser(userEnt)
+                    log.info("user account %s setup with no password" % user_name)
 
                 if kwargs.get("lock", False):
                     self.admin.lockUser(userEnt)
+                    log.info("user account %s locked" % user_name)
+
 
                 # Add the user to all the groups they should be part of.
                 grpLst.append(self.admin.lookupGroupByName(user_name))
-- 
1.8.1.4



More information about the anaconda-patches mailing list