rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
group_home_acl = self.BuildGroupACL(gid) group_home_acl['path'] = group_home
group_home_acl = self.BuildGroupACL(gid) group_home_acl['path'] = group_home
def __check_group(self, group, minimal=True, batch=False, auto_answer=None, force=False):
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
def __check_group(self, group, minimal=True, batch=False, auto_answer=None, force=False):
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
if os.path.exists(group_home) and os.path.isdir(os.path.realpath(group_home)):
if os.path.exists(group_home) \ and os.path.isdir(os.path.realpath(group_home)):
def __check_group(self, group, minimal=True, batch=False, auto_answer=None, force=False):
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
def __check_group(self, group, minimal=True, batch=False, auto_answer=None, force=False):
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
logging.progress("Checking shared group dir %s..." % \
logging.progress("Checking shared group dir %s..." %
def __check_group(self, group, minimal=True, batch=False, auto_answer=None, force=False):
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
logging.warning("Shared group dir %s is missing, please repair this first." \ % styles.stylize(styles.ST_PATH, group_home))
logging.warning( "Shared group dir %s is missing, please repair this first." % styles.stylize(styles.ST_PATH, group_home))
def __check_group(self, group, minimal=True, batch=False, auto_answer=None, force=False):
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
def __check_group(self, group, minimal=True, batch=False, auto_answer=None, force=False):
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
def __check_group(self, group, minimal=True, batch=False, auto_answer=None, force=False):
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
"Checking %s symlinks in members homes, this can take a while..." \ % styles.stylize(styles.ST_NAME, group))
"Checking %s symlinks in members homes, this can be long…" % styles.stylize(styles.ST_NAME, group))
def __check_group(self, group, minimal=True, batch=False, auto_answer=None, force=False):
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
def __check_group(self, group, minimal=True, batch=False, auto_answer=None, force=False):
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
"""Check the groups, the cache. If not system, check the shared dir, the resps/guests, the members symlinks."""
""" Check the groups, the cache. If not system, check the shared dir, the resps/guests, the members symlinks."""
def CheckGroups(self, groups_to_check = [], minimal=True, batch=False, auto_answer=None, force=False): """Check the groups, the cache. If not system, check the shared dir, the resps/guests, the members symlinks."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
GroupsController.configuration.CheckBaseDirs(minimal, batch, auto_answer)
GroupsController.configuration.CheckBaseDirs( minimal, batch, auto_answer)
def CheckGroups(self, groups_to_check = [], minimal=True, batch=False, auto_answer=None, force=False): """Check the groups, the cache. If not system, check the shared dir, the resps/guests, the members symlinks."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
raise exceptions.LicornCheckError("Some group(s) check(s) didn't pass, or weren't corrected.")
raise exceptions.LicornCheckError( "Some group(s) check(s) didn't pass, or weren't corrected.")
def _chk(group): return self.__check_group(group, minimal=minimal, batch=batch, auto_answer=auto_answer, force=force)
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
"""For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set."""
""" For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set. """
def CheckGroupSymlinks(self, gid=None, group=None, oldname=None, delete=False, strip_prefix=None, batch=False, auto_answer=None): """For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
link_basename = GroupsController.groups[gid]['name'].replace(strip_prefix, '', 1)
link_basename = \ GroupsController.groups[gid]['name'].replace(strip_prefix, '', 1)
def CheckGroupSymlinks(self, gid=None, group=None, oldname=None, delete=False, strip_prefix=None, batch=False, auto_answer=None): """For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
logging.info("Deleted symlink %s." % \
logging.info("Deleted symlink %s." %
def CheckGroupSymlinks(self, gid=None, group=None, oldname=None, delete=False, strip_prefix=None, batch=False, auto_answer=None): """For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
"Unable to delete symlink %s (was: %s)." \ % (styles.stylize(styles.ST_LINK, link), str(e)) )
"Unable to delete symlink %s (was: %s)." % ( styles.stylize(styles.ST_LINK, link), str(e)))
def CheckGroupSymlinks(self, gid=None, group=None, oldname=None, delete=False, strip_prefix=None, batch=False, auto_answer=None): """For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
if e.errno == 2 and link_src_old and link_src_old == os.readlink(link):
if e.errno == 2 and link_src_old \ and link_src_old == os.readlink(link):
def CheckGroupSymlinks(self, gid=None, group=None, oldname=None, delete=False, strip_prefix=None, batch=False, auto_answer=None): """For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
logging.info("Deleted old symlink %s." % styles.stylize(styles.ST_LINK, link) )
logging.info("Deleted old symlink %s." % styles.stylize(styles.ST_LINK, link))
def CheckGroupSymlinks(self, gid=None, group=None, oldname=None, delete=False, strip_prefix=None, batch=False, auto_answer=None): """For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
raise exceptions.LicornRuntimeError("Unable to read symlink %s (error was: %s)." % (link, str(e)) )
raise exceptions.LicornRuntimeError( "Unable to read symlink %s (error was: %s)." % ( link, str(e)))
def CheckGroupSymlinks(self, gid=None, group=None, oldname=None, delete=False, strip_prefix=None, batch=False, auto_answer=None): """For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
warn_message = logging.SYSG_USER_LACKS_SYMLINK % (styles.stylize(styles.ST_LOGIN, user), styles.stylize(styles.ST_NAME, link_basename))
warn_message = logging.SYSG_USER_LACKS_SYMLINK % ( styles.stylize(styles.ST_LOGIN, user), styles.stylize(styles.ST_NAME, link_basename))
def CheckGroupSymlinks(self, gid=None, group=None, oldname=None, delete=False, strip_prefix=None, batch=False, auto_answer=None): """For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
fsapi.make_symlink(link_src, link_dst, batch = batch, auto_answer = auto_answer)
fsapi.make_symlink(link_src, link_dst, batch=batch, auto_answer=auto_answer)
def CheckGroupSymlinks(self, gid=None, group=None, oldname=None, delete=False, strip_prefix=None, batch=False, auto_answer=None): """For each member of a group, verify member has a symlink to the shared group dir inside his home (or under level 2 directory). If not, create the link. Eventually delete links pointing to the old group name if it is set."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
""" Set permissive or not permissive the shared directory of the group 'name'. """
""" Set permissive or not permissive the shared directory of the group 'name'. """
def SetSharedDirPermissiveness(self, name=None, permissive=True): """ Set permissive or not permissive the shared directory of the group 'name'. """ if name is None: raise exceptions.BadArgumentError, "You must specify a group name."
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
def SetSharedDirPermissiveness(self, name=None, permissive=True): """ Set permissive or not permissive the shared directory of the group 'name'. """ if name is None: raise exceptions.BadArgumentError, "You must specify a group name."
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
self.CheckGroups( [ name ], batch=True)
self.CheckGroups([ name ], batch=True)
def SetSharedDirPermissiveness(self, name=None, permissive=True): """ Set permissive or not permissive the shared directory of the group 'name'. """ if name is None: raise exceptions.BadArgumentError, "You must specify a group name."
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
logging.progress("Group %s is already%s permissive." % (styles.stylize(styles.ST_NAME, name), qualif) )
logging.info("Group %s is already%s permissive." % ( styles.stylize(styles.ST_NAME, name), qualif) )
def SetSharedDirPermissiveness(self, name=None, permissive=True): """ Set permissive or not permissive the shared directory of the group 'name'. """ if name is None: raise exceptions.BadArgumentError, "You must specify a group name."
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
raise exceptions.BadArgumentError, "You must specify a group name or a GID."
raise exceptions.BadArgumentError( "You must specify a group name or a GID.")
def is_permissive(self, name = None, gid = None): """ Return True if the shared dir of the group is permissive."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
home = '%s/%s/%s' % (GroupsController.configuration.defaults.home_base_path, GroupsController.configuration.groups.names['plural'], name)
home = '%s/%s/%s' % ( GroupsController.configuration.defaults.home_base_path, GroupsController.configuration.groups.names['plural'], name)
def is_permissive(self, name = None, gid = None): """ Return True if the shared dir of the group is permissive."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
def is_permissive(self, name = None, gid = None): """ Return True if the shared dir of the group is permissive."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
logging.warning('''Shared dir %s doesn't exist, please run "licorn-check group --name %s" to fix.''' % (styles.stylize(styles.ST_PATH, home), styles.stylize(styles.ST_NAME, name)), once = True)
logging.warning('''Shared dir %s doesn't exist, please ''' '''run "licorn-check group --name %s" to fix.''' % ( styles.stylize(styles.ST_PATH, home), styles.stylize(styles.ST_NAME, name)), once=True)
def is_permissive(self, name = None, gid = None): """ Return True if the shared dir of the group is permissive."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
raise exceptions.LicornIOError("IO error on %s (was: %s)." % (home, e))
raise exceptions.LicornIOError("IO error on %s (was: %s)." % (home, e))
def is_permissive(self, name = None, gid = None): """ Return True if the shared dir of the group is permissive."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
logging.warning(logging.MODULE_POSIX1E_IMPORT_ERROR % e, once = True)
logging.warning(logging.MODULE_POSIX1E_IMPORT_ERROR % e, once=True)
def is_permissive(self, name = None, gid = None): """ Return True if the shared dir of the group is permissive."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
def group_exists(name = None, gid = None):
def group_exists(name=None, gid=None):
def group_exists(name = None, gid = None): """Return true if the group or gid exists on the system. """
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
raise exceptions.BadArgumentError("You must specify a GID or a name to test existence of.")
raise exceptions.BadArgumentError( "You must specify a GID or a name to test existence of.")
def group_exists(name = None, gid = None): """Return true if the group or gid exists on the system. """
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
"""Return all members of a group, which are not members of this group in their primary group."""
""" Return all members of a group, which are not members of this group in their primary group."""
def auxilliary_members(name): """Return all members of a group, which are not members of this group in their primary group."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
return GroupsController.groups[GroupsController.name_to_gid(name)]['memberUid']
return GroupsController.groups[ GroupsController.name_to_gid(name)]['memberUid']
def auxilliary_members(name): """Return all members of a group, which are not members of this group in their primary group."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
return GroupsController.primary_members(name).union(GroupsController.auxilliary_members(name))
return GroupsController.primary_members(name).union( GroupsController.auxilliary_members(name))
def all_members(name): """Return all members of a given group name."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
return gid < GroupsController.configuration.groups.gid_min or gid > GroupsController.configuration.groups.gid_max
return gid < GroupsController.configuration.groups.gid_min \ or gid > GroupsController.configuration.groups.gid_max
def is_system_gid(gid): """ Return true if gid is system. """ return gid < GroupsController.configuration.groups.gid_min or gid > GroupsController.configuration.groups.gid_max
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
logging.debug2("filtering %d against %d and %d." % (gid, GroupsController.configuration.groups.gid_min, GroupsController.configuration.groups.gid_max)) return gid >= GroupsController.configuration.groups.gid_min and gid <= GroupsController.configuration.groups.gid_max
return gid >= GroupsController.configuration.groups.gid_min \ and gid <= GroupsController.configuration.groups.gid_max
def is_standard_gid(gid): """ Return true if gid is system. """ logging.debug2("filtering %d against %d and %d." % (gid, GroupsController.configuration.groups.gid_min, GroupsController.configuration.groups.gid_max)) return gid >= GroupsController.configuration.groups.gid_min and gid <= GroupsController.configuration.groups.gid_max
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
return GroupsController.is_system_gid(GroupsController.name_to_gid(name))
return GroupsController.is_system_gid( GroupsController.name_to_gid(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
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
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
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
return GroupsController.is_standard_gid(GroupsController.name_to_gid(name))
return GroupsController.is_standard_gid( GroupsController.name_to_gid(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
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
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
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
return GroupsController.is_empty_gid(GroupsController.name_to_gid(name))
return GroupsController.is_empty_gid( GroupsController.name_to_gid(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
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
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
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
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."""
2c25685af98e96114695a04efeb86385220aeb9c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2c25685af98e96114695a04efeb86385220aeb9c/groups.py
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 harmless and I don't see any reason # apart from obfuscation which is not acceptable. # Anyway, to see a system group, user must forge an URL. try: group = g[groups.name_to_gid(name)] members = groups.all_members(name) if members != []: members.sort() members_html = ''' <h2>%s</h2> <div style="text-align:left;">%s</div> <table class="group_members"> <tr> <th><strong>%s</strong></th> <th><strong>%s</strong></th> <th><strong>%s</strong></th> </tr> ''' % ( _('Members'), _('(ordered by login)'), _('Full Name'), _('Identifier'), _('UID') ) 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 ) members_html += "\n".join(map(user_line, members)) + '</table>' else: members_html = "<h2>%s</h2>" % _('No members in this group.') if not groups.is_system_group(name): resps = groups.all_members(configuration.groups.resp_prefix + name) if resps != []: resps.sort() resps_html = ''' <h2>%s</h2> <div style="text-align:left;">%s</div> <table class="group_members"> <tr> <th><strong>%s</strong></th> <th><strong>%s</strong></th> <th><strong>%s</strong></th> </tr> %s </table> ''' % ( _('Responsibles'), _('(ordered by login)'), _('Full Name'), _('Identifier'), _('UID'), "\n".join(map(user_line, resps)) ) else: resps_html = "<h2>%s</h2>" % \ _('No responsibles for this group.') guests = \ groups.all_members(configuration.groups.guest_prefix + name) if guests != []: guests.sort() guests_html = ''' <h2>%s</h2> <div style="text-align:left;">%s</div> <table class="group_members"> <tr> <th><strong>%s</strong></th> <th><strong>%s</strong></th> <th><strong>%s</strong></th> </tr> %s </table> ''' % ( _('Guests'), _('(ordered by login)'), _('Full Name'), _('Identifier'), _('UID'), "\n".join(map(user_line, guests)) ) else: guests_html = "<h2>%s</h2>" % _('No guests in this group.') else: resps_html = guests_html = '' form_name = "group_print_form" data += ''' <div id="details"> <form name="%s" id="%s" action="/groups/view/%s" method="post"> <table id="user_account"> <tr><td><strong>%s</strong><br />%s</td> <td class="not_modifiable">%d</td></tr> <tr><td><strong>%s</strong><br />%s</td> <td class="not_modifiable">%s</td></tr> <tr><td colspan="2" class="double_selector">%s</td></tr> <tr><td colspan="2" class="double_selector">%s</td></tr> <tr><td colspan="2" class="double_selector">%s</td></tr> <tr> <td>%s</td> <td class="right">%s</td> </tr> </table> </form> </div> ''' % ( form_name, form_name, name, _('GID'), _('immutable'), group['gidNumber'], _('Name'), _('immutable'), name, members_html, resps_html, guests_html, w.button(_('<< Go back'), "/groups/list", accesskey=_('B')), w.submit('print', _('Print') + ' >>', onClick="javascript:window.print(); return false;", accesskey=_('P')) ) except exceptions.LicornException, e: data += w.error(_("Group %s doesn't exist (%s, %s)!") % ( name, "group = g[groups.name_to_gid(name)]", e)) return (w.HTTP_TYPE_TEXT, w.page(title, data + w.page_body_end()))
1f04a4fc30ab0f9646c851ccb0f79e2bc831824d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1f04a4fc30ab0f9646c851ccb0f79e2bc831824d/groups.py
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 )
1f04a4fc30ab0f9646c851ccb0f79e2bc831824d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1f04a4fc30ab0f9646c851ccb0f79e2bc831824d/groups.py
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 )
1f04a4fc30ab0f9646c851ccb0f79e2bc831824d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1f04a4fc30ab0f9646c851ccb0f79e2bc831824d/groups.py
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 = {} if sys: groups_filters_lists_ids = ( (name, ( _('Manage members'), _('Users not yet members'), _('Current members') ), 'members' ), (configuration.groups.resp_prefix + name, None, '&#160;' ), (configuration.groups.guest_prefix + name, None, '&#160;' ) ) else: groups_filters_lists_ids = ( (name, [_('Manage members'), _('Users not yet members'), _('Current members')], 'members'), (configuration.groups.resp_prefix + name, [_('Manage responsibles'), _('Users not yet responsibles'), _('Current responsibles')], 'resps'), (configuration.groups.guest_prefix + name, [_('Manage guests'), _('Users not yet guests'), _('Current guests')], 'guests') ) for (gname, titles, id) in groups_filters_lists_ids: if titles is None: dbl_lists[gname] = id else: users.Select(users.FILTER_STANDARD) dest = g[groups.name_to_gid(gname)]['memberUid'][:] source = [ u[uid]['login'] for uid in users.filtered_users ] for current in g[groups.name_to_gid(gname)]['memberUid']: try: source.remove(current) except ValueError: dest.remove(current) dest.sort() source.sort() dbl_lists[gname] = w.doubleListBox(titles, id, source, dest) def descr(desc, system): return w.input('description', desc, size=30, maxlength=256, accesskey='D') 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)) def permissive(perm, system): if system: return '' else: return ''' <tr> <td><strong>%s</strong></td> <td class="right">%s</td> </tr> ''' % (_('Permissive shared dir?'), w.checkbox('permissive', "True", "Oui", checked = perm )) form_name = "group_edit_form" data += '''<div id="edit_form">
1f04a4fc30ab0f9646c851ccb0f79e2bc831824d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1f04a4fc30ab0f9646c851ccb0f79e2bc831824d/groups.py
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 = {} if sys: groups_filters_lists_ids = ( (name, ( _('Manage members'), _('Users not yet members'), _('Current members') ), 'members' ), (configuration.groups.resp_prefix + name, None, '&#160;' ), (configuration.groups.guest_prefix + name, None, '&#160;' ) ) else: groups_filters_lists_ids = ( (name, [_('Manage members'), _('Users not yet members'), _('Current members')], 'members'), (configuration.groups.resp_prefix + name, [_('Manage responsibles'), _('Users not yet responsibles'), _('Current responsibles')], 'resps'), (configuration.groups.guest_prefix + name, [_('Manage guests'), _('Users not yet guests'), _('Current guests')], 'guests') ) for (gname, titles, id) in groups_filters_lists_ids: if titles is None: dbl_lists[gname] = id else: users.Select(users.FILTER_STANDARD) dest = g[groups.name_to_gid(gname)]['members'][:] source = [ u[uid]['login'] for uid in users.filtered_users ] for current in g[groups.name_to_gid(gname)]['members']: try: source.remove(current) except ValueError: dest.remove(current) dest.sort() source.sort() dbl_lists[gname] = w.doubleListBox(titles, id, source, dest) def descr(desc, system): return w.input('description', desc, size=30, maxlength=256, accesskey='D') 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)) def permissive(perm, system): if system: return '' else: return ''' <tr> <td><strong>%s</strong></td> <td class="right">%s</td> </tr> ''' % (_('Permissive shared dir?'), w.checkbox('permissive', "True", "Oui", checked = perm )) form_name = "group_edit_form" data += '''<div id="edit_form">
84927f63ccb0390487678873dbd1c49eb749f5a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/84927f63ccb0390487678873dbd1c49eb749f5a9/groups.py
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 = {} if sys: groups_filters_lists_ids = ( (name, ( _('Manage members'), _('Users not yet members'), _('Current members') ), 'members' ), (configuration.groups.resp_prefix + name, None, '&#160;' ), (configuration.groups.guest_prefix + name, None, '&#160;' ) ) else: groups_filters_lists_ids = ( (name, [_('Manage members'), _('Users not yet members'), _('Current members')], 'members'), (configuration.groups.resp_prefix + name, [_('Manage responsibles'), _('Users not yet responsibles'), _('Current responsibles')], 'resps'), (configuration.groups.guest_prefix + name, [_('Manage guests'), _('Users not yet guests'), _('Current guests')], 'guests') ) for (gname, titles, id) in groups_filters_lists_ids: if titles is None: dbl_lists[gname] = id else: users.Select(users.FILTER_STANDARD) dest = g[groups.name_to_gid(gname)]['members'][:] source = [ u[uid]['login'] for uid in users.filtered_users ] for current in g[groups.name_to_gid(gname)]['members']: try: source.remove(current) except ValueError: dest.remove(current) dest.sort() source.sort() dbl_lists[gname] = w.doubleListBox(titles, id, source, dest) def descr(desc, system): return w.input('description', desc, size=30, maxlength=256, accesskey='D') 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)) def permissive(perm, system): if system: return '' else: return ''' <tr> <td><strong>%s</strong></td> <td class="right">%s</td> </tr> ''' % (_('Permissive shared dir?'), w.checkbox('permissive', "True", "Oui", checked = perm )) form_name = "group_edit_form" data += '''<div id="edit_form">
84927f63ccb0390487678873dbd1c49eb749f5a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/84927f63ccb0390487678873dbd1c49eb749f5a9/groups.py
skel(group['skel'], sys),
skel(group['groupSkel'], sys),
def permissive(perm, system):
84927f63ccb0390487678873dbd1c49eb749f5a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/84927f63ccb0390487678873dbd1c49eb749f5a9/groups.py
'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 = _('Groups') data = w.page_body_start(uri, http_user, ctxtnav, title) if order == "asc": reverseorder = "desc" else: reverseorder = "asc" data += '<table>\n <tr>\n' sortcols = ( ('', '', False), ("name", _("Name"), True), ("description", _("Description"), True), ("skel", _("Skeleton"), True), ("permissive", _("Perm."), True), ('members', _("Members"), False), ("resps", _("Responsibles"), False), ("guests", _("Guests"), False) ) for (column, name, can_sort) in sortcols: if can_sort: if column == sort: data += ''' <th><img src="/images/sort_%s.gif" alt="%s" />&#160; <a href="/groups/list/%s/%s" title="%s">%s</a> </th>\n''' % (order, _('%s order') % order, column, reverseorder, _('Click to sort in reverse order.'), name) else: data += ''' <th><a href="/groups/list/%s/asc" title="%s">%s</a></th>\n''' % (column, _('Click to sort on this column.'), name) else: data += ' <th>%s</th>\n' % name data += ' </tr>\n' for (filter, filter_name) in ( (groups.FILTER_STANDARD, _('Groups')), (groups.FILTER_PRIVILEGED, _("Privileges")) ): tgroups = {} ordered = {} totals[filter_name] = 0 groups.Select(filter) for gid in groups.filtered_groups: group = groups.groups[gid] name = group['name'] tgroups[gid] = { 'name' : name, 'description' : group['description'] + name, 'skel' : group['skel'] + name, 'permissive' : str(group['permissive']) + name } totals[filter_name] += 1 # index on the column choosen for sorting, and keep trace of the uid # to find account data back after ordering. ordered[hlstr.validate_name(tgroups[gid][sort])] = gid tgroups[gid]['members'] = [] for member in groups.groups[gid]['members']: if not users.is_system_login(member): tgroups[gid]['members'].append( users.users[users.login_to_uid(member)]) if not groups.is_system_gid(gid): for prefix in ( configuration.groups.resp_prefix, configuration.groups.guest_prefix): tgroups[gid][prefix + 'members'] = [] for member in \ groups.groups[groups.name_to_gid( prefix + name)]['members']: if not users.is_system_login(member): tgroups[gid][prefix + 'members'].append( users.users[users.login_to_uid(member)]) gkeys = ordered.keys() gkeys.sort() if order == "desc": gkeys.reverse() def html_build_group(index, tgroups = tgroups ): gid = ordered[index] name = g[gid]['name'] html_data = ''' <tr class="userdata"> <td class="nopadding"> <a href="/groups/view/%s" title="%s" class="view-entry"> <span class="view-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> <td class="group_name"> <a href="/groups/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td class="group_name"> <a href="/groups/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td class="right"> <a href="/groups/edit/%s">%s</a> </td> ''' % ( name, _('''View the group details, its parameters, members, responsibles and guests. From there you can print all group-related informations.'''), name, g[gid]['description'], name, name, g[gid]['description'], g[gid]['description'], name, g[gid]['skel']) if groups.is_system_gid(gid): html_data += '<td>&#160;</td>' else: if g[gid]['permissive']: html_data += ''' <td class="user_action_center"> <a href="/groups/lock/%s" title="%s"> <img src="/images/16x16/unlocked.png" alt="%s"/></a> </td> ''' % (name, _('''Shared group directory is currently ''' '''<strong>permissive</strong>. Click to deactivate ''' '''permissiveness.'''), _('Group is currently permissive.')) else: html_data += ''' <td class="user_action_center"> <a href="/groups/unlock/%s" title="%s"> <img src="/images/16x16/locked.png" alt="%s"/></a> </td> ''' % (name, _('''Shared group directory is currently <strong>NOT</strong> permissive. Click ti activate permissiveness.'''), _('Group is NOT permissive.')) for (keyname, text) in ( ('members', _('Current members')), ('rsp-members', _('Current responsibles')), ('gst-members', _('Current guests')) ): if tgroups[gid].has_key(keyname): accounts = {} uordered = {} for member in tgroups[gid][keyname]: uid = member['uidNumber'] accounts[uid] = { 'login': member['login'], 'gecos': member['gecos'], 'gecos_sort': member['gecos'] + member['login'] } uordered[hlstr.validate_name( accounts[uid]['gecos_sort'], aggressive=True)] = uid memberkeys = uordered.keys() memberkeys.sort() mbdata = '''<table><tr><th>%s</th><th>%s</th> <th>%s</th></tr>\n''' % (_('Full Name'), _('Identifier'), _('UID')) for member in memberkeys: uid = uordered[member] mbdata += '''<tr><td>%s</td><td>%s</td> <td>%d</td></tr>\n''' % (accounts[uid]['gecos'], accounts[uid]['login'], uid) mbdata += '</table>' nb = len(tgroups[gid][keyname]) if nb == 0: html_data += '''<td class="right faded">%s</td>\n''' % \ _('none') else: html_data += '''<td class="right"> <a class="nounder" title="<h4>%s</h4><br />%s"> <strong>%d</strong>&#160;<img src="/images/16x16/details-light.png" alt="%s" /></a></td>\n''' % (text, mbdata, nb, _('See %s of group %s.') % (text, name)) else: html_data += '''<td>&#160;</td>\n''' if groups.is_system_gid(gid): html_data += '<td colspan="1">&#160;</td></tr>\n' else: html_data += ''' <!-- TODO: implement skel reapplying for all users of curent group <td class="user_action"> <a href="/users/skel/%s" title="%s" class="reapply-skel"> <span class="reapply-skel">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> --> <td class="user_action"> <a href="/groups/delete/%s" title="%s" class="delete-entry"> <span class="delete-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> </tr> ''' % (name, _('''This will rebuild his/her desktop from scratch, with defaults icons and so on. <br /><br />The user must be disconnected for the operation to be completely successfull.'''), name, _('''Definitely remove this group from system.''')) return html_data data += '<tr><td class="group_class" colspan="8">%s</td></tr>\n%s' % ( filter_name, ''.join(map(html_build_group, gkeys))) def print_totals(totals): output = "" for total in totals: if totals[total] != 0: output += ''' <tr class="list_total"> <td colspan="6" class="total_left">%s</td> <td colspan="6" class="total_right">%d</td> </tr> ''' % (_('number of <strong>%s</strong>:') % total, totals[total]) return output data += ''' <tr> <td colspan="6">&#160;</td></tr> %s <tr class="list_total"> <td colspan="6" class="total_left"><strong>%s</strong></td> <td colspan="6" class="total_right">%d</td> </tr>
84927f63ccb0390487678873dbd1c49eb749f5a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/84927f63ccb0390487678873dbd1c49eb749f5a9/groups.py
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 = _('Groups') data = w.page_body_start(uri, http_user, ctxtnav, title) if order == "asc": reverseorder = "desc" else: reverseorder = "asc" data += '<table>\n <tr>\n' sortcols = ( ('', '', False), ("name", _("Name"), True), ("description", _("Description"), True), ("skel", _("Skeleton"), True), ("permissive", _("Perm."), True), ('members', _("Members"), False), ("resps", _("Responsibles"), False), ("guests", _("Guests"), False) ) for (column, name, can_sort) in sortcols: if can_sort: if column == sort: data += ''' <th><img src="/images/sort_%s.gif" alt="%s" />&#160; <a href="/groups/list/%s/%s" title="%s">%s</a> </th>\n''' % (order, _('%s order') % order, column, reverseorder, _('Click to sort in reverse order.'), name) else: data += ''' <th><a href="/groups/list/%s/asc" title="%s">%s</a></th>\n''' % (column, _('Click to sort on this column.'), name) else: data += ' <th>%s</th>\n' % name data += ' </tr>\n' for (filter, filter_name) in ( (groups.FILTER_STANDARD, _('Groups')), (groups.FILTER_PRIVILEGED, _("Privileges")) ): tgroups = {} ordered = {} totals[filter_name] = 0 groups.Select(filter) for gid in groups.filtered_groups: group = groups.groups[gid] name = group['name'] tgroups[gid] = { 'name' : name, 'description' : group['description'] + name, 'skel' : group['skel'] + name, 'permissive' : str(group['permissive']) + name } totals[filter_name] += 1 # index on the column choosen for sorting, and keep trace of the uid # to find account data back after ordering. ordered[hlstr.validate_name(tgroups[gid][sort])] = gid tgroups[gid]['members'] = [] for member in groups.groups[gid]['members']: if not users.is_system_login(member): tgroups[gid]['members'].append( users.users[users.login_to_uid(member)]) if not groups.is_system_gid(gid): for prefix in ( configuration.groups.resp_prefix, configuration.groups.guest_prefix): tgroups[gid][prefix + 'members'] = [] for member in \ groups.groups[groups.name_to_gid( prefix + name)]['members']: if not users.is_system_login(member): tgroups[gid][prefix + 'members'].append( users.users[users.login_to_uid(member)]) gkeys = ordered.keys() gkeys.sort() if order == "desc": gkeys.reverse() def html_build_group(index, tgroups = tgroups ): gid = ordered[index] name = g[gid]['name'] html_data = ''' <tr class="userdata"> <td class="nopadding"> <a href="/groups/view/%s" title="%s" class="view-entry"> <span class="view-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> <td class="group_name"> <a href="/groups/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td class="group_name"> <a href="/groups/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td class="right"> <a href="/groups/edit/%s">%s</a> </td> ''' % ( name, _('''View the group details, its parameters, members, responsibles and guests. From there you can print all group-related informations.'''), name, g[gid]['description'], name, name, g[gid]['description'], g[gid]['description'], name, g[gid]['skel']) if groups.is_system_gid(gid): html_data += '<td>&#160;</td>' else: if g[gid]['permissive']: html_data += ''' <td class="user_action_center"> <a href="/groups/lock/%s" title="%s"> <img src="/images/16x16/unlocked.png" alt="%s"/></a> </td> ''' % (name, _('''Shared group directory is currently ''' '''<strong>permissive</strong>. Click to deactivate ''' '''permissiveness.'''), _('Group is currently permissive.')) else: html_data += ''' <td class="user_action_center"> <a href="/groups/unlock/%s" title="%s"> <img src="/images/16x16/locked.png" alt="%s"/></a> </td> ''' % (name, _('''Shared group directory is currently <strong>NOT</strong> permissive. Click ti activate permissiveness.'''), _('Group is NOT permissive.')) for (keyname, text) in ( ('members', _('Current members')), ('rsp-members', _('Current responsibles')), ('gst-members', _('Current guests')) ): if tgroups[gid].has_key(keyname): accounts = {} uordered = {} for member in tgroups[gid][keyname]: uid = member['uidNumber'] accounts[uid] = { 'login': member['login'], 'gecos': member['gecos'], 'gecos_sort': member['gecos'] + member['login'] } uordered[hlstr.validate_name( accounts[uid]['gecos_sort'], aggressive=True)] = uid memberkeys = uordered.keys() memberkeys.sort() mbdata = '''<table><tr><th>%s</th><th>%s</th> <th>%s</th></tr>\n''' % (_('Full Name'), _('Identifier'), _('UID')) for member in memberkeys: uid = uordered[member] mbdata += '''<tr><td>%s</td><td>%s</td> <td>%d</td></tr>\n''' % (accounts[uid]['gecos'], accounts[uid]['login'], uid) mbdata += '</table>' nb = len(tgroups[gid][keyname]) if nb == 0: html_data += '''<td class="right faded">%s</td>\n''' % \ _('none') else: html_data += '''<td class="right"> <a class="nounder" title="<h4>%s</h4><br />%s"> <strong>%d</strong>&#160;<img src="/images/16x16/details-light.png" alt="%s" /></a></td>\n''' % (text, mbdata, nb, _('See %s of group %s.') % (text, name)) else: html_data += '''<td>&#160;</td>\n''' if groups.is_system_gid(gid): html_data += '<td colspan="1">&#160;</td></tr>\n' else: html_data += ''' <!-- TODO: implement skel reapplying for all users of curent group <td class="user_action"> <a href="/users/skel/%s" title="%s" class="reapply-skel"> <span class="reapply-skel">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> --> <td class="user_action"> <a href="/groups/delete/%s" title="%s" class="delete-entry"> <span class="delete-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> </tr> ''' % (name, _('''This will rebuild his/her desktop from scratch, with defaults icons and so on. <br /><br />The user must be disconnected for the operation to be completely successfull.'''), name, _('''Definitely remove this group from system.''')) return html_data data += '<tr><td class="group_class" colspan="8">%s</td></tr>\n%s' % ( filter_name, ''.join(map(html_build_group, gkeys))) def print_totals(totals): output = "" for total in totals: if totals[total] != 0: output += ''' <tr class="list_total"> <td colspan="6" class="total_left">%s</td> <td colspan="6" class="total_right">%d</td> </tr> ''' % (_('number of <strong>%s</strong>:') % total, totals[total]) return output data += ''' <tr> <td colspan="6">&#160;</td></tr> %s <tr class="list_total"> <td colspan="6" class="total_left"><strong>%s</strong></td> <td colspan="6" class="total_right">%d</td> </tr>
84927f63ccb0390487678873dbd1c49eb749f5a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/84927f63ccb0390487678873dbd1c49eb749f5a9/groups.py
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 = _('Groups') data = w.page_body_start(uri, http_user, ctxtnav, title) if order == "asc": reverseorder = "desc" else: reverseorder = "asc" data += '<table>\n <tr>\n' sortcols = ( ('', '', False), ("name", _("Name"), True), ("description", _("Description"), True), ("skel", _("Skeleton"), True), ("permissive", _("Perm."), True), ('members', _("Members"), False), ("resps", _("Responsibles"), False), ("guests", _("Guests"), False) ) for (column, name, can_sort) in sortcols: if can_sort: if column == sort: data += ''' <th><img src="/images/sort_%s.gif" alt="%s" />&#160; <a href="/groups/list/%s/%s" title="%s">%s</a> </th>\n''' % (order, _('%s order') % order, column, reverseorder, _('Click to sort in reverse order.'), name) else: data += ''' <th><a href="/groups/list/%s/asc" title="%s">%s</a></th>\n''' % (column, _('Click to sort on this column.'), name) else: data += ' <th>%s</th>\n' % name data += ' </tr>\n' for (filter, filter_name) in ( (groups.FILTER_STANDARD, _('Groups')), (groups.FILTER_PRIVILEGED, _("Privileges")) ): tgroups = {} ordered = {} totals[filter_name] = 0 groups.Select(filter) for gid in groups.filtered_groups: group = groups.groups[gid] name = group['name'] tgroups[gid] = { 'name' : name, 'description' : group['description'] + name, 'skel' : group['skel'] + name, 'permissive' : str(group['permissive']) + name } totals[filter_name] += 1 # index on the column choosen for sorting, and keep trace of the uid # to find account data back after ordering. ordered[hlstr.validate_name(tgroups[gid][sort])] = gid tgroups[gid]['members'] = [] for member in groups.groups[gid]['members']: if not users.is_system_login(member): tgroups[gid]['members'].append( users.users[users.login_to_uid(member)]) if not groups.is_system_gid(gid): for prefix in ( configuration.groups.resp_prefix, configuration.groups.guest_prefix): tgroups[gid][prefix + 'members'] = [] for member in \ groups.groups[groups.name_to_gid( prefix + name)]['members']: if not users.is_system_login(member): tgroups[gid][prefix + 'members'].append( users.users[users.login_to_uid(member)]) gkeys = ordered.keys() gkeys.sort() if order == "desc": gkeys.reverse() def html_build_group(index, tgroups = tgroups ): gid = ordered[index] name = g[gid]['name'] html_data = ''' <tr class="userdata"> <td class="nopadding"> <a href="/groups/view/%s" title="%s" class="view-entry"> <span class="view-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> <td class="group_name"> <a href="/groups/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td class="group_name"> <a href="/groups/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td class="right"> <a href="/groups/edit/%s">%s</a> </td> ''' % ( name, _('''View the group details, its parameters, members, responsibles and guests. From there you can print all group-related informations.'''), name, g[gid]['description'], name, name, g[gid]['description'], g[gid]['description'], name, g[gid]['skel']) if groups.is_system_gid(gid): html_data += '<td>&#160;</td>' else: if g[gid]['permissive']: html_data += ''' <td class="user_action_center"> <a href="/groups/lock/%s" title="%s"> <img src="/images/16x16/unlocked.png" alt="%s"/></a> </td> ''' % (name, _('''Shared group directory is currently ''' '''<strong>permissive</strong>. Click to deactivate ''' '''permissiveness.'''), _('Group is currently permissive.')) else: html_data += ''' <td class="user_action_center"> <a href="/groups/unlock/%s" title="%s"> <img src="/images/16x16/locked.png" alt="%s"/></a> </td> ''' % (name, _('''Shared group directory is currently <strong>NOT</strong> permissive. Click ti activate permissiveness.'''), _('Group is NOT permissive.')) for (keyname, text) in ( ('members', _('Current members')), ('rsp-members', _('Current responsibles')), ('gst-members', _('Current guests')) ): if tgroups[gid].has_key(keyname): accounts = {} uordered = {} for member in tgroups[gid][keyname]: uid = member['uidNumber'] accounts[uid] = { 'login': member['login'], 'gecos': member['gecos'], 'gecos_sort': member['gecos'] + member['login'] } uordered[hlstr.validate_name( accounts[uid]['gecos_sort'], aggressive=True)] = uid memberkeys = uordered.keys() memberkeys.sort() mbdata = '''<table><tr><th>%s</th><th>%s</th> <th>%s</th></tr>\n''' % (_('Full Name'), _('Identifier'), _('UID')) for member in memberkeys: uid = uordered[member] mbdata += '''<tr><td>%s</td><td>%s</td> <td>%d</td></tr>\n''' % (accounts[uid]['gecos'], accounts[uid]['login'], uid) mbdata += '</table>' nb = len(tgroups[gid][keyname]) if nb == 0: html_data += '''<td class="right faded">%s</td>\n''' % \ _('none') else: html_data += '''<td class="right"> <a class="nounder" title="<h4>%s</h4><br />%s"> <strong>%d</strong>&#160;<img src="/images/16x16/details-light.png" alt="%s" /></a></td>\n''' % (text, mbdata, nb, _('See %s of group %s.') % (text, name)) else: html_data += '''<td>&#160;</td>\n''' if groups.is_system_gid(gid): html_data += '<td colspan="1">&#160;</td></tr>\n' else: html_data += ''' <!-- TODO: implement skel reapplying for all users of curent group <td class="user_action"> <a href="/users/skel/%s" title="%s" class="reapply-skel"> <span class="reapply-skel">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> --> <td class="user_action"> <a href="/groups/delete/%s" title="%s" class="delete-entry"> <span class="delete-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> </tr> ''' % (name, _('''This will rebuild his/her desktop from scratch, with defaults icons and so on. <br /><br />The user must be disconnected for the operation to be completely successfull.'''), name, _('''Definitely remove this group from system.''')) return html_data data += '<tr><td class="group_class" colspan="8">%s</td></tr>\n%s' % ( filter_name, ''.join(map(html_build_group, gkeys))) def print_totals(totals): output = "" for total in totals: if totals[total] != 0: output += ''' <tr class="list_total"> <td colspan="6" class="total_left">%s</td> <td colspan="6" class="total_right">%d</td> </tr> ''' % (_('number of <strong>%s</strong>:') % total, totals[total]) return output data += ''' <tr> <td colspan="6">&#160;</td></tr> %s <tr class="list_total"> <td colspan="6" class="total_left"><strong>%s</strong></td> <td colspan="6" class="total_right">%d</td> </tr>
84927f63ccb0390487678873dbd1c49eb749f5a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/84927f63ccb0390487678873dbd1c49eb749f5a9/groups.py
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 = _('Groups') data = w.page_body_start(uri, http_user, ctxtnav, title) if order == "asc": reverseorder = "desc" else: reverseorder = "asc" data += '<table>\n <tr>\n' sortcols = ( ('', '', False), ("name", _("Name"), True), ("description", _("Description"), True), ("skel", _("Skeleton"), True), ("permissive", _("Perm."), True), ('members', _("Members"), False), ("resps", _("Responsibles"), False), ("guests", _("Guests"), False) ) for (column, name, can_sort) in sortcols: if can_sort: if column == sort: data += ''' <th><img src="/images/sort_%s.gif" alt="%s" />&#160; <a href="/groups/list/%s/%s" title="%s">%s</a> </th>\n''' % (order, _('%s order') % order, column, reverseorder, _('Click to sort in reverse order.'), name) else: data += ''' <th><a href="/groups/list/%s/asc" title="%s">%s</a></th>\n''' % (column, _('Click to sort on this column.'), name) else: data += ' <th>%s</th>\n' % name data += ' </tr>\n' for (filter, filter_name) in ( (groups.FILTER_STANDARD, _('Groups')), (groups.FILTER_PRIVILEGED, _("Privileges")) ): tgroups = {} ordered = {} totals[filter_name] = 0 groups.Select(filter) for gid in groups.filtered_groups: group = groups.groups[gid] name = group['name'] tgroups[gid] = { 'name' : name, 'description' : group['description'] + name, 'skel' : group['skel'] + name, 'permissive' : str(group['permissive']) + name } totals[filter_name] += 1 # index on the column choosen for sorting, and keep trace of the uid # to find account data back after ordering. ordered[hlstr.validate_name(tgroups[gid][sort])] = gid tgroups[gid]['members'] = [] for member in groups.groups[gid]['members']: if not users.is_system_login(member): tgroups[gid]['members'].append( users.users[users.login_to_uid(member)]) if not groups.is_system_gid(gid): for prefix in ( configuration.groups.resp_prefix, configuration.groups.guest_prefix): tgroups[gid][prefix + 'members'] = [] for member in \ groups.groups[groups.name_to_gid( prefix + name)]['members']: if not users.is_system_login(member): tgroups[gid][prefix + 'members'].append( users.users[users.login_to_uid(member)]) gkeys = ordered.keys() gkeys.sort() if order == "desc": gkeys.reverse() def html_build_group(index, tgroups = tgroups ): gid = ordered[index] name = g[gid]['name'] html_data = ''' <tr class="userdata"> <td class="nopadding"> <a href="/groups/view/%s" title="%s" class="view-entry"> <span class="view-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> <td class="group_name"> <a href="/groups/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td class="group_name"> <a href="/groups/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td class="right"> <a href="/groups/edit/%s">%s</a> </td> ''' % ( name, _('''View the group details, its parameters, members, responsibles and guests. From there you can print all group-related informations.'''), name, g[gid]['description'], name, name, g[gid]['description'], g[gid]['description'], name, g[gid]['skel']) if groups.is_system_gid(gid): html_data += '<td>&#160;</td>' else: if g[gid]['permissive']: html_data += ''' <td class="user_action_center"> <a href="/groups/lock/%s" title="%s"> <img src="/images/16x16/unlocked.png" alt="%s"/></a> </td> ''' % (name, _('''Shared group directory is currently ''' '''<strong>permissive</strong>. Click to deactivate ''' '''permissiveness.'''), _('Group is currently permissive.')) else: html_data += ''' <td class="user_action_center"> <a href="/groups/unlock/%s" title="%s"> <img src="/images/16x16/locked.png" alt="%s"/></a> </td> ''' % (name, _('''Shared group directory is currently <strong>NOT</strong> permissive. Click ti activate permissiveness.'''), _('Group is NOT permissive.')) for (keyname, text) in ( ('members', _('Current members')), ('rsp-members', _('Current responsibles')), ('gst-members', _('Current guests')) ): if tgroups[gid].has_key(keyname): accounts = {} uordered = {} for member in tgroups[gid][keyname]: uid = member['uidNumber'] accounts[uid] = { 'login': member['login'], 'gecos': member['gecos'], 'gecos_sort': member['gecos'] + member['login'] } uordered[hlstr.validate_name( accounts[uid]['gecos_sort'], aggressive=True)] = uid memberkeys = uordered.keys() memberkeys.sort() mbdata = '''<table><tr><th>%s</th><th>%s</th> <th>%s</th></tr>\n''' % (_('Full Name'), _('Identifier'), _('UID')) for member in memberkeys: uid = uordered[member] mbdata += '''<tr><td>%s</td><td>%s</td> <td>%d</td></tr>\n''' % (accounts[uid]['gecos'], accounts[uid]['login'], uid) mbdata += '</table>' nb = len(tgroups[gid][keyname]) if nb == 0: html_data += '''<td class="right faded">%s</td>\n''' % \ _('none') else: html_data += '''<td class="right"> <a class="nounder" title="<h4>%s</h4><br />%s"> <strong>%d</strong>&#160;<img src="/images/16x16/details-light.png" alt="%s" /></a></td>\n''' % (text, mbdata, nb, _('See %s of group %s.') % (text, name)) else: html_data += '''<td>&#160;</td>\n''' if groups.is_system_gid(gid): html_data += '<td colspan="1">&#160;</td></tr>\n' else: html_data += ''' <!-- TODO: implement skel reapplying for all users of curent group <td class="user_action"> <a href="/users/skel/%s" title="%s" class="reapply-skel"> <span class="reapply-skel">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> --> <td class="user_action"> <a href="/groups/delete/%s" title="%s" class="delete-entry"> <span class="delete-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span> </a> </td> </tr> ''' % (name, _('''This will rebuild his/her desktop from scratch, with defaults icons and so on. <br /><br />The user must be disconnected for the operation to be completely successfull.'''), name, _('''Definitely remove this group from system.''')) return html_data data += '<tr><td class="group_class" colspan="8">%s</td></tr>\n%s' % ( filter_name, ''.join(map(html_build_group, gkeys))) def print_totals(totals): output = "" for total in totals: if totals[total] != 0: output += ''' <tr class="list_total"> <td colspan="6" class="total_left">%s</td> <td colspan="6" class="total_right">%d</td> </tr> ''' % (_('number of <strong>%s</strong>:') % total, totals[total]) return output data += ''' <tr> <td colspan="6">&#160;</td></tr> %s <tr class="list_total"> <td colspan="6" class="total_left"><strong>%s</strong></td> <td colspan="6" class="total_right">%d</td> </tr>
84927f63ccb0390487678873dbd1c49eb749f5a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/84927f63ccb0390487678873dbd1c49eb749f5a9/groups.py
name, g[gid]['skel'])
name, g[gid]['groupSkel'])
def html_build_group(index, tgroups = tgroups ): gid = ordered[index] name = g[gid]['name'] html_data = '''
84927f63ccb0390487678873dbd1c49eb749f5a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/84927f63ccb0390487678873dbd1c49eb749f5a9/groups.py
assert ltrace('ldap', '| __init__().')
assert ltrace('ldap', '| __init__()')
def __init__(self, configuration, users=None, groups=None, warnings=True): """ Init the LDAP backend instance. """
b6cd5454ed254d78f6ce9e40393d67f5a4f8a52c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/b6cd5454ed254d78f6ce9e40393d67f5a4f8a52c/ldap_backend.py
def __init__(self, configuration, users=None, groups=None, warnings=True): """ Init the LDAP backend instance. """
b6cd5454ed254d78f6ce9e40393d67f5a4f8a52c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/b6cd5454ed254d78f6ce9e40393d67f5a4f8a52c/ldap_backend.py
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.
b6cd5454ed254d78f6ce9e40393d67f5a4f8a52c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/b6cd5454ed254d78f6ce9e40393d67f5a4f8a52c/ldap_backend.py
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.
b6cd5454ed254d78f6ce9e40393d67f5a4f8a52c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/b6cd5454ed254d78f6ce9e40393d67f5a4f8a52c/ldap_backend.py
else: delete_user()
else: delete_user()
def delete_webfilter(): raise NotImplementedError("delete_webfilters_types not implemented.")
128f21ec2768df4310ecd8efcd74aebe244ccc82 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/128f21ec2768df4310ecd8efcd74aebe244ccc82/del.py
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 --skeldir=/etc/skel && exit 1 # doit planter pour le skel pas un répertoire, pour le groupe jfgdghf log_and_exec $MOD profile --name=profileA --rename=theprofile --rename-primary-group=theprofile --comment=modify --shell=/bin/sh --skel=/etc/power --quota=10 --add-groups=cdrom,remote,qsdfgkh --del-groups=cdrom,jfgdghf log_and_exec $DEL profile --name=profileB --del-users --no-archive log_and_exec $DEL profile --name=profileeD log_and_exec $MOD profile --name=profileeC --not-permissive log_and_exec $ADD profile --name=theprofile log_and_exec $MOD profile --name=theprofile --skel=/etc/doesntexist } """ pass
71bb836aa180c761edf6c4cdaf1315dd30e05f7c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/71bb836aa180c761edf6c4cdaf1315dd30e05f7c/core.py
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 --skeldir=/etc/skel && exit 1 # doit planter pour le skel pas un répertoire, pour le groupe jfgdghf log_and_exec $MOD profile --name=profileA --rename=theprofile --rename-primary-group=theprofile --comment=modify --shell=/bin/sh --skel=/etc/power --quota=10 --add-groups=cdrom,remote,qsdfgkh --del-groups=cdrom,jfgdghf log_and_exec $DEL profile --name=profileB --del-users --no-archive log_and_exec $DEL profile --name=profileeD log_and_exec $MOD profile --name=profileeC --not-permissive log_and_exec $ADD profile --name=theprofile log_and_exec $MOD profile --name=theprofile --skel=/etc/doesntexist } """ pass
71bb836aa180c761edf6c4cdaf1315dd30e05f7c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/71bb836aa180c761edf6c4cdaf1315dd30e05f7c/core.py
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 --skeldir=/etc/skel && exit 1 # doit planter pour le skel pas un répertoire, pour le groupe jfgdghf log_and_exec $MOD profile --name=profileA --rename=theprofile --rename-primary-group=theprofile --comment=modify --shell=/bin/sh --skel=/etc/power --quota=10 --add-groups=cdrom,remote,qsdfgkh --del-groups=cdrom,jfgdghf log_and_exec $DEL profile --name=profileB --del-users --no-archive log_and_exec $DEL profile --name=profileeD log_and_exec $MOD profile --name=profileeC --not-permissive log_and_exec $ADD profile --name=theprofile log_and_exec $MOD profile --name=theprofile --skel=/etc/doesntexist } """ pass
71bb836aa180c761edf6c4cdaf1315dd30e05f7c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/71bb836aa180c761edf6c4cdaf1315dd30e05f7c/core.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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. """
a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/a99fa36c9c57f1ef71f9ac0df9bc184bbcc4d91b/ldap_backend.py
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 None: password = None else: password = unicode(opts.password) for login in opts.login.split(','): if login != '': try: users.AddUser(lastname, firstname, password, opts.primary_group, opts.profile, opts.skel, login, gecos, False) except exceptions.AlreadyExistsException: logging.warning('User %s already exists on the system.' % login)
4da9ec785b12576bac5f207a9af992cc3d40cae2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/4da9ec785b12576bac5f207a9af992cc3d40cae2/add.py
groups.AddGroup(name, description = description, system = opts.system, skel = opts.skel, gid = opts.gid, permissive = opts.permissive)
groups.AddGroup(name, description = description, system = opts.system, skel = opts.skel, gid = opts.gid, permissive = opts.permissive)
def add_group(): """ Add a POSIX group. """ if opts.description == '': description = '' else: description = unicode(opts.description) for name in opts.name.split(','): if name != '': try: groups.AddGroup(name, description = description, system = opts.system, skel = opts.skel, gid = opts.gid, permissive = opts.permissive) except exceptions.AlreadyExistsException: logging.warning('Group %s already exists on the system.' % name)
4da9ec785b12576bac5f207a9af992cc3d40cae2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/4da9ec785b12576bac5f207a9af992cc3d40cae2/add.py
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
c8291edb9c768806e0a5ddff59697fb04c0707aa /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/c8291edb9c768806e0a5ddff59697fb04c0707aa/privileges.py
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))
bde6015db327e7049b910183ab7c4d388fac0e1b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/bde6015db327e7049b910183ab7c4d388fac0e1b/privileges.py
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):
940d620d0570fcfb29886fd8671a43a6b4a18ede /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/940d620d0570fcfb29886fd8671a43a6b4a18ede/users.py
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):
940d620d0570fcfb29886fd8671a43a6b4a18ede /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/940d620d0570fcfb29886fd8671a43a6b4a18ede/users.py
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):
940d620d0570fcfb29886fd8671a43a6b4a18ede /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/940d620d0570fcfb29886fd8671a43a6b4a18ede/users.py
'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 context to restaure it at the end of the testsuite backends = [ line for line in process.execute(['get', 'config', 'backends'])[1].split('\n') if 'U' in line ] reduce(lambda x,y: x if y == '' else y, backends) self.user_context = backends[0].split('(')[0] self.current_context=self.user_context
f64e67ce4f4a810b0dacb62d0e737879f526513c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/f64e67ce4f4a810b0dacb62d0e737879f526513c/__init__.py
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.
26b0203107d85ef066e948b2d4845fbc71bd6f2d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/26b0203107d85ef066e948b2d4845fbc71bd6f2d/configuration.py
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()')
43dbf1adf057b66668d355529748be8d7e1b8bcb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/43dbf1adf057b66668d355529748be8d7e1b8bcb/configuration.py
'''between 0 and 25.''' (
'''between 0 and 50.''' (
def check_directive_daemon_threads(self): """ check the pingers number for correctness. """ assert ltrace('configuration', '| check_directive_daemon_threads()')
43dbf1adf057b66668d355529748be8d7e1b8bcb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/43dbf1adf057b66668d355529748be8d7e1b8bcb/configuration.py
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()')
43dbf1adf057b66668d355529748be8d7e1b8bcb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/43dbf1adf057b66668d355529748be8d7e1b8bcb/configuration.py
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)."""
2ff6415f024305dbd4b0432215a73c8d9f7274bc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2ff6415f024305dbd4b0432215a73c8d9f7274bc/users.py
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
1df52d2e524f04424ad39ff7b6c48acfaf92a774 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1df52d2e524f04424ad39ff7b6c48acfaf92a774/core.py
term_columns = term_size()[1] separator = '--------8<--------' * (term_columns/18)
def RunCommand(self, cmdnum, batch=False):
1df52d2e524f04424ad39ff7b6c48acfaf92a774 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1df52d2e524f04424ad39ff7b6c48acfaf92a774/core.py
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,test,utilisager.normal,''' \ '''test.responsibilly,utilicateur.accentue,user_test,''' \ '''GRP-ACL-user''', '--no-archive'], ['profile', '--group=utilisagers', '--del-users', '--no-archive'], ['profile', '--group=responsibilisateurs', '--del-users', '--no-archive'], ['group', '''test_users_A,test_users_B,groupeA,B-Group_Test,''' \ '''groupe_a_skel,ACL_tests,MOD_tests,SYSTEM-test,SKEL-tests,''' \ '''ARCHIVES-test,group_test,GRP-ACL-test'''], ): execute(DEL + argument) os.system('sudo rm -rf %s/* %s/*' % (configuration.home_backup_dir, configuration.home_archive_dir)) test_message('''system cleaned from previous testsuite runs.''')
1df52d2e524f04424ad39ff7b6c48acfaf92a774 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1df52d2e524f04424ad39ff7b6c48acfaf92a774/core.py
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': for file in system_files: if os.path.exists('/etc/%s' % file): execute([ 'sudo', 'cp', '-f', '/etc/%s' % file, '/tmp/%s.bak.%s' % (file.replace('/', '_'), bkp_ext)]) elif mode == 'ldap': execute(['sudo', 'slapcat', '-l', '/tmp/backup.1.ldif']) else: logging.error('backup mode not understood.') test_message('''made backups of system config files.''')
1df52d2e524f04424ad39ff7b6c48acfaf92a774 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1df52d2e524f04424ad39ff7b6c48acfaf92a774/core.py
def RunCommand(self, cmdnum, batch=False):
2952d8e41ae40d2ecab06ada5028c9c4bf52bf16 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2952d8e41ae40d2ecab06ada5028c9c4bf52bf16/core.py
'%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):
2952d8e41ae40d2ecab06ada5028c9c4bf52bf16 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/2952d8e41ae40d2ecab06ada5028c9c4bf52bf16/core.py