summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian C. Lane <bcl@redhat.com>2012-09-07 21:36:23 -0700
committerBrian C. Lane <bcl@redhat.com>2012-09-09 11:25:27 -0700
commitf1396352f23f97b8d6036f9893df67469418fec4 (patch)
tree649ee766c8ef96c011fd084219c207499c32f32b
parentcf85d16001808013022343d5022b4b0e040dd12a (diff)
downloadanaconda-f1396352f23f97b8d6036f9893df67469418fec4.tar.gz
anaconda-f1396352f23f97b8d6036f9893df67469418fec4.tar.xz
anaconda-f1396352f23f97b8d6036f9893df67469418fec4.zip
fix root password setup (#855481)
libuser checks the LIBUSER_CONF environmental variable and uses the temporary config file it points to, but in order for this to work it must be set before User() is run.
-rw-r--r--pyanaconda/install.py4
-rw-r--r--pyanaconda/kickstart.py7
-rw-r--r--pyanaconda/users.py31
3 files changed, 24 insertions, 18 deletions
diff --git a/pyanaconda/install.py b/pyanaconda/install.py
index 982ffc424..7fe93632a 100644
--- a/pyanaconda/install.py
+++ b/pyanaconda/install.py
@@ -24,7 +24,7 @@ from pyanaconda.constants import ROOT_PATH
from pyanaconda.storage import turnOnFilesystems
from pyanaconda.bootloader import writeBootLoader
from pyanaconda.progress import progress_report
-from pyanaconda.users import createLuserConf, Users
+from pyanaconda.users import createLuserConf, getPassAlgo, Users
from pyanaconda.network import writeNetworkConf
import gettext
@@ -93,8 +93,8 @@ def doInstall(storage, payload, ksdata, instClass):
writeNetworkConf(storage, ksdata, instClass)
# Creating users and groups requires some pre-configuration.
+ createLuserConf(ROOT_PATH, algoname=getPassAlgo(ksdata.authconfig.authconfig))
u = Users()
- createLuserConf(ROOT_PATH, algoname=u.getPassAlgo(ksdata.authconfig.authconfig))
ksdata.rootpw.execute(storage, ksdata, instClass, u)
ksdata.group.execute(storage, ksdata, instClass, u)
ksdata.user.execute(storage, ksdata, instClass, u)
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index c5154f769..fff0ff25c 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -52,6 +52,7 @@ from pyanaconda import ntp
from pyanaconda import timezone
from pyanaconda import localization
from pyanaconda.simpleconfig import SimpleConfigFile
+from pyanaconda.users import getPassAlgo
from pykickstart.base import KickstartCommand
from pykickstart.constants import *
@@ -469,7 +470,7 @@ class Firstboot(commands.firstboot.FC3_Firstboot):
class Group(commands.group.F12_Group):
def execute(self, storage, ksdata, instClass, users):
- algo = users.getPassAlgo(ksdata.authconfig.authconfig)
+ algo = getPassAlgo(ksdata.authconfig.authconfig)
for grp in self.groupList:
kwargs = grp.__dict__
@@ -1224,7 +1225,7 @@ class RaidData(commands.raid.F15_RaidData):
class RootPw(commands.rootpw.F18_RootPw):
def execute(self, storage, ksdata, instClass, users):
- algo = users.getPassAlgo(ksdata.authconfig.authconfig)
+ algo = getPassAlgo(ksdata.authconfig.authconfig)
users.setRootPassword(self.password, self.isCrypted, self.lock, algo)
class SELinux(commands.selinux.FC3_SELinux):
@@ -1282,7 +1283,7 @@ class Timezone(commands.timezone.F18_Timezone):
class User(commands.user.F12_User):
def execute(self, storage, ksdata, instClass, users):
- algo = users.getPassAlgo(ksdata.authconfig.authconfig)
+ algo = getPassAlgo(ksdata.authconfig.authconfig)
for usr in self.userList:
kwargs = usr.__dict__
diff --git a/pyanaconda/users.py b/pyanaconda/users.py
index 6a9e2b9d5..c10dd4ade 100644
--- a/pyanaconda/users.py
+++ b/pyanaconda/users.py
@@ -33,7 +33,11 @@ import logging
log = logging.getLogger("anaconda")
def createLuserConf(instPath, algoname='sha512'):
- """Writes a libuser.conf for instPath."""
+ """ Writes a libuser.conf for instPath.
+
+ This must be called before User() is instantiated the first time
+ so that libuser.admin will use the temporary config file.
+ """
createTmp = False
try:
fn = os.environ["LIBUSER_CONF"]
@@ -71,6 +75,19 @@ directory = %(instPath)s/etc
return fn
+def getPassAlgo(authconfigStr):
+ """ Reads the auth string and returns a string indicating our desired
+ password encoding algorithm.
+ """
+ if authconfigStr.find("--enablemd5") != -1 or authconfigStr.find("--passalgo=md5") != -1:
+ return 'md5'
+ elif authconfigStr.find("--passalgo=sha256") != -1:
+ return 'sha256'
+ elif authconfigStr.find("--passalgo=sha512") != -1:
+ return 'sha512'
+ else:
+ return None
+
# These are explained in crypt/crypt-entry.c in glibc's code. The prefixes
# we use for the different crypt salts:
# $1$ MD5
@@ -269,18 +286,6 @@ class Users:
else:
return False
- # Reads the auth string and returns a string indicating our desired
- # password encoding algorithm.
- def getPassAlgo(self, authconfigStr):
- if authconfigStr.find("--enablemd5") != -1 or authconfigStr.find("--passalgo=md5") != -1:
- return 'md5'
- elif authconfigStr.find("--passalgo=sha256") != -1:
- return 'sha256'
- elif authconfigStr.find("--passalgo=sha512") != -1:
- return 'sha512'
- else:
- return None
-
def setUserPassword(self, username, password, isCrypted, lock, algo=None):
user = self.admin.lookupUserByName(username)