Added template variables cl_migrate_users cl_migrate_users_change_pwd

master3.3
Самоукин Алексей 14 years ago
parent 12ce30083c
commit e15d9325be

@ -16,6 +16,7 @@
import os
import re
from crypt import crypt
import cl_overriding
from cl_datavars import glob_attr
from os.path import join as pathjoin, exists as pathexists
@ -899,3 +900,52 @@ class fillVars(object, glob_attr):
return ("".join(filter(lambda x: not roothd in x,
reGrubEntry.findall(grubconf)))).strip()
return ""
def get_cl_migrate_users(self):
"""migrate users"""
retList = []
fileName = "/etc/passwd"
if access(fileName, R_OK):
maxId = 65000
minId = 500
reNumb = re.compile("^\d+$")
lenData=7
userData = filter(lambda x: len(x)==lenData,
map(lambda x: x.rstrip().split(":"),
open(fileName)))
userData = filter(lambda x:\
reNumb.match(x[2]) and minId<=int(x[2])<=maxId,
userData)
retList = ["root"] +map(lambda x: x[0], userData)
return retList
def get_cl_migrate_users_change_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")
else:
retList.append("No")
else:
retList.append("Yes")
else:
if userName in shadowUsers:
retList.append("No")
else:
retList.append("Yes")
return retList

@ -433,9 +433,12 @@ class currentUsers(migrate):
if not self.checkPermFiles():
return False
getDataInFile = _shareData().getDataInFile
self.dataUsers = getDataInFile(fileName=migrateUsers.filePasswd,lenData=7)
self.dataGroups = getDataInFile(fileName=migrateGroups.fileGroups,lenData=4)
self.dataShadow = getDataInFile(fileName=migrateShadow.fileShadow,lenData=9)
self.dataUsers = getDataInFile(fileName=migrateUsers.filePasswd,
lenData=7)
self.dataGroups = getDataInFile(fileName=migrateGroups.fileGroups,
lenData=4)
self.dataShadow = getDataInFile(fileName=migrateShadow.fileShadow,
lenData=9)
getHash = encrypt().getHashPasswd
for userName, pwd in zip(users_passwd[0::2],
users_passwd[1::2]):

@ -264,3 +264,9 @@ class Data:
# current grub
os_grub_conf = {}
# migrate users
cl_migrate_users = {}
# migrate users who need to change passwords
cl_migrate_users_change_pwd = {}

Loading…
Cancel
Save