|
|
|
@ -73,8 +73,12 @@ org.kde.kdialog.ProgressDialog'
|
|
|
|
|
close_fds=True,
|
|
|
|
|
env=env, shell=True)
|
|
|
|
|
pipe.stdin.close()
|
|
|
|
|
if pipe.poll() != 0:
|
|
|
|
|
time.sleep(0.5)
|
|
|
|
|
if pipe.poll() == None:
|
|
|
|
|
# задержка полсекунды
|
|
|
|
|
for t in range(50):
|
|
|
|
|
time.sleep(0.01)
|
|
|
|
|
if pipe.poll() != None:
|
|
|
|
|
break
|
|
|
|
|
if pipe.poll() == 0:
|
|
|
|
|
self.kdialog = pipe.stdout.readline().strip()
|
|
|
|
|
while not "org.kde.kdialog" in self.kdialog:
|
|
|
|
@ -743,27 +747,22 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
os.lchown(linkCh[1], uid, gid)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def execProg(self, cmdStrProg, inStr=False, retFull=True):
|
|
|
|
|
def execProg(self, cmdStrProg, inStr=False, retFull=True, envProg={}):
|
|
|
|
|
"""Выполняет внешнюю программу
|
|
|
|
|
|
|
|
|
|
Параметры:
|
|
|
|
|
cmdStrProg внешняя программа
|
|
|
|
|
inStr данные передаваемые программе на страндартный вход.
|
|
|
|
|
Возвращаемые параметры:
|
|
|
|
|
строка которую выведет внешняя программа
|
|
|
|
|
строка которую выведет внешняя программа или False в случае ошибки
|
|
|
|
|
"""
|
|
|
|
|
return cl_utils.runOsCommand(cmdStrProg, inStr, retFull)
|
|
|
|
|
|
|
|
|
|
#def getUidAndGidUser(self, userName):
|
|
|
|
|
#strRes = self.execProg("id %s" %userName)
|
|
|
|
|
#reFind = re.compile("uid=(\d+)\(.+gid=(\d+)\(")
|
|
|
|
|
#res = reFind.search(strRes)
|
|
|
|
|
#if res:
|
|
|
|
|
#return res.group(1), res.group(2)
|
|
|
|
|
#else:
|
|
|
|
|
#self.printERROR(_("User %s not found")\
|
|
|
|
|
#%str(userName))
|
|
|
|
|
#return False
|
|
|
|
|
env_path = {"PATH":cl_utils.getpathenv()}
|
|
|
|
|
env = {}
|
|
|
|
|
env.update(os.environ.items() + env_path.items() + envProg.items())
|
|
|
|
|
retCode,programOut = cl_utils.runOsCommand(cmdStrProg,inStr,retFull,env)
|
|
|
|
|
if not retCode:
|
|
|
|
|
return programOut
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def getUserPasswdInfo(self, userName):
|
|
|
|
|
"""получаем uid и gid пользователя из /etc/passwd"""
|
|
|
|
@ -787,8 +786,7 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
"""Прописывает демона в автозагрузку"""
|
|
|
|
|
execStr = "rc-update add %s default" %daemon
|
|
|
|
|
textLine = self.execProg(execStr)
|
|
|
|
|
if "added to runlevel" in textLine or\
|
|
|
|
|
"already installed in runlevel" in textLine:
|
|
|
|
|
if textLine:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("ERROR") + ": " + execStr)
|
|
|
|
@ -799,12 +797,7 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
"""Удаляет демона из автозагрузки"""
|
|
|
|
|
execStr = "rc-update del %s default" %daemon
|
|
|
|
|
textLine = self.execProg(execStr)
|
|
|
|
|
if "removed from the following runlevels" in textLine or\
|
|
|
|
|
"not found in any of the specified runlevels" in textLine:
|
|
|
|
|
return True
|
|
|
|
|
#Для openrc
|
|
|
|
|
elif "removed from runlevel" in textLine or\
|
|
|
|
|
"is not in the runlevel" in textLine:
|
|
|
|
|
if textLine:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("ERROR") + ": " + execStr)
|
|
|
|
@ -901,6 +894,8 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
def killRsync(self):
|
|
|
|
|
"""Убивает все процессы rsync и cl-sync --login"""
|
|
|
|
|
listProcess = self.execProg("ps ax",False,False)
|
|
|
|
|
if not listProcess:
|
|
|
|
|
return False
|
|
|
|
|
killPid = []
|
|
|
|
|
flagError = False
|
|
|
|
|
for process in listProcess:
|
|
|
|
@ -1056,11 +1051,9 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
return False
|
|
|
|
|
if not os.path.exists(pathRemote):
|
|
|
|
|
os.makedirs(pathRemote)
|
|
|
|
|
#Экранируем символы
|
|
|
|
|
escPwdRemote = re.sub("(\W)", r"\\\1",pwdRemote)
|
|
|
|
|
mountStr = "PASSWD=%s mount -t cifs -o user=client \
|
|
|
|
|
//%s/remote %s" %(escPwdRemote,domain,pathRemote)
|
|
|
|
|
textLine = self.execProg(mountStr)
|
|
|
|
|
mountStr = "mount -t cifs -o user=client //%s/remote %s"\
|
|
|
|
|
%(domain,pathRemote)
|
|
|
|
|
textLine = self.execProg(mountStr, None, True, {"PASSWD":pwdRemote})
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printWARNING(_("Can not mount Samba resource [%s]")%\
|
|
|
|
|
"remote" + " ...")
|
|
|
|
@ -1230,7 +1223,11 @@ manager") + " ..."
|
|
|
|
|
domain = domainName
|
|
|
|
|
else:
|
|
|
|
|
domain = "%s.%s" %(domainName,netDomain)
|
|
|
|
|
resPing = self.execProg("ping -c 2 -i 0.3 %s" %domain,False,False)
|
|
|
|
|
execStr = "ping -c 2 -i 0.3 %s" %domain
|
|
|
|
|
resPing = self.execProg(execStr, False, False)
|
|
|
|
|
if not resPing:
|
|
|
|
|
self.printERROR(_('Can not execute "%s"')%execStr)
|
|
|
|
|
return False
|
|
|
|
|
foudHost = False
|
|
|
|
|
foudHostSamba = False
|
|
|
|
|
foundMountRemote = False
|
|
|
|
@ -1277,11 +1274,9 @@ manager") + " ..."
|
|
|
|
|
pwdRemote = userPwd
|
|
|
|
|
if not os.path.exists(pathRemote):
|
|
|
|
|
os.makedirs(pathRemote)
|
|
|
|
|
# Экранируем символы
|
|
|
|
|
escPwdRemote = re.sub("(\W)", r"\\\1",pwdRemote)
|
|
|
|
|
mountStr = "PASSWD=%s mount -t cifs -o user=client \
|
|
|
|
|
//%s/remote %s" %(escPwdRemote,domain,pathRemote)
|
|
|
|
|
textLine = self.execProg(mountStr)
|
|
|
|
|
mountStr = "mount -t cifs -o user=client //%s/remote %s"\
|
|
|
|
|
%(domain,pathRemote)
|
|
|
|
|
textLine = self.execProg(mountStr, None, True, {"PASSWD":pwdRemote})
|
|
|
|
|
if not (textLine == None):
|
|
|
|
|
self.printERROR(_("Can not mount Samba resource [%s]")%\
|
|
|
|
|
"remote" + " ...")
|
|
|
|
@ -1655,21 +1650,18 @@ or ld_bind_dn or ld_bind_pw")
|
|
|
|
|
def mountSambaRes(self,userName,userPwd,uid,gid,res,path,
|
|
|
|
|
mountUidList=['ftp','share']):
|
|
|
|
|
"""Монтирует Samba ресурсы"""
|
|
|
|
|
#Экранируем символы
|
|
|
|
|
escUserPwd = re.sub("(\W)", r"\\\1",userPwd)
|
|
|
|
|
if res in mountUidList:
|
|
|
|
|
# Монтируем директории c uid
|
|
|
|
|
mountStr="PASSWD=%s mount -t cifs -o user=%s,uid=%s,gid=%s"\
|
|
|
|
|
%(escUserPwd,userName,uid,gid) +\
|
|
|
|
|
mountStr="mount -t cifs -o user=%s,uid=%s,gid=%s"\
|
|
|
|
|
%(userName,uid,gid) +\
|
|
|
|
|
" //%s/%s %s" %(self.clVars.Get("cl_remote_host"),
|
|
|
|
|
res, path)
|
|
|
|
|
else:
|
|
|
|
|
# Монтируем директории
|
|
|
|
|
mountStr="PASSWD=%s mount -t cifs -o user=%s"%(escUserPwd,
|
|
|
|
|
userName)+\
|
|
|
|
|
mountStr="mount -t cifs -o user=%s"%(userName)+\
|
|
|
|
|
" //%s/%s %s" %(self.clVars.Get("cl_remote_host"),
|
|
|
|
|
res, path)
|
|
|
|
|
textLine = self.execProg(mountStr)
|
|
|
|
|
textLine = self.execProg(mountStr, None, True, {"PASSWD":userPwd})
|
|
|
|
|
return textLine
|
|
|
|
|
|
|
|
|
|
def removeDir(self, rmDirOrScanObjs):
|
|
|
|
|