rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
raise exceptions.LicornRuntimeException, "The group %s doesn't exist." % name
raise exceptions.LicornRuntimeException( "The group '%s' doesn't exist." % name)
def is_system_group(name): """ Return true if group is system. """ try: return GroupsController.is_system_gid(GroupsController.name_to_gid(name)) except KeyError: raise exceptions.LicornRuntimeException, "The group %s doesn't exist." % name
raise exceptions.LicornRuntimeException, "The group `%s' doesn't exist." % name
raise exceptions.LicornRuntimeException( "The group '%s' doesn't exist." % name)
def is_standard_group(name): """ Return true if group is system. """ try: return GroupsController.is_standard_gid(GroupsController.name_to_gid(name)) except KeyError: raise exceptions.LicornRuntimeException, "The group `%s' doesn't exist." % name
raise exceptions.LicornRuntimeException, "The group `%s' doesn't exist." % name
raise exceptions.LicornRuntimeException( "The group '%s' doesn't exist." % name)
def is_empty_group(name): try: return GroupsController.is_empty_gid(GroupsController.name_to_gid(name)) except KeyError: raise exceptions.LicornRuntimeException, "The group `%s' doesn't exist." % name
raise exceptions.LicornRuntimeError('''Can't build a valid UNIX group name (got %s, which doesn't verify %s) with the string you provided "%s".''' % (groupname, hlstr.regex['group_name'], inputname) )
raise exceptions.LicornRuntimeError( '''Can't build a valid UNIX group name (got %s, ''' '''which doesn't verify %s) with the string you ''' '''provided "%s".''' % ( groupname, hlstr.regex['group_name'], inputname) )
def make_name(inputname): """ Make a valid login from user's firstname and lastname."""
members = groups.all_members(name)
members = list(groups.all_members(name))
def view(uri, http_user, name): """Prepare a group view to be printed.""" users.reload() groups.reload() title = _("Details of group %s") % name data = w.page_body_start(uri, http_user, ctxtnav, title) u = users.users g = groups.groups # TODO: should we forbid system group view ? why not ? # As of now, this is har...
resps = groups.all_members(configuration.groups.resp_prefix + name)
resps = list( groups.all_members(configuration.groups.resp_prefix + name))
def user_line(login): uid = users.login_to_uid(login) return '''<tr> <td>%s</td> <td>%s</td> <td>%s</td> </tr>''' % ( u[uid]['gecos'], login, uid )
guests = \ groups.all_members(configuration.groups.guest_prefix + name)
guests = list( groups.all_members(configuration.groups.guest_prefix + name))
def user_line(login): uid = users.login_to_uid(login) return '''<tr> <td>%s</td> <td>%s</td> <td>%s</td> </tr>''' % ( u[uid]['gecos'], login, uid )
dest = g[groups.name_to_gid(gname)]['memberUid'][:]
dest = list(g[groups.name_to_gid(gname)]['memberUid'])
def edit(uri, http_user, name): """Edit a group.""" users.reload() groups.reload() u = users.users g = groups.groups title = _("Editing group %s") % name data = w.page_body_start(uri, http_user, ctxtnav, title, False) try: group = g[groups.name_to_gid(name)] sys = groups.is_system_group(name) dbl_lists ...
dest = g[groups.name_to_gid(gname)]['members'][:]
dest = g[groups.name_to_gid(gname)]['memberUid'][:]
def edit(uri, http_user, name): """Edit a group.""" users.reload() groups.reload() u = users.users g = groups.groups title = _("Editing group %s") % name data = w.page_body_start(uri, http_user, ctxtnav, title, False) try: group = g[groups.name_to_gid(name)] sys = groups.is_system_group(name) dbl_lists ...
for current in g[groups.name_to_gid(gname)]['members']:
for current in g[groups.name_to_gid(gname)]['memberUid']:
def edit(uri, http_user, name): """Edit a group.""" users.reload() groups.reload() u = users.users g = groups.groups title = _("Editing group %s") % name data = w.page_body_start(uri, http_user, ctxtnav, title, False) try: group = g[groups.name_to_gid(name)] sys = groups.is_system_group(name) dbl_lists ...
skel(group['skel'], sys),
skel(group['groupSkel'], sys),
def permissive(perm, system):
'skel' : group['skel'] + name,
'skel' : group['groupSkel'] + name,
def main(uri, http_user, sort = "name", order = "asc"): """List all groups and provileges on the system, displaying them in a nice HTML page. """ start = time.time() users.reload() groups.reload() #profiles.reload() g = groups.groups users.Select(users.FILTER_STANDARD) tgroups = {} totals = {} title = _('Group...
tgroups[gid]['members'] = [] for member in groups.groups[gid]['members']:
tgroups[gid]['memberUid'] = [] for member in groups.groups[gid]['memberUid']:
def main(uri, http_user, sort = "name", order = "asc"): """List all groups and provileges on the system, displaying them in a nice HTML page. """ start = time.time() users.reload() groups.reload() #profiles.reload() g = groups.groups users.Select(users.FILTER_STANDARD) tgroups = {} totals = {} title = _('Group...
tgroups[gid]['members'].append(
tgroups[gid]['memberUid'].append(
def main(uri, http_user, sort = "name", order = "asc"): """List all groups and provileges on the system, displaying them in a nice HTML page. """ start = time.time() users.reload() groups.reload() #profiles.reload() g = groups.groups users.Select(users.FILTER_STANDARD) tgroups = {} totals = {} title = _('Group...
prefix + name)]['members']:
prefix + name)]['memberUid']:
def main(uri, http_user, sort = "name", order = "asc"): """List all groups and provileges on the system, displaying them in a nice HTML page. """ start = time.time() users.reload() groups.reload() #profiles.reload() g = groups.groups users.Select(users.FILTER_STANDARD) tgroups = {} totals = {} title = _('Group...
name, g[gid]['skel'])
name, g[gid]['groupSkel'])
def html_build_group(index, tgroups = tgroups ): gid = ordered[index] name = g[gid]['name'] html_data = '''
assert ltrace('ldap', '| __init__().')
assert ltrace('ldap', '| __init__()')
def __init__(self, configuration, users=None, groups=None, warnings=True): """ Init the LDAP backend instance. """
assert ltrace('ldap', '> initialize().')
assert ltrace('ldap', '> initialize()')
def initialize(self, enabled=True): """ try to start it without any tests (it should work if it's installed) and become available. If that fails, try to guess a little and help user resolving issue. else, just fail miserably.
assert ltrace('ldap', '< initialize() %s.' % self.available)
assert ltrace('ldap', '< initialize(%s)' % self.available)
def initialize(self, enabled=True): """ try to start it without any tests (it should work if it's installed) and become available. If that fails, try to guess a little and help user resolving issue. else, just fail miserably.
test_integrated_help() test_regexes() save_state(1, state_type='context')
if get_state(state_type='context') == 0: test_integrated_help() test_regexes() save_state(1, state_type='context') ctx_will_change = True else: logging.notice('Skipping context %s' % stylize(ST_NAME, "std")) ctx_will_change = False
def to_be_implemented(): """ TO BE DONE ! # # Profiles # # doit planter pour le groupe log_and_exec $ADD profile --name=profileA --group=a # doit planter pour le groupe kjsdqsdf log_and_exec $ADD profile --name=profileB --group=b --comment="le profil b" --shell=/bin/bash --quota=26 --groups=cdrom,kjsdqsdf,audio --ske...
ScenarioTest.reinit()
if get_state(state_type='scenarii') == 0 or ctx_will_change == True: ScenarioTest.reinit()
def to_be_implemented(): """ TO BE DONE ! # # Profiles # # doit planter pour le groupe log_and_exec $ADD profile --name=profileA --group=a # doit planter pour le groupe kjsdqsdf log_and_exec $ADD profile --name=profileB --group=b --comment="le profil b" --shell=/bin/bash --quota=26 --groups=cdrom,kjsdqsdf,audio --ske...
ctx_will_change = True
def to_be_implemented(): """ TO BE DONE ! # # Profiles # # doit planter pour le groupe log_and_exec $ADD profile --name=profileA --group=a # doit planter pour le groupe kjsdqsdf log_and_exec $ADD profile --name=profileB --group=b --comment="le profil b" --shell=/bin/bash --quota=26 --groups=cdrom,kjsdqsdf,audio --ske...
users = UGBackend.users action = users[uid]['action'] login = users[uid]['login']
user = UGBackend.users[uid].copy() action = user['action'] login = user['login']
def save_user(self, uid): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
ltrace('ldap', 'password: %s.' % (users[uid]['userPassword']))
def save_user(self, uid): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
users[uid]['userPassword'] = \ '{SHA}' + encodestring(users[uid]['userPassword']).strip()
user['userPassword'] = \ '{SHA}' + encodestring(user['userPassword']).strip()
def save_user(self, uid): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
modifyModlist(old_entry, users[uid],
modifyModlist(old_entry, user,
def save_user(self, uid): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
old_entry, users[uid], ignore_list, ignore_oldexistent=1))
old_entry, user, ignore_list, ignore_oldexistent=1))
def save_user(self, uid): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
users[uid]['cn'] = login users[uid]['objectClass'] = [
user['cn'] = login user['objectClass'] = [
def save_user(self, uid): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
users[uid]['sn'] = users[uid]['gecos']
user['sn'] = user['gecos']
def save_user(self, uid): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
addModlist(users[uid], ignore_list)))
addModlist(user, ignore_list)))
def save_user(self, uid): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
addModlist(users[uid], ignore_list))
addModlist(user, ignore_list))
def save_user(self, uid): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
users[uid]['action'] = None
UGBackend.users[uid]['action'] = None
def save_user(self, uid): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
groups = UGBackend.groups action = groups[gid]['action'] name = groups[gid]['name']
group = UGBackend.groups[gid].copy() action = group['action'] name = group['name']
def save_group(self, gid): """ Save one group in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
old_entry, groups[gid], ignore_list, ignore_oldexistent=1))
old_entry, group, ignore_list, ignore_oldexistent=1))
def save_group(self, gid): """ Save one group in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
groups[gid]['cn'] = name groups[gid]['objectClass'] = [
group['cn'] = name group['objectClass'] = [
def save_group(self, gid): """ Save one group in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
addModlist(groups[gid], ignore_list))
addModlist(group, ignore_list))
def save_group(self, gid): """ Save one group in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
groups[gid]['action'] = None
UGBackend.groups[gid]['action'] = None
def save_group(self, gid): """ Save one group in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
users.AddUser(lastname, firstname, password, opts.primary_group, opts.profile, opts.skel, login, gecos, False)
users.AddUser(lastname, firstname, password, primary_group=opts.primary_group, profile=opts.profile, skel=opts.skel, login=login, gecos=gecos, system=opts.system, batch=False)
def add_user(): """ Add a user account on the system. """ if opts.firstname is None: firstname = None else: firstname = unicode(opts.firstname) if opts.lastname is None: lastname = None else: lastname = unicode(opts.lastname) if opts.gecos is None: gecos = None else: gecos = unicode(opts.gecos) if opts.password is ...
logging.warning("%s is not a privilege." % \
logging.warning('''group %s can't be promoted as privilege, ''' '''it is not a system group.''' % \
def append(self, privilege): """ Set append like: no doubles.""" try: self.index(privilege) except ValueError: from licorn.core.users import UsersController from licorn.core.groups import GroupsController
logging.warning('''privilege %s is already not present in the '''
logging.info('''privilege %s is already not present in the '''
def remove(self, privilege): """ Remove without throw of exception """ try: list.remove(self, privilege) except ValueError: logging.warning('''privilege %s is already not present in the ''' '''whitelist, skipped.''' % \ styles.stylize(styles.ST_NAME, privilege))
if UsersController.is_system_uid(uid):
if uid > self.configuration.users.system_uid_min \ and uid < self.configuration.users.system_uid_max:
def check_uid(uid, minimal=minimal, batch=batch, auto_answer=auto_answer):
else: logging.progress("Checking user %s..." % \
elif self.is_standard_uid(uid): logging.progress("Checking standard account %s..." % \
def check_uid(uid, minimal=minimal, batch=batch, auto_answer=auto_answer):
return all_went_ok
else: login = self.uid_to_login(uid) logging.info('''Skipped reserved system account %s ''' '''(we don't check them at all).''' % styles.stylize(styles.ST_NAME, login)) return all_went_ok
def check_uid(uid, minimal=minimal, batch=batch, auto_answer=auto_answer):
'backends'])[1].split('\n') if 'U' in line ]
'backends'])[0].split('\n') if 'U' in line ]
def __init__(self, name, directory_scenarii, clean_func, state_file, cmd_display_func): self.name=name self.list_scenario = [] self.selected_scenario = [] self.directory_scenarii=directory_scenarii self.clean_system=clean_func self.cmd_display_func = cmd_display_func self.state_file=state_file # save the current contex...
elif b.can_be_enabled(): b.initialize() b.check(batch, auto_answer)
elif b.name in self.available_backends: self.available_backends[b.name].check(batch, auto_answer)
def check_backends(self, batch=False, auto_answer=None): """ check all enabled backends, except the 'prefered', which is one of the enabled anyway.
if pingers > 25:
if pingers > 50:
def check_directive_daemon_threads(self): """ check the pingers number for correctness. """ assert ltrace('configuration', '| check_directive_daemon_threads()')
stylize(ST_ , 'licornd.threads.pool_members')))
stylize(ST_COMMENT, 'licornd.threads.pool_members')))
def check_directive_daemon_threads(self): """ check the pingers number for correctness. """ assert ltrace('configuration', '| check_directive_daemon_threads()')
tmp_user_dict['shadowInactive'] = 99999 tmp_user_dict['shadowWarning'] = ''
tmp_user_dict['shadowInactive'] = '' tmp_user_dict['shadowWarning'] = 7
def AddUser(self, lastname = None, firstname = None, password = None, primary_group=None, profile=None, skel=None, login=None, gecos=None, system = False, batch=False): """Add a user and return his/her (uid, login, pass)."""
def execute(cmd, verbose=False):
def execute(cmd, verbose=verbose):
def execute(cmd, verbose=False): if verbose: logging.notice('running %s.' % ' '.join(cmd)) p4 = Popen(cmd, shell=False, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) output = p4.stdout.read() retcode = p4.wait() if verbose: sys.stderr.write(output) return output, retcode
term_columns = term_size()[1] separator = '--------8<--------' * (term_columns/18)
def RunCommand(self, cmdnum, batch=False):
os.system('sudo rm -rf %s/* %s/*' % (configuration.home_backup_dir, configuration.home_archive_dir))
execute([ 'sudo', 'rm', '-rf', '%s/*' % configuration.home_backup_dir, '%s/*' % configuration.home_archive_dir ]) execute(ADD + ['group', '--system', 'acl,admins,remotessh,licorn-wmi'])
def clean_system(): """ Remove all stuff to make the system clean, testsuite-wise.""" test_message('''cleaning system from previous runs.''') # delete them first in case of a previous failed testsuite run. # don't check exit codes or such, this will be done later. for argument in ( ['user', '''toto,tutu,tata,titi,te...
execute(['chk', 'config', '-avvb'])
execute(['sudo', 'chk', 'config', '-avvb'])
def make_backups(mode): """Make backup of important system files before messing them up ;-) """ # this is mandatory, else there could be some inconsistencies following # backend (de)activation, and backup comparison could fail (false-negative) # because of this. execute(['chk', 'config', '-avvb']) if mode == 'unix': ...
'%s/%s/out.txt' % (self.base_path, cmdnum),
tmpfilename2 if gz_file else '%s/%s/out.txt' % (self.base_path, cmdnum),
def RunCommand(self, cmdnum, batch=False):
profile.add_option("--group", "--name",
profile.add_option("--name", action="store", type="string", dest="name", default = None, help="specify profile to modify by its name (%s)." % styles.stylize(styles.ST_IMPORTANT, "one of --name or --group is required")) profile.add_option("--group",
def mod_profile_parse_arguments(app): usage_text = "\n\t%s profile --group=<nom> [--name=<nouveau_nom>] [--rename-group=<nouveau_nom>]\n" % styles.stylize(styles.ST_APPNAME, "%prog") \ + "\t\t[--comment=<nouveau_commentaire>] [--shell=<nouveau_shell>] [--skel=<nouveau_skel>]\n" \ + "\t\t[--quota=<nouveau_quota>] [--ad...
help="specify profile to modify by its primary group (%s)." % styles.stylize(styles.ST_IMPORTANT, "required"))
help="specify profile to modify by its primary group (%s)." % styles.stylize(styles.ST_IMPORTANT, "one of --name or --group is required"))
def mod_profile_parse_arguments(app): usage_text = "\n\t%s profile --group=<nom> [--name=<nouveau_nom>] [--rename-group=<nouveau_nom>]\n" % styles.stylize(styles.ST_APPNAME, "%prog") \ + "\t\t[--comment=<nouveau_commentaire>] [--shell=<nouveau_shell>] [--skel=<nouveau_skel>]\n" \ + "\t\t[--quota=<nouveau_quota>] [--ad...
if user['shadowExpire'] == '':
if 'shadowExpire' in user and user['shadowExpire'] == '':
def save_User(self, uid, mode): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
if user['shadowFlag'] == '':
if 'shadowFlag' in user and user['shadowFlag'] == '':
def save_User(self, uid, mode): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
if user['shadowInactive'] == '':
if 'shadowInactive' in user and user['shadowInactive'] == '':
def save_User(self, uid, mode): """ Save one user in the LDAP backend. If updating, the entry will be dropped prior of insertion. """
groups = GroupsController(self.configuration)
users = UsersController(self.configuration) groups = GroupsController(self.configuration, users)
def append(self, privilege): """ Set append like: no doubles.""" try: self.index(privilege) except ValueError: from licorn.core.groups import GroupsController groups = GroupsController(self.configuration) if groups.is_system_group(privilege): list.append(self, privilege) else: logging.warning("%s is not a privilege." %...
return (w.HTTP_TYPE_TEXT, w.minipage(w.lbox('''%s <div class="vspacer"></div>
return (w.HTTP_TYPE_TEXT, w.minipage(w.lbox(''' <div style="line-height: 1.5em; padding-bottom:20px">%s</div>
def reboot(uri, http_user, sure = False): if sure: return (w.HTTP_TYPE_TEXT, w.minipage(w.lbox('''<div class="vspacer"></div>%s''' % \ _('Rebooting…')))) else: return (w.HTTP_TYPE_TEXT, w.minipage(w.lbox('''%s <div class="vspacer"></div> <table class="lbox-table"> <tr> <td> <form name="reboot_form" id="reboot_form" act...
from licorn.core import groups as allgroups if allusers is None: from licorn.core import users as allusers
from licorn.core.groups import GroupsController allgroups = GroupsController(allusers.configuration, allusers)
def check_dirs_and_contents_perms_and_acls(dirs_infos, batch = False, auto_answer = None, allgroups = None, allusers = None): """ Check if a dir exists, else create it and apply ACLs on it eventually. dirs_infos should be a n-tuple of dicts, composed like this: { 'path' : string, 'type' : stat.S_IF???, ...
from licorn.core import groups as allgroups if allusers is None: from licorn.core import users as allusers
from licorn.core.groups import GroupsController allgroups = GroupsController(allusers.configuration, allusers)
def check_posix_ugid_and_perms(onpath, uid = -1, gid = -1, perms = -1, batch = False, auto_answer = None, allgroups = None, allusers = None): """Check if some path has some desired perms, repair if told to do so.""" if onpath in ("", None): raise exceptions.BadArgumentError("The path you want to check perms on must no...
desired_login = allusers.users[ uid ]['login']
desired_login = allusers[uid]['login']
def check_posix_ugid_and_perms(onpath, uid = -1, gid = -1, perms = -1, batch = False, auto_answer = None, allgroups = None, allusers = None): """Check if some path has some desired perms, repair if told to do so.""" if onpath in ("", None): raise exceptions.BadArgumentError("The path you want to check perms on must no...
desired_group = allgroups.groups[ gid ]['name']
desired_group = allgroups[gid]['name']
def check_posix_ugid_and_perms(onpath, uid = -1, gid = -1, perms = -1, batch = False, auto_answer = None, allgroups = None, allusers = None): """Check if some path has some desired perms, repair if told to do so.""" if onpath in ("", None): raise exceptions.BadArgumentError("The path you want to check perms on must no...
current_login = allusers.users[ pathstat.st_uid ]['login']
current_login = allusers[pathstat.st_uid]['login']
def check_posix_ugid_and_perms(onpath, uid = -1, gid = -1, perms = -1, batch = False, auto_answer = None, allgroups = None, allusers = None): """Check if some path has some desired perms, repair if told to do so.""" if onpath in ("", None): raise exceptions.BadArgumentError("The path you want to check perms on must no...
current_group = allgroups.groups[ pathstat.st_gid ]['name']
current_group = allgroups[pathstat.st_gid]['name']
def check_posix_ugid_and_perms(onpath, uid = -1, gid = -1, perms = -1, batch = False, auto_answer = None, allgroups = None, allusers = None): """Check if some path has some desired perms, repair if told to do so.""" if onpath in ("", None): raise exceptions.BadArgumentError("The path you want to check perms on must no...
to_remove.append(member)
to_remove.add(member)
def load_groups(self): """ Load groups from /etc/{group,gshadow} and /etc/licorn/group. """
except (OSError, IOerror), e:
except (OSError, IOError), e:
def CleanUp(self): """This is a sort of destructor. Clean-up before being deleted..."""
logging.info(logging.SYSG_CREATED_GROUP % styles.stylize(styles.ST_NAME, name))
logging.info(logging.SYSG_CREATED_GROUP % \ styles.stylize(styles.ST_NAME, name))
def AddGroup(self, name, gid=None, description="", groupSkel="", system=False, permissive=False, batch=False, force=False): """ Add an Licorn group (the group + the responsible group + the shared dir + permissions). """
dir_info.dirs_perm = "%s,g:%s:rw-,%s,%s" % \
dir_info.dirs_perm = ("%s,g:%s:rw-,%s,%s" % \
def generate_dir_info(self, user_info=None, dir_info_base=None): """ generate a FsapiObject from the rule. This object will be understandable by fsapi """ acl=self.acl
LMC.configuration.acls.file_acl_mask)
LMC.configuration.acls.file_acl_mask)).replace( '@UX','x').replace('@GX','x')
def generate_dir_info(self, user_info=None, dir_info_base=None): """ generate a FsapiObject from the rule. This object will be understandable by fsapi """ acl=self.acl
def shutdown(uri, http_user, hostname=None, sure=False, warn_users=True, yes=None):
def shutdown(uri, http_user, hostname=None, sure=False, warn_users=True, yes=None, configuration=None, machines=None, **kwargs):
def shutdown(uri, http_user, hostname=None, sure=False, warn_users=True, yes=None): """ Export machine list.""" # submit button; forget it. del yes title = _("Shutdown machine %s") % hostname data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: description = _('''Are you sure you want to remotely s...
active=None, warn_users=None, admin=None, yes=None):
active=None, warn_users=None, admin=None, yes=None, configuration=None, machines=None, **kwargs):
def massshutdown(uri, http_user, sure=False, asleep=None, idle=None, active=None, warn_users=None, admin=None, yes=None): """ Export machine list.""" # submit button; forget it. del yes title = _("Massive shutdown") data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: description = _('''You can shu...
def energyprefs(uri, http_user):
def energyprefs(uri, http_user, configuration=None, machines=None, **kwargs):
def energyprefs(uri, http_user): """ Export machine list.""" # submit button; forget it. del yes title = _("Energy saving policies") if type == "": description = _('''CSV file-format is used by spreadsheets and most ''' '''systems which offer import functionnalities. XML file-format is a ''' '''modern exchange forma...
def export(uri, http_user, type = "", yes = None):
def export(uri, http_user, type = "", yes=None, configuration=None, machines=None, **kwargs):
def export(uri, http_user, type = "", yes = None): """ Export machine list.""" # submit button; forget it. del yes return (w.HTTP_TYPE_TEXT, "not implemented yet.") title = _("Export machines list") data = '''<div id="banner"> %s %s</div> %s <div id="main"> %s <div id="content"> <h1>%s</h1>''' % ( w.backto(), w.met...
def forget(uri, http_user, hostname, sure=False, yes=None):
def forget(uri, http_user, hostname, sure=False, yes=None, configuration=None, machines=None, **kwargs):
def forget(uri, http_user, hostname, sure=False, yes=None): """remove machine account.""" # form submit button, forget it. del yes return (w.HTTP_TYPE_TEXT, "not implemented yet.") title = _("Remove machine %s's record") % hostname if protected_user(hostname): return w.forgery_error(title) data = w.page_body_star...
def new(uri, http_user):
def new(uri, http_user, configuration=None, machines=None, **kwargs):
def new(uri, http_user): """Generate a form to create a new machine on the system.""" return (w.HTTP_TYPE_TEXT, "not implemented yet.") title = _("New machine record") data = w.page_body_start(uri, http_user, ctxtnav, title, False) def profile_input(): #TODO: To be rewritten ? return """ <tr> <td><strong>%s</stron...
create = None ):
create=None, configuration=None, machines=None, **kwargs):
def create(uri, http_user, loginShell, password, password_confirm, profile=None, hostname="", gecos="", firstname="", lastname="", standard_groups_dest=[], privileged_groups_dest=[], responsible_groups_dest=[], guest_groups_dest=[], standard_groups_source=[], privileged_groups_source=[], responsible_groups_source=[], g...
def edit(uri, http_user, hostname):
def edit(uri, http_user, hostname, configuration=None, machines=None, **kwargs):
def edit(uri, http_user, hostname): """Edit an machine record, based on hostname.""" return (w.HTTP_TYPE_TEXT, "not implemented yet.") title = _("Edit %s's record") % hostname if protected_user(hostname): return w.forgery_error(title) data = w.page_body_start(uri, http_user, ctxtnav, title, False) try: machine = ...
record = None):
record=None, configuration=None, machines=None, **kwargs):
def record(uri, http_user, hostname, loginShell=None, password = "", password_confirm = "", firstname = "", lastname = "", gecos = "", standard_groups_source = [], standard_groups_dest = [], privileged_groups_source = [], privileged_groups_dest = [], responsible_groups_source = [], responsible_groups_dest = [],...
def main(uri, http_user, sort = "hostname", order = "asc"):
def main(uri, http_user, sort="hostname", order="asc", configuration=None, machines=None, **kwargs):
def main(uri, http_user, sort = "hostname", order = "asc"): """ display all machines in a nice HTML page. """ start = time.time() m = machines.machines accounts = {} ordered = {} totals = { _('managed'): 0, _('floating'): 0 } title = _("Machines") data = w.page_body_start(uri, http_user, ctxtnav, title) if ord...
groups_filters_lists_ids = ( (name, ( _('Manage members'), _('Users not yet members'), _('Current members') ), 'members' ), (configuration.groups.resp_prefix + name, None, '& (configuration.groups.guest_prefix + name, None, '& )
groups_filters_lists_ids = [ (name, [ _('Manage members'), _('Users not yet members'), _('Current members') ], 'members' ) ]
def edit(uri, http_user, name): """Edit a group.""" users.reload() groups.reload() u = users.users g = groups.groups title = _("Editing group %s") % name data = w.page_body_start(uri, http_user, ctxtnav, title, False) try: group = g[groups.name_to_gid(name)] sys = groups.is_system_group(name) dbl_lists ...
dest = list(g[groups.name_to_gid(gname)]['memberUid'])
dest = list(group['memberUid'])
def edit(uri, http_user, name): """Edit a group.""" users.reload() groups.reload() u = users.users g = groups.groups title = _("Editing group %s") % name data = w.page_body_start(uri, http_user, ctxtnav, title, False) try: group = g[groups.name_to_gid(name)] sys = groups.is_system_group(name) dbl_lists ...
for current in g[groups.name_to_gid(gname)]['memberUid']: try: source.remove(current) except ValueError: dest.remove(current)
for current in group['memberUid']: try: source.remove(current) except ValueError: dest.remove(current)
def edit(uri, http_user, name): """Edit a group.""" users.reload() groups.reload() u = users.users g = groups.groups title = _("Editing group %s") % name data = w.page_body_start(uri, http_user, ctxtnav, title, False) try: group = g[groups.name_to_gid(name)] sys = groups.is_system_group(name) dbl_lists ...
if system: return '' else: return '''
return '' if system else \ '''
def skel(cur_skel, system): if system: return '' else: return ''' <tr> <td><strong>%s</strong></td> <td class="right">%s</td> </tr> ''' % (_('Skeleton'), w.select('skel', configuration.users.skels, cur_skel, func = os.path.basename))
if system: return '' else: return '''
return '' if system else \ '''
def permissive(perm, system):
<h2 class="accordion_toggle">≫&nbsp;%s</h2> <div class="accordion_content">%s</div> <h2 class="accordion_toggle">≫&nbsp;%s</h2> <div class="accordion_content">%s</div>
%s
def permissive(perm, system):
_('Group responsibles'), dbl_lists[configuration.groups.resp_prefix+name], _('Group guests'), dbl_lists[configuration.groups.guest_prefix+name],
data_rsp_gst,
def permissive(perm, system):
for member in groups.groups[gid]['memberUid']:
for member in group['memberUid']:
def main(uri, http_user, sort = "name", order = "asc"): """List all groups and provileges on the system, displaying them in a nice HTML page. """ start = time.time() users.reload() groups.reload() #profiles.reload() g = groups.groups users.Select(users.FILTER_STANDARD) tgroups = {} totals = {} title = _('Group...
tgroups[gid][prefix + 'members'] = []
tgroups[gid][prefix + 'memberUid'] = []
def main(uri, http_user, sort = "name", order = "asc"): """List all groups and provileges on the system, displaying them in a nice HTML page. """ start = time.time() users.reload() groups.reload() #profiles.reload() g = groups.groups users.Select(users.FILTER_STANDARD) tgroups = {} totals = {} title = _('Group...
tgroups[gid][prefix + 'members'].append(
tgroups[gid][prefix + 'memberUid'].append(
def main(uri, http_user, sort = "name", order = "asc"): """List all groups and provileges on the system, displaying them in a nice HTML page. """ start = time.time() users.reload() groups.reload() #profiles.reload() g = groups.groups users.Select(users.FILTER_STANDARD) tgroups = {} totals = {} title = _('Group...
('members', _('Current members')), ('rsp-members', _('Current responsibles')), ('gst-members', _('Current guests')) ):
('memberUid', _('Current members')), ('rsp-memberUid', _('Current responsibles')), ('gst-memberUid', _('Current guests')) ):
def html_build_group(index, tgroups = tgroups ): gid = ordered[index] name = g[gid]['name'] html_data = '''
if prim_memb != []:
if prim_memb != set():
def DeleteGroup(self, name, del_users, no_archive, bygid = None, batch=False): """ Delete an Licorn group """ if name is None and bygid is None: raise exceptions.BadArgumentError, "You must specify a name or a GID."
return GroupsController.is_standard_gid(gid) and GroupsController.groups[gid]['memberUid'] == []
return GroupsController.is_standard_gid(gid) and GroupsController.groups[gid]['memberUid'] == set()
def is_empty_gid(gid): return GroupsController.is_standard_gid(gid) and GroupsController.groups[gid]['memberUid'] == []
(LMC.users.Select(filters.STD), LMC.users.confirm_uid), (LMC.users.Select(filters.SYSUNRSTR), LMC.users.confirm_uid)
(LMC.users.Select(filters.STD), lambda x: x), (LMC.users.Select(filters.SYSUNRSTR), lambda x: x)
def del_user(self, opts, args): """ delete a user account. """ include_id_lists=[ (opts.login, LMC.users.login_to_uid), (opts.uid, LMC.users.confirm_uid) ] exclude_id_lists=[ (opts.exclude, LMC.users.guess_identifier), (opts.exclude_login, LMC.users.login_to_uid), (opts.exclude_uid, LMC.users.confirm_uid), ([os.getuid(...
(LMC.groups.Select(filters.STD), LMC.groups.confirm_gid), (LMC.groups.Select(filters.SYSUNRSTR), LMC.groups.confirm_gid)
(LMC.groups.Select(filters.STD), lambda x: x), (LMC.groups.Select(filters.SYSUNRSTR), lambda x: x)
def del_group(self, opts, args): """ delete an Licorn group. """ selection = filters.NONE if opts.empty: selection = filters.EMPTY include_id_lists=[ (opts.name, LMC.groups.name_to_gid), (opts.gid, LMC.groups.confirm_gid), ] exclude_id_lists = [ (opts.exclude, LMC.groups.guess_identifier), (opts.exclude_group, LMC.grou...
(LMC.profiles.Select(filters.ALL), LMC.profiles.guess_identifier)
(LMC.profiles.Select(filters.ALL), lambda x: x)
def del_profile(self, opts, args): """ Delete a system wide User profile. """ include_id_lists=[ (opts.name, LMC.profiles.name_to_group), (opts.group, LMC.profiles.confirm_group) ] exclude_id_lists=[ (opts.exclude, LMC.profiles.guess_identifier) ] if opts.all and ( ( # NOTE TO THE READER: don't event try to simplify th...
'Are you sure you want to delete all users ?',
'Are you sure you want to delete all privileges?',
def del_privilege(self, opts, args): if opts.privileges_to_remove is None and len(args) == 2: opts.privileges_to_remove = args[1] include_priv_lists=[ (opts.privileges_to_remove, LMC.privileges.confirm_privilege), ] exclude_priv_lists=[ (opts.exclude, LMC.privileges.confirm_privilege), ] if opts.all and ( ( # NOTE TO T...
(LMC.privileges.Select(filters.ALL), LMC.privileges.confirm_privilege),
(LMC.privileges.Select(filters.ALL), lambda x: x),
def del_privilege(self, opts, args): if opts.privileges_to_remove is None and len(args) == 2: opts.privileges_to_remove = args[1] include_priv_lists=[ (opts.privileges_to_remove, LMC.privileges.confirm_privilege), ] exclude_priv_lists=[ (opts.exclude, LMC.privileges.confirm_privilege), ] if opts.all and ( ( # NOTE TO T...
(LMC.groups.Select(filters.STD), LMC.groups.confirm_gid), (LMC.groups.Select(filters.SYSUNRSTR), LMC.groups.confirm_gid)
(LMC.groups.Select(filters.STD), lambda x: x), (LMC.groups.Select(filters.SYSUNRSTR), lambda x: x)
def mod_group(self, opts, args): """ Modify a group. """ include_id_lists=[ (opts.name, LMC.groups.name_to_gid), (opts.gid, LMC.groups.confirm_gid) ] exclude_id_lists = [ (opts.exclude, LMC.groups.guess_identifier), (opts.exclude_group, LMC.groups.name_to_gid), (opts.exclude_gid, LMC.groups.confirm_gid) ] if opts.all a...