Renamed cl_migrate_users_change_pwd to cl_migrate_user_pwd and cl_migrate_users to cl_migrate_user

netsetup
Самоукин Алексей 14 years ago
parent a6b6bc2f13
commit dc976a5d2a

@ -901,7 +901,7 @@ class fillVars(object, glob_attr):
reGrubEntry.findall(grubconf)))).strip()
return ""
def get_cl_migrate_users(self):
def get_cl_migrate_user(self):
"""migrate users"""
retList = []
fileName = "/etc/passwd"
@ -919,33 +919,35 @@ class fillVars(object, glob_attr):
retList = ["root"] +map(lambda x: x[0], userData)
return retList
def get_cl_migrate_users_change_pwd(self):
def get_cl_migrate_user_pwd(self):
retList = []
fileName = "/etc/shadow"
if access(fileName, R_OK):
migrateusers = self.Get("cl_migrate_users")
lenData=9
shadowData = filter(lambda x: len(x)==lenData,
map(lambda x: x.rstrip().split(":"),
open(fileName)))
shadowData = filter(lambda x: x[0] in migrateusers, shadowData)
shadowData = map(lambda x: (x[0], x[1]), shadowData)
shadowUsers = map(lambda x: x[0], shadowData)
for userName in migrateusers:
if userName in ("root"):
if userName in shadowUsers:
userData = filter(lambda x: x[0]==userName, shadowData)
hashPwd = userData[0][1]
salt = "".join(hashPwd.rpartition("$")[:1])
if salt and crypt(userName, salt) == hashPwd:
retList.append("Yes")
migrateusers = self.Get("cl_migrate_user")
if migrateusers:
lenData=9
shadowData = filter(lambda x: len(x)==lenData,
map(lambda x: x.rstrip().split(":"),
open(fileName)))
shadowData = filter(lambda x: x[0] in migrateusers, shadowData)
shadowData = map(lambda x: (x[0], x[1]), shadowData)
shadowUsers = map(lambda x: x[0], shadowData)
for userName in migrateusers:
if userName in ("root"):
if userName in shadowUsers:
userData = filter(lambda x: x[0]==userName,
shadowData)
hashPwd = userData[0][1]
salt = "".join(hashPwd.rpartition("$")[:1])
if salt and crypt(userName, salt) == hashPwd:
retList.append("yes")
else:
retList.append("no")
else:
retList.append("No")
retList.append("yes")
else:
retList.append("Yes")
else:
if userName in shadowUsers:
retList.append("No")
else:
retList.append("Yes")
if userName in shadowUsers:
retList.append("no")
else:
retList.append("yes")
return retList

@ -738,8 +738,15 @@ class cl_install(color_print):
zip(self.clVars.Get('os_install_bind_dir'),
self.clVars.Get('os_install_bind_mountpoint'))))
def setInstallOptions(self, listDisks, listBinds, listSwaps):
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(migrateUsers))
migrateUsers.sort()
self.clVars.Set('cl_migrate_user', migrateUsers, force=True)
convObj = convertDictOpt(self.clVars)
try:
listDisks = map(convObj, listDisks)

@ -244,7 +244,8 @@ class install_cmd(share_cmd):
self.setLinuxName(options.s.upper())
return True
def checkAndSetInstallOptions(self,diskOptions, swapOptions, bindOptions):
def checkAndSetInstallOptions(self,diskOptions, swapOptions, bindOptions,
usersOptions):
"""Check and set disk, swap and bind cmd options"""
listDiskOptions = []
listBindOptions = []
@ -262,7 +263,7 @@ class install_cmd(share_cmd):
if listSwapOptions is False:
return False
if not self.logicObj.setInstallOptions(listDiskOptions, listBindOptions,
listSwapOptions):
listSwapOptions, usersOptions):
return False
return True

@ -266,7 +266,7 @@ class Data:
os_grub_conf = {}
# migrate users
cl_migrate_users = {}
cl_migrate_user = {}
# migrate users who need to change passwords
cl_migrate_users_change_pwd = {}
cl_migrate_user_pwd = {}

@ -48,7 +48,8 @@ if __name__ == "__main__":
sys.exit(1)
# check and set installed options
if not options.live:
if not install.checkAndSetInstallOptions(options.d,options.w,options.b):
if not install.checkAndSetInstallOptions(options.d,options.w,options.b,
options.u):
sys.exit(1)
# print variables
if options.v or options.filter or options.xml:

Loading…
Cancel
Save