|
|
|
@ -279,6 +279,7 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
self.progName = { 'cl-client':0,
|
|
|
|
|
'cl-createhome':1,
|
|
|
|
|
'cl-sync':2,
|
|
|
|
|
'cl-passwd':3
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Cвязь длинных опций помощи и выводимых разделов помощи с опциями
|
|
|
|
@ -318,6 +319,11 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
'helpChapter':_("Usage"),
|
|
|
|
|
'help': cmdName + " [" + _("options") + "] " + _("user")
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'progAccess':(3,),
|
|
|
|
|
'helpChapter':_("Usage"),
|
|
|
|
|
'help': cmdName
|
|
|
|
|
},
|
|
|
|
|
# Function
|
|
|
|
|
{
|
|
|
|
|
'progAccess':(0,),
|
|
|
|
@ -335,6 +341,11 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
'helpChapter':"Function",
|
|
|
|
|
'help':_("Mounting resources and synchronize the user preferences")
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'progAccess':(3,),
|
|
|
|
|
'helpChapter':"Function",
|
|
|
|
|
'help':_("Change user password")
|
|
|
|
|
},
|
|
|
|
|
# Examples
|
|
|
|
|
{
|
|
|
|
|
'progAccess':(0,),
|
|
|
|
@ -344,6 +355,13 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
" (ip 192.168.0.1)",
|
|
|
|
|
self.consolewidth-self.column_width )
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'progAccess':(3,),
|
|
|
|
|
'helpChapter':_("Examples"),
|
|
|
|
|
'help':pcs(" cl-passwd", self.column_width,
|
|
|
|
|
"# "+_("change password of user for Samba and Unix services")+".",
|
|
|
|
|
self.consolewidth-self.column_width)
|
|
|
|
|
},
|
|
|
|
|
# Options
|
|
|
|
|
{'shortOption':"h",
|
|
|
|
|
'longOption':"help",
|
|
|
|
@ -366,13 +384,13 @@ class cl_client(imp_cl_err, imp_cl_xml, imp_cl_help, imp_cl_smcon):
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("show progress bar for kde startup")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(0,1,2),
|
|
|
|
|
{'progAccess':(0,1,2,3),
|
|
|
|
|
'longOption':"vars",
|
|
|
|
|
'optVal':_("TYPE_VAR"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("print variables (TYPE_VAR - all:full var)")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(0,1,2),
|
|
|
|
|
{'progAccess':(0,1,2,3),
|
|
|
|
|
'longOption':"color",
|
|
|
|
|
'optVal':_("WHEN"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
@ -419,13 +437,12 @@ if necessary, removes from domain")
|
|
|
|
|
'help':_("not synchronize the user preferences, is used in \
|
|
|
|
|
conjunction with the 'login' or 'logout'")
|
|
|
|
|
},
|
|
|
|
|
#{'progAccess':(0,),
|
|
|
|
|
#'shortOption':"p",
|
|
|
|
|
#'longOption':"prvar",
|
|
|
|
|
#'optVal':_("TYPES_VAR"),
|
|
|
|
|
#'helpChapter':_("Common options"),
|
|
|
|
|
#'help':_("print variable (filter type - comma delimited)")
|
|
|
|
|
#},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"P",
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("use password for the user account") +\
|
|
|
|
|
" (" + _("from standard input") + ")"
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
@ -484,6 +501,35 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
# Имя пользователя
|
|
|
|
|
self.userName = ""
|
|
|
|
|
|
|
|
|
|
def getUserPwd(self, options, optDialog, optStdIn, pwDialog=False):
|
|
|
|
|
"""Получить пароль у пользователя
|
|
|
|
|
|
|
|
|
|
options - полученные опции командной строки
|
|
|
|
|
optDialog - опция командной строки для вывода диалога для получения
|
|
|
|
|
пароля
|
|
|
|
|
optStdIn - опция командной строки для получения пароля из
|
|
|
|
|
стандартного ввода (stdin)
|
|
|
|
|
pwDialog - структура для вывода приглашения в режиме диалога
|
|
|
|
|
"""
|
|
|
|
|
userPwd = ""
|
|
|
|
|
if optStdIn and options.has_key(optStdIn):
|
|
|
|
|
pwdA = sys.stdin.readline().rstrip()
|
|
|
|
|
pwdB = sys.stdin.readline().rstrip()
|
|
|
|
|
elif optDialog and options.has_key(optDialog):
|
|
|
|
|
if not pwDialog:
|
|
|
|
|
pwDialog = [_("New password"),
|
|
|
|
|
_("Retype new password")]
|
|
|
|
|
pwdA = getpass.getpass(pwDialog[0]+":")
|
|
|
|
|
pwdB = getpass.getpass(pwDialog[1]+":")
|
|
|
|
|
if (optStdIn and options.has_key(optStdIn)) or\
|
|
|
|
|
(optDialog and options.has_key(optDialog)):
|
|
|
|
|
if not pwdA or not (pwdA == pwdB):
|
|
|
|
|
self.printERROR (_("ERROR") + ": " +\
|
|
|
|
|
_("password incorrect")+ ": " + _("try again"))
|
|
|
|
|
return False
|
|
|
|
|
userPwd = pwdA
|
|
|
|
|
return userPwd
|
|
|
|
|
|
|
|
|
|
def exit(self, exitCode):
|
|
|
|
|
"""Метод выхода при ошибке"""
|
|
|
|
|
self.errorExit()
|
|
|
|
@ -499,12 +545,13 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
"""Выполняется при удалении объекта"""
|
|
|
|
|
self.errorExit()
|
|
|
|
|
|
|
|
|
|
def isRoot(self):
|
|
|
|
|
def isRoot(self, printError=True):
|
|
|
|
|
"""Определяет является ли пользователь root"""
|
|
|
|
|
if os.getuid() == 0 and os.getgid() == 0:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("The user is not root"))
|
|
|
|
|
if printError:
|
|
|
|
|
self.printERROR(_("The user is not root"))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -709,6 +756,38 @@ conjunction with the 'login' or 'logout'")
|
|
|
|
|
else:
|
|
|
|
|
return dirsFiles
|
|
|
|
|
|
|
|
|
|
def setUserPasswordToServer(self, options):
|
|
|
|
|
"""Установка пароля пользователя на сервере"""
|
|
|
|
|
# Проверяем на root
|
|
|
|
|
if self.isRoot(False):
|
|
|
|
|
self.printERROR(_("The user is root"))
|
|
|
|
|
self.printWARNING(\
|
|
|
|
|
_("The program can be executed from a non-root user"))
|
|
|
|
|
return False
|
|
|
|
|
# Создаем объект переменных
|
|
|
|
|
self.createClVars()
|
|
|
|
|
optPasswd = options
|
|
|
|
|
if not options:
|
|
|
|
|
optPasswd = {"p":""}
|
|
|
|
|
password = self.getUserPwd(optPasswd, "p", "P")
|
|
|
|
|
if password == False:
|
|
|
|
|
return False
|
|
|
|
|
# Записываем пароль пользователя в переменную
|
|
|
|
|
self.clVars.Set("ur_pw", password)
|
|
|
|
|
oldEnvPath = self.clVars.Get("cl_env_path")
|
|
|
|
|
fileEnvPath = os.path.join(os.environ["HOME"],".calculate.env")
|
|
|
|
|
newEnvPath = [fileEnvPath]*3
|
|
|
|
|
self.clVars.Set("cl_env_path",newEnvPath,True)
|
|
|
|
|
# Переменные для записи в env файл
|
|
|
|
|
namesVars = ["ur_unix_hash","ur_samba_lm_hash","ur_samba_nt_hash"]
|
|
|
|
|
data = map(lambda x: (x,self.clVars.Get(x)), namesVars)
|
|
|
|
|
for name, value in data:
|
|
|
|
|
self.clVars.Write(name, value, True, "default","server")
|
|
|
|
|
self.clVars.Set("cl_env_path",oldEnvPath,True)
|
|
|
|
|
self.printOK(_("Password changed in user %s")%os.environ["USER"] + \
|
|
|
|
|
" ...")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def getUserPassword(self, pwDialog=False):
|
|
|
|
|
"""Получить пароль у пользователя
|
|
|
|
|
|
|
|
|
@ -1359,7 +1438,8 @@ or ld_bind_dn or ld_bind_pw")
|
|
|
|
|
|
|
|
|
|
def removePrivateFiles(self, userHome):
|
|
|
|
|
"""Удаление приватных файлов"""
|
|
|
|
|
privateFiles = ['.kde4/share/apps/kwallet/kdewallet.kwl']
|
|
|
|
|
privateFiles = ['.kde4/share/apps/kwallet/kdewallet.kwl',
|
|
|
|
|
'.calculate.env']
|
|
|
|
|
for prFile in privateFiles:
|
|
|
|
|
rmFile = os.path.join(userHome, prFile)
|
|
|
|
|
if os.path.exists(rmFile):
|
|
|
|
@ -2238,6 +2318,7 @@ or ld_bind_dn or ld_bind_pw")
|
|
|
|
|
--exclude="/.local/share/mime/mime.cache" \
|
|
|
|
|
--exclude="/.kde4/share/apps/nepomuk/repository/main/data" \
|
|
|
|
|
--exclude="/.logout" \
|
|
|
|
|
--exclude="/.calculate.env" \
|
|
|
|
|
--exclude="/.Xauthority" \
|
|
|
|
|
--filter="P /.googleearth" --filter="P /Home" --filter="P /Disks" \
|
|
|
|
|
--filter="P /.local/share/akonadi/db_data" --filter="P /.VirtualBox" \
|
|
|
|
@ -2245,6 +2326,7 @@ or ld_bind_dn or ld_bind_pw")
|
|
|
|
|
--filter="P /.local/share/mime/mime.cache" \
|
|
|
|
|
--filter="P /.kde4/share/apps/nepomuk/repository/main/data" \
|
|
|
|
|
--filter="P /.logout" \
|
|
|
|
|
--filter="P /.calculate.env" \
|
|
|
|
|
--filter="P /.Xauthority" \
|
|
|
|
|
--filter="P /FTP" -a -x -v -v -v -v %s/ %s/' %(homeProfile,userHome)
|
|
|
|
|
elif sync == "logout":
|
|
|
|
@ -2345,8 +2427,9 @@ class tsOpt(cl_base.opt):
|
|
|
|
|
Параметры:
|
|
|
|
|
helpObj объект-справка содержащий необходимые опции
|
|
|
|
|
notOptError выдавать ошибку при отсутствии опций командной строки
|
|
|
|
|
optUser проверять хвост командной строки на наличие пользователя
|
|
|
|
|
"""
|
|
|
|
|
def __init__(self, helpObj, notOptError=False):
|
|
|
|
|
def __init__(self, helpObj, notOptError=False, optUser=True):
|
|
|
|
|
# от cl_help получаем короткие и длинные опции
|
|
|
|
|
shortOpt,longOpt = helpObj.getAllOpt('all', helpObj.relOptions['h'])
|
|
|
|
|
# вызвать конструктор объекта, распознающего опции
|
|
|
|
@ -2368,12 +2451,8 @@ class tsOpt(cl_base.opt):
|
|
|
|
|
if len(helpopt) > 0:
|
|
|
|
|
print helpObj.getHelp(helpObj.relOptions[helpopt[0]])
|
|
|
|
|
self.flagHelp = True
|
|
|
|
|
#Если нет хвостов
|
|
|
|
|
#elif not self.params:
|
|
|
|
|
#print helpObj.getHelp(helpObj.relOptions['h'])
|
|
|
|
|
#self.flagHelp = True
|
|
|
|
|
else:
|
|
|
|
|
if self.params.has_key('user'):
|
|
|
|
|
if optUser and self.params.has_key('user'):
|
|
|
|
|
if len(self.nameParams) != self.__iter:
|
|
|
|
|
self.handlerErrOpt()
|
|
|
|
|
# В случае остсутствия опций командной строки и имени пользователя
|
|
|
|
@ -2381,7 +2460,13 @@ class tsOpt(cl_base.opt):
|
|
|
|
|
if not self.opt:
|
|
|
|
|
self.printErrorNotOpt()
|
|
|
|
|
self.flagHelp = True
|
|
|
|
|
elif not self.opt and not self.params.has_key('user'):
|
|
|
|
|
if optUser and not self.params.has_key('user'):
|
|
|
|
|
print helpObj.getHelp(helpObj.relOptions['h'])
|
|
|
|
|
self.flagHelp = True
|
|
|
|
|
elif optUser and not self.opt and not self.params.has_key('user'):
|
|
|
|
|
print helpObj.getHelp(helpObj.relOptions['h'])
|
|
|
|
|
self.flagHelp = True
|
|
|
|
|
if not optUser and self.params.has_key('user'):
|
|
|
|
|
print helpObj.getHelp(helpObj.relOptions['h'])
|
|
|
|
|
self.flagHelp = True
|
|
|
|
|
|
|
|
|
|