|
|
|
@ -164,15 +164,15 @@ class cl_ldap(imp_cl_err, imp_cl_xml, imp_cl_par, imp_cl_con):
|
|
|
|
|
# расположение разделов на странице
|
|
|
|
|
# имя раздела, видимый или невидимый, кол. "\n" после
|
|
|
|
|
# названия раздела, кол. "\n" после раздела
|
|
|
|
|
("Copyright",False,0,2),
|
|
|
|
|
(_("Usage"),True,0,1),
|
|
|
|
|
("Function",False,0,2),
|
|
|
|
|
(_("Examples"),True,1,1),
|
|
|
|
|
(_("Options"),True,1,1),
|
|
|
|
|
(_("Service Ldap options"),True,1,1),
|
|
|
|
|
(_("Service Samba options"),True,1,1),
|
|
|
|
|
(_("Services"),True,1,1),
|
|
|
|
|
(_("Informative output"),True,1,0),
|
|
|
|
|
# тип раздела
|
|
|
|
|
("Copyright",False,0,2,""),
|
|
|
|
|
(_("Usage"),True,0,1,""),
|
|
|
|
|
("Function",False,0,2,""),
|
|
|
|
|
(_("Examples"),True,1,1,""),
|
|
|
|
|
(_("Common options"),True,1,1,"options"),
|
|
|
|
|
(_("Service LDAP options"),True,1,1,"options"),
|
|
|
|
|
(_("Service Samba options"),True,1,1,"options"),
|
|
|
|
|
(_("Services"),True,1,0,"")
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
self.chapterBloc = []
|
|
|
|
@ -189,226 +189,253 @@ class cl_ldap(imp_cl_err, imp_cl_xml, imp_cl_par, imp_cl_con):
|
|
|
|
|
'cl-usermod':5,
|
|
|
|
|
'cl-setup':6,
|
|
|
|
|
}
|
|
|
|
|
self.relServices = [{"samba":[_("Options"),
|
|
|
|
|
_("Service Samba options")]
|
|
|
|
|
},
|
|
|
|
|
"ldap":[_("Options"),
|
|
|
|
|
_("Service Ldap options")]
|
|
|
|
|
# Cвязь сервисов и действующих опций
|
|
|
|
|
self.relServices = {"samba":[_("Common options"),
|
|
|
|
|
_("Service Samba options")],
|
|
|
|
|
"ldap":[_("Common options"),
|
|
|
|
|
_("Service LDAP options")],
|
|
|
|
|
}
|
|
|
|
|
# Cвязь длинных опций помощи и выводимых разделов помощи с опциями
|
|
|
|
|
self.relOptions = {"h":[_("Common options")],
|
|
|
|
|
"help-ldap":[_("Common options"),
|
|
|
|
|
_("Service LDAP options")],
|
|
|
|
|
"help-samba":[_("Common options"),
|
|
|
|
|
_("Service Samba options")],
|
|
|
|
|
"help-all":[_("Common options"),
|
|
|
|
|
_("Service Samba options"),
|
|
|
|
|
_("Service LDAP options")
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
self.data = [\
|
|
|
|
|
# Options
|
|
|
|
|
{'shortOption':"h",
|
|
|
|
|
'longOption':"help",
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("display this help and exit")
|
|
|
|
|
},
|
|
|
|
|
{'longOption':"help-ldap",
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("display help options service LDAP")
|
|
|
|
|
},
|
|
|
|
|
{'longOption':"help-samba",
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("display help options service Samba")
|
|
|
|
|
},
|
|
|
|
|
{'longOption':"help-all",
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("display help options all services")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(0,),
|
|
|
|
|
'shortOption':"g",
|
|
|
|
|
'longOption':"gid",
|
|
|
|
|
'optVal':"GID",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("use GID for the new group")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(0,),
|
|
|
|
|
'shortOption':"c",
|
|
|
|
|
'longOption':"comment",
|
|
|
|
|
'optVal':"COMMENT",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("set the GECOS field for the new group")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(0,),
|
|
|
|
|
'shortOption':"p",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("print the gidNumber to stdout")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(2,),
|
|
|
|
|
'shortOption':"m",
|
|
|
|
|
'longOption':"member",
|
|
|
|
|
'optVal':"ADD_USERS",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("add members (comma delimited)")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(2,),
|
|
|
|
|
'shortOption':"x",
|
|
|
|
|
'longOption':"member",
|
|
|
|
|
'optVal':"DEL_USERS",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("delete members (comma delimted)")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"b",
|
|
|
|
|
'longOption':"base-dir",
|
|
|
|
|
'optVal':"BASE_DIR",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Service LDAP options"),
|
|
|
|
|
'help':_("base directory for the new user account home directory")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"c",
|
|
|
|
|
'longOption':"comment",
|
|
|
|
|
'optVal':"COMMENT",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Service LDAP options"),
|
|
|
|
|
'help':_("set the GECOS field for the new user account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"w",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Service Samba options"),
|
|
|
|
|
'help':_("set the trust account (Windows Workstation)")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"g",
|
|
|
|
|
'longOption':"gid",
|
|
|
|
|
'optVal':"GROUP",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Service LDAP options"),
|
|
|
|
|
'help':_("force use GROUP for the new user account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"G",
|
|
|
|
|
'longOption':"groups",
|
|
|
|
|
'optVal':"GROUPS",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Service LDAP options"),
|
|
|
|
|
'help':_("list of supplementary groups for the new user account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"k",
|
|
|
|
|
'longOption':"skel",
|
|
|
|
|
'optVal':"SKEL_DIR",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Service LDAP options"),
|
|
|
|
|
'help':_("specify an alternative skel directory")
|
|
|
|
|
},
|
|
|
|
|
#{'progAccess':(3,),
|
|
|
|
|
#'shortOption':"p",
|
|
|
|
|
#'longOption':"password",
|
|
|
|
|
#'optVal':"PASSWORD",
|
|
|
|
|
#'helpChapter':_("Options"),
|
|
|
|
|
#'helpChapter':_("Common options"),
|
|
|
|
|
#'help':_("use encrypted password for the new user account")
|
|
|
|
|
#},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"m",
|
|
|
|
|
'longOption':"create-home",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Service LDAP options"),
|
|
|
|
|
'help':_("create home directory for the new user account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"s",
|
|
|
|
|
'longOption':"shell",
|
|
|
|
|
'optVal':"SHELL",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Service LDAP options"),
|
|
|
|
|
'help':_("the login shell for the new user account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"u",
|
|
|
|
|
'longOption':"uid",
|
|
|
|
|
'optVal':"UID",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Service LDAP options"),
|
|
|
|
|
'help':_("force use the UID for the new user account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(4,),
|
|
|
|
|
'shortOption':"r",
|
|
|
|
|
'longOption':"remove",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("remove home directory (LDAP service only)")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(5,),
|
|
|
|
|
'shortOption':"c",
|
|
|
|
|
'longOption':"comment",
|
|
|
|
|
'optVal':"COMMENT",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("new value of the GECOS field")
|
|
|
|
|
},
|
|
|
|
|
#{'progAccess':(5,),
|
|
|
|
|
#'shortOption':"d",
|
|
|
|
|
#'longOption':"home",
|
|
|
|
|
#'optVal':"HOME_DIR",
|
|
|
|
|
#'helpChapter':_("Options"),
|
|
|
|
|
#'helpChapter':_("Common options"),
|
|
|
|
|
#'help':_("new home directory for the user account")
|
|
|
|
|
#},
|
|
|
|
|
#{'progAccess':(5,),
|
|
|
|
|
#'shortOption':"g",
|
|
|
|
|
#'longOption':"gid",
|
|
|
|
|
#'optVal':"GROUP",
|
|
|
|
|
#'helpChapter':_("Options"),
|
|
|
|
|
#'helpChapter':_("Common options"),
|
|
|
|
|
#'help':_("force use GROUP as new primary group")
|
|
|
|
|
#},
|
|
|
|
|
{'progAccess':(5,),
|
|
|
|
|
'shortOption':"G",
|
|
|
|
|
'longOption':"groups",
|
|
|
|
|
'optVal':"GROUPS",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("new list of supplementary GROUPS")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(5,),
|
|
|
|
|
'shortOption':"a",
|
|
|
|
|
'longOption':"append",
|
|
|
|
|
'optVal':"GROUPS",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("append the user to the supplemental GROUPS")
|
|
|
|
|
},
|
|
|
|
|
#{'progAccess':(5,),
|
|
|
|
|
#'shortOption':"l",
|
|
|
|
|
#'longOption':"login",
|
|
|
|
|
#'optVal':"NEW_LOGIN",
|
|
|
|
|
#'helpChapter':_("Options"),
|
|
|
|
|
#'helpChapter':_("Common options"),
|
|
|
|
|
#'help':_("new value of the login name")
|
|
|
|
|
#},
|
|
|
|
|
#{'progAccess':(5,),
|
|
|
|
|
#'shortOption':"m",
|
|
|
|
|
#'longOption':"move-home",
|
|
|
|
|
#'helpChapter':_("Options"),
|
|
|
|
|
#'helpChapter':_("Common options"),
|
|
|
|
|
#'help':_("move contents of the home directory to the new location\
|
|
|
|
|
#(use only with -d)")
|
|
|
|
|
#},
|
|
|
|
|
{'progAccess':(5,),
|
|
|
|
|
'shortOption':"p",
|
|
|
|
|
'longOption':"password",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("new password for the user account (from dialog)")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(5,),
|
|
|
|
|
'shortOption':"P",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("new password for the user account (from standart input)")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(5,),
|
|
|
|
|
'shortOption':"s",
|
|
|
|
|
'longOption':"shell",
|
|
|
|
|
'optVal':"SHELL",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("new login shell for the user account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(5,),
|
|
|
|
|
'shortOption':"d",
|
|
|
|
|
'longOption':"userDisable",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("disable user")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(5,),
|
|
|
|
|
'shortOption':"e",
|
|
|
|
|
'longOption':"userEnable",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("enable user")
|
|
|
|
|
},
|
|
|
|
|
#{'progAccess':(5,),
|
|
|
|
|
#'shortOption':"u",
|
|
|
|
|
#'longOption':"uid",
|
|
|
|
|
#'optVal':"UID",
|
|
|
|
|
#'helpChapter':_("Options"),
|
|
|
|
|
#'helpChapter':_("Common options"),
|
|
|
|
|
#'help':_("new UID for the user account")
|
|
|
|
|
#},
|
|
|
|
|
|
|
|
|
|
{'progAccess':(6,),
|
|
|
|
|
'shortOption':"f",
|
|
|
|
|
'longOption':"force",
|
|
|
|
|
'helpChapter':_("Options"),
|
|
|
|
|
'helpChapter':_("Common options"),
|
|
|
|
|
'help':_("forced setup service")
|
|
|
|
|
},
|
|
|
|
|
#{'progAccess':(0,1,2,4,5,6),
|
|
|
|
|
#'shortOption':"s",
|
|
|
|
|
#'longOption':"set",
|
|
|
|
|
#'optVal':"<name>=<val>",
|
|
|
|
|
#'helpChapter':_("Options"),
|
|
|
|
|
#'helpChapter':_("Common options"),
|
|
|
|
|
#'help':_("change enviroment values")
|
|
|
|
|
#},
|
|
|
|
|
#{'shortOption':"e",
|
|
|
|
|
#'longOption':"env",
|
|
|
|
|
#'optVal':"filter",
|
|
|
|
|
#'helpChapter':_("Options"),
|
|
|
|
|
#'helpChapter':_("Common options"),
|
|
|
|
|
#'help':_("show enviroment values (filter for type, all - no filter)")
|
|
|
|
|
#},
|
|
|
|
|
# Services
|
|
|
|
@ -448,11 +475,6 @@ class cl_ldap(imp_cl_err, imp_cl_xml, imp_cl_par, imp_cl_con):
|
|
|
|
|
##'help':" wiki \t\t\twiki " + servName + "\n"
|
|
|
|
|
##},
|
|
|
|
|
# Informative output
|
|
|
|
|
{'shortOption':"h",
|
|
|
|
|
'longOption':"help",
|
|
|
|
|
'helpChapter':_("Informative output"),
|
|
|
|
|
'help':_("display this help and exit")
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
#'progAccess':(3,),
|
|
|
|
|
'helpChapter':"Copyright",
|
|
|
|
@ -2296,3 +2318,82 @@ Samba in backup directory")
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("Not add user ..."))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
class tsOpt:
|
|
|
|
|
def __init__(self, obj, parBeforeService):
|
|
|
|
|
service = sys.argv[-1:][0].rstrip()
|
|
|
|
|
shortOpt = obj.getAllOpt('short', obj.relOptions['h'])
|
|
|
|
|
longOpt = obj.getAllOpt('long', obj.relOptions['h'])
|
|
|
|
|
if service in obj.allServ:
|
|
|
|
|
if service == "ldap":
|
|
|
|
|
obj.clearAllOpt()
|
|
|
|
|
shortOpt = obj.getAllOpt('short', obj.relServices['ldap'])
|
|
|
|
|
longOpt = obj.getAllOpt('long', obj.relServices['ldap'])
|
|
|
|
|
elif service == "samba":
|
|
|
|
|
obj.clearAllOpt()
|
|
|
|
|
shortOpt = obj.getAllOpt('short', obj.relServices['samba'])
|
|
|
|
|
longOpt = obj.getAllOpt('long', obj.relServices['samba'])
|
|
|
|
|
optObj = cl_base.opt(shortOpt, longOpt)
|
|
|
|
|
optObj.sysArgv = sys.argv[1:]
|
|
|
|
|
optObj.obj = obj
|
|
|
|
|
optObj.__iter = 0
|
|
|
|
|
optObj.opt = {}
|
|
|
|
|
optObj.params = {}
|
|
|
|
|
optObj.handlerOpt = tsOpt.handlerOpt.__get__(optObj)
|
|
|
|
|
optObj.handlerErrOpt = tsOpt.handlerErrOpt.__get__(optObj)
|
|
|
|
|
optObj.handlerParam = tsOpt.handlerParam.__get__(optObj)
|
|
|
|
|
# названия параметров из хвоста командной строки
|
|
|
|
|
optObj.nameParams = parBeforeService + ['service']
|
|
|
|
|
optObj.getopt()
|
|
|
|
|
# параметры из хвоста командной строки
|
|
|
|
|
self.params = optObj.params
|
|
|
|
|
self.opt = optObj.opt
|
|
|
|
|
# Обработка help
|
|
|
|
|
self.flagHelp = False
|
|
|
|
|
if "h" in optObj.opt:
|
|
|
|
|
print obj.getHelp(obj.relOptions['h'])
|
|
|
|
|
self.flagHelp = True
|
|
|
|
|
elif "help-ldap" in optObj.opt:
|
|
|
|
|
print obj.getHelp(obj.relOptions['help-ldap'])
|
|
|
|
|
self.flagHelp = True
|
|
|
|
|
elif "help-samba" in optObj.opt:
|
|
|
|
|
print obj.getHelp(obj.relOptions['help-samba'])
|
|
|
|
|
self.flagHelp = True
|
|
|
|
|
elif "help-all" in optObj.opt:
|
|
|
|
|
print obj.getHelp(obj.relOptions['help-all'])
|
|
|
|
|
self.flagHelp = True
|
|
|
|
|
elif not optObj.params:
|
|
|
|
|
print obj.getHelp(obj.relOptions['h'])
|
|
|
|
|
self.flagHelp = True
|
|
|
|
|
else:
|
|
|
|
|
if optObj.params.has_key('service'):
|
|
|
|
|
if not (optObj.params['service'] in obj.allServ) or\
|
|
|
|
|
len(optObj.nameParams) != optObj.__iter:
|
|
|
|
|
optObj.handlerErrOpt()
|
|
|
|
|
else:
|
|
|
|
|
optObj.handlerErrOpt()
|
|
|
|
|
|
|
|
|
|
def handlerOpt(self,option,value):
|
|
|
|
|
# Обработчик (опция значение)
|
|
|
|
|
#print option, value
|
|
|
|
|
shortOpt = self.obj.getShortOpt(option)
|
|
|
|
|
if not shortOpt:
|
|
|
|
|
shortOpt = option
|
|
|
|
|
if not self.opt.has_key(shortOpt):
|
|
|
|
|
self.opt[shortOpt] = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handlerErrOpt(self):
|
|
|
|
|
# Обработчик ошибок
|
|
|
|
|
argv = " ".join(sys.argv[1:])
|
|
|
|
|
print _("Unrecognized option") + ' "' + argv + '"\n' + \
|
|
|
|
|
_("Try") + ' "' + sys.argv[0].split("/")[-1] + ' --help" ' +\
|
|
|
|
|
_("for more information.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handlerParam(self,param):
|
|
|
|
|
# Обработчик хвостов (значение)
|
|
|
|
|
self.__iter += 1
|
|
|
|
|
if self.__iter<=len(self.nameParams):
|
|
|
|
|
self.params[self.nameParams[self.__iter-1]] = param
|
|
|
|
|
|
|
|
|
|