|
|
|
@ -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
|
|
|
|
|