|
|
|
@ -756,12 +756,11 @@ class cl_install(color_print):
|
|
|
|
|
def setInstallOptions(self, listDisks, listBinds, listSwaps, listUsers):
|
|
|
|
|
"""Set data for installation partitions"""
|
|
|
|
|
if listUsers:
|
|
|
|
|
migrateUsers = self.clVars.Get('cl_migrate_user')
|
|
|
|
|
migrateUsers = list(set(listUsers)|\
|
|
|
|
|
set(filter(lambda x: x=="root", migrateUsers)))
|
|
|
|
|
migrateUsers = list(set(listUsers))
|
|
|
|
|
migrateUsers.sort()
|
|
|
|
|
migrateUsers = ["root"] + filter(lambda x: x!="root", migrateUsers)
|
|
|
|
|
self.clVars.Set('cl_migrate_user', migrateUsers, force=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
convObj = convertDictOpt(self.clVars)
|
|
|
|
|
try:
|
|
|
|
|
listDisks = map(convObj, listDisks)
|
|
|
|
@ -1128,22 +1127,32 @@ class cl_install(color_print):
|
|
|
|
|
return title, headerList, zip(self.clVars.Get('os_install_bind_dir'),
|
|
|
|
|
self.clVars.Get('os_install_bind_mountpoint'))
|
|
|
|
|
|
|
|
|
|
def getPwdHashUser(self, userName):
|
|
|
|
|
cl_overriding.printSUCCESS(_("Enter password for user %s") %userName)
|
|
|
|
|
try:
|
|
|
|
|
userPwd = getUserPassword()
|
|
|
|
|
while userPwd is False:
|
|
|
|
|
if get_install_errors():
|
|
|
|
|
for line in filter(lambda x:x,
|
|
|
|
|
pop_install_errors().split('\n')):
|
|
|
|
|
self.printERROR(line)
|
|
|
|
|
def getPwdHashUser(self, userName, stdinRead=False):
|
|
|
|
|
if stdinRead:
|
|
|
|
|
try:
|
|
|
|
|
userPwd = sys.stdin.readline().rstrip()
|
|
|
|
|
except EOFError:
|
|
|
|
|
raise KeyboardInterrupt()
|
|
|
|
|
else:
|
|
|
|
|
cl_overriding.printSUCCESS(_("Enter password for user %s")%userName)
|
|
|
|
|
try:
|
|
|
|
|
userPwd = getUserPassword()
|
|
|
|
|
except EOFError:
|
|
|
|
|
raise KeyboardInterrupt()
|
|
|
|
|
while userPwd is False:
|
|
|
|
|
if get_install_errors():
|
|
|
|
|
for line in filter(lambda x:x,
|
|
|
|
|
pop_install_errors().split('\n')):
|
|
|
|
|
self.printERROR(line)
|
|
|
|
|
userPwd = getUserPassword()
|
|
|
|
|
except EOFError:
|
|
|
|
|
raise KeyboardInterrupt()
|
|
|
|
|
encryptObj = encrypt()
|
|
|
|
|
if not userPwd:
|
|
|
|
|
raise InstallError(_("Unable to find the password for user %s")\
|
|
|
|
|
%userName)
|
|
|
|
|
return False
|
|
|
|
|
pwdHash = encryptObj.getHashPasswd(userPwd, "shadow_ssha256")
|
|
|
|
|
if pwdHash is False:
|
|
|
|
|
return False
|
|
|
|
|
raise InstallError()
|
|
|
|
|
return pwdHash
|
|
|
|
|
|
|
|
|
|
def getNamesAddUsers(self):
|
|
|
|
@ -1160,21 +1169,21 @@ class cl_install(color_print):
|
|
|
|
|
zip(self.clVars.Get("cl_migrate_user"),
|
|
|
|
|
self.clVars.Get("cl_migrate_user_pwd"))))
|
|
|
|
|
|
|
|
|
|
def generateHashUsers(self):
|
|
|
|
|
def generateHashUsers(self, stdinRead=False):
|
|
|
|
|
"""Generate pwd hash from users"""
|
|
|
|
|
addUsers = self.getNamesAddUsers()
|
|
|
|
|
users = filter(lambda x: x!="root", addUsers)
|
|
|
|
|
listAddUsers = []
|
|
|
|
|
for user in users:
|
|
|
|
|
hashPwd = self.getPwdHashUser(user)
|
|
|
|
|
hashPwd = self.getPwdHashUser(user, stdinRead)
|
|
|
|
|
listAddUsers.append((user, hashPwd))
|
|
|
|
|
return listAddUsers
|
|
|
|
|
|
|
|
|
|
def generateHashRoot(self):
|
|
|
|
|
def generateHashRoot(self, stdinRead=False):
|
|
|
|
|
"""Generate pwd hash from root"""
|
|
|
|
|
addUsers = self.getNamesAddUsers()
|
|
|
|
|
if filter(lambda x: x=="root", addUsers):
|
|
|
|
|
hashPwd = self.getPwdHashUser("root")
|
|
|
|
|
hashPwd = self.getPwdHashUser("root", stdinRead)
|
|
|
|
|
return [("root", hashPwd,"","")]
|
|
|
|
|
else:
|
|
|
|
|
return []
|
|
|
|
@ -1310,13 +1319,22 @@ class cl_install(color_print):
|
|
|
|
|
#if not self.clVars.WriteVars(header="install"):
|
|
|
|
|
# raise InstallError(self.getError())
|
|
|
|
|
|
|
|
|
|
def installSystem(self, force=False, bootDisk=None):
|
|
|
|
|
def installSystem(self, force=False, bootDisk=None, stdinReadPwd=False):
|
|
|
|
|
"""install System by current variable enviroment"""
|
|
|
|
|
sourceDistr = None
|
|
|
|
|
targetDistr = None
|
|
|
|
|
error = None
|
|
|
|
|
distrCopy = False
|
|
|
|
|
try:
|
|
|
|
|
# error in stdin
|
|
|
|
|
#if not stdinReadPwd:
|
|
|
|
|
#import StringIO
|
|
|
|
|
#sys.stdin = StringIO.StringIO()
|
|
|
|
|
#sys.stdin.write("no")
|
|
|
|
|
#print sys.stdin.read()
|
|
|
|
|
#sys.stdin.close()
|
|
|
|
|
#if textStdin:
|
|
|
|
|
#raise InstallError("incorrect stdin '%s'"%textStdin)
|
|
|
|
|
rootPartdev = self.clVars.Get('os_install_root_dev')
|
|
|
|
|
rootPartCmdList = filter(lambda x: x['dev']==rootPartdev,
|
|
|
|
|
self.listDisksOptions)
|
|
|
|
@ -1360,15 +1378,10 @@ the system") + " (yes/no)"
|
|
|
|
|
elif dialogRes is False:
|
|
|
|
|
return True
|
|
|
|
|
# set Users passwords
|
|
|
|
|
changePwdUsers = self.generateHashRoot()
|
|
|
|
|
addUsers = self.generateHashUsers()
|
|
|
|
|
changePwdUsers = self.generateHashRoot(stdinRead=stdinReadPwd)
|
|
|
|
|
addUsers = self.generateHashUsers(stdinRead=stdinReadPwd)
|
|
|
|
|
migrateUsers = self.getNamesMigrateUsers()
|
|
|
|
|
#self.wait(waittime)
|
|
|
|
|
# cmd options
|
|
|
|
|
#self.listDisksOptions
|
|
|
|
|
#self.listBindsOptions
|
|
|
|
|
#self.listSwapsOptions
|
|
|
|
|
|
|
|
|
|
noRootPartDisksOptions = filter(lambda x: x['mountPoint']!="/",
|
|
|
|
|
self.listDisksOptions)
|
|
|
|
|
flagMultipartition = False
|
|
|
|
@ -1464,6 +1477,8 @@ the system") + " (yes/no)"
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
except (EOFError), e:
|
|
|
|
|
error = e
|
|
|
|
|
|
|
|
|
|
except (InstallError,DistributiveError),e:
|
|
|
|
|
error = e
|
|
|
|
|