rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
(LMC.profiles.Select(filters.ALL), LMC.profiles.guess_identifier)
(LMC.profiles.Select(filters.ALL), lambda x: x)
def mod_profile(self, opts, args): """ Modify 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 t...
(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 chk_user(self, opts, args): """ Check one or more user account(s). """ 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) ]...
(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 chk_group(self, opts, args): """ Check one or more group(s). """ 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) ] i...
(LMC.profiles.Select(filters.ALL), LMC.profiles.guess_identifier)
(LMC.profiles.Select(filters.ALL), lambda x: x)
def chk_profile(self, opts, args): """ TODO: to be implemented. """ 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 these condit...
''' % (styles.stylize(styles.ST_OK, "Call trace")))
''' % (stylize(ST_OK, "Call trace")))
def error(mesg, returncode=1, full=False, tb=None, listener=None): """ Display a styles.stylized error message and exit badly. """ if full: if tb: sys.stderr.write(tb + '\n') else: import traceback sys.stderr.write ('''>>> %s: ''' % (styles.stylize(styles.ST_OK, "Call trace"))) traceback.print_tb( sys.exc_info()[2] )...
styles.stylize(styles.ST_BAD, 'ERROR:'),
stylize(ST_BAD, 'ERROR:'),
def error(mesg, returncode=1, full=False, tb=None, listener=None): """ Display a styles.stylized error message and exit badly. """ if full: if tb: sys.stderr.write(tb + '\n') else: import traceback sys.stderr.write ('''>>> %s: ''' % (styles.stylize(styles.ST_OK, "Call trace"))) traceback.print_tb( sys.exc_info()[2] )...
styles.stylize(styles.ST_WARNING, '/!\\'), mytime(), mesg)
stylize(ST_WARNING, '/!\\'), mytime(), mesg)
def warning(mesg, once=False, listener=None): """Display a styles.stylized warning message on stderr.""" if once: try: already_displayed = __warningsdb[mesg] return except KeyError, e: __warningsdb[mesg] = True text_message = "%s%s %s\n" % ( styles.stylize(styles.ST_WARNING, '/!\\'), mytime(), mesg) if listener: lis...
""" Display a styles.stylized warning message on stderr, only if verbose
""" Display a stylized warning message on stderr, only if verbose
def warning2(mesg, once=False, listener=None): """ Display a styles.stylized warning message on stderr, only if verbose level > INFO. """ if once: try: already_displayed = __warningsdb[mesg] return except KeyError, e: __warningsdb[mesg] = True if listener and listener.verbose >= verbose.INFO: listener.process( Licorn...
styles.stylize(styles.ST_WARNING, '/2\\'), mytime(), mesg)),
stylize(ST_WARNING, '/2\\'), mytime(), mesg)),
def warning2(mesg, once=False, listener=None): """ Display a styles.stylized warning message on stderr, only if verbose level > INFO. """ if once: try: already_displayed = __warningsdb[mesg] return except KeyError, e: __warningsdb[mesg] = True if listener and listener.verbose >= verbose.INFO: listener.process( Licorn...
styles.stylize(styles.ST_WARNING, '/2\\'), mytime(), mesg))
stylize(ST_WARNING, '/2\\'), mytime(), mesg))
def warning2(mesg, once=False, listener=None): """ Display a styles.stylized warning message on stderr, only if verbose level > INFO. """ if once: try: already_displayed = __warningsdb[mesg] return except KeyError, e: __warningsdb[mesg] = True if listener and listener.verbose >= verbose.INFO: listener.process( Licorn...
styles.stylize(styles.ST_INFO, '*'), mytime(), mesg)),
stylize(ST_INFO, '*'), mytime(), mesg)),
def notice(mesg, listener=None): """ Display a non-styles.stylized notice message on stderr.""" assert ltrace('logging', '| notice(%s L%s/R%s)' % (verbose.NOTICE, options.verbose, listener.verbose if listener else '-')) if listener and listener.verbose >= verbose.NOTICE: listener.process(LicornMessage(data=" %s %s %s\n...
styles.stylize(styles.ST_INFO, '*'), mytime(), mesg))
stylize(ST_INFO, '*'), mytime(), mesg))
def notice(mesg, listener=None): """ Display a non-styles.stylized notice message on stderr.""" assert ltrace('logging', '| notice(%s L%s/R%s)' % (verbose.NOTICE, options.verbose, listener.verbose if listener else '-')) if listener and listener.verbose >= verbose.NOTICE: listener.process(LicornMessage(data=" %s %s %s\n...
styles.stylize(styles.ST_DEBUG, 'DEBUG'), mesg) )
stylize(ST_DEBUG, 'DEBUG'), mesg) )
def debug(mesg): """Display a styles.stylized debug message on stderr.""" if options.verbose >= verbose.DEBUG: sys.stderr.write( "%s: %s\n" % ( styles.stylize(styles.ST_DEBUG, 'DEBUG'), mesg) )
styles.stylize(styles.ST_DEBUG, 'DEBUG2'), mesg))
stylize(ST_DEBUG, 'DEBUG2'), mesg))
def debug2(mesg): """Display a styles.stylized debug2 message on stderr.""" if options.verbose >= verbose.DEBUG2: sys.stderr.write("%s: %s\n" % ( styles.stylize(styles.ST_DEBUG, 'DEBUG2'), mesg))
@staticmethod def is_standard_login(login): """ Return true if login is standard (not system). """ try: return UsersController.is_standard_uid( UsersController.login_cache[login]) except KeyError: raise exceptions.DoesntExistsException( logging.SYSU_USER_DOESNT_EXIST % login)
def is_system_login(login): """ return true if login is system. """ try: return UsersController.is_system_uid( UsersController.login_cache[login]) except KeyError: raise exceptions.DoesntExistsException( logging.SYSU_USER_DOESNT_EXIST % login)
def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !"""
def minifind(path, type=None, perms=None, mindepth=0, maxdepth=99, exclude=[], followlinks=False, followmounts=True): """ Mimic the GNU find behaviour in python. returns an iterator. """
def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" if mindepth > maxdepth: raise exceptions.BadArgumentError("mindepth must be <= maxdepth....
logging.debug("starting minifind in %s, type=%s, mindepth=%s, maxdepth=%s, exclude=%s." \ % (path, type, mindepth, maxdepth, exclude))
ltrace('fsapi', '''> minifind(%s, type=%s, mindepth=%s, maxdepth=%s, ''' '''exclude=%s, followlinks=%s, followmounts=%s)''' % ( path, type, mindepth, maxdepth, exclude, followlinks, followmounts))
def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" if mindepth > maxdepth: raise exceptions.BadArgumentError("mindepth must be <= maxdepth....
and ( (type is None and entry_type & S_IFSTD) or entry_type == type) \
and ( (type is None and entry_type & S_IFSTD) \ or entry_type == type) \
def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" if mindepth > maxdepth: raise exceptions.BadArgumentError("mindepth must be <= maxdepth....
if (entry_type & S_IFLNK and not followlinks) \
if (entry_type == S_IFLNK and not followlinks) \
def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" if mindepth > maxdepth: raise exceptions.BadArgumentError("mindepth must be <= maxdepth....
except OSError, e:
else: ltrace('fsapi', ' minifind(excluded=%s)' % entry) except (IOError, OSError), e:
def minifind(path, type = None, perms = None, mindepth = 0, maxdepth = 99, exclude = [], followlinks = False, followmounts = False): """mimic the GNU find behaviour in python. returns an iterator. WARNING: recursive function !""" if mindepth > maxdepth: raise exceptions.BadArgumentError("mindepth must be <= maxdepth....
for cmd in self.pre_cmds: out_path += 'pre_%s/' % make_path(cmd)
for pre_cmd in self.pre_cmds: out_path += 'pre_%s/' % make_path(pre_cmd)
def Prepare(self, cmd): """ Run commands mandatory for func_test to succeed. """
execute(cmd)
execute(pre_cmd)
def Prepare(self, cmd): """ Run commands mandatory for func_test to succeed. """
[ 'sudo', 'rm', '-rf', '%s/*' % configuration.home_archive_dir ]
[ 'sudo', 'rm', '-vrf', '%s/*' % configuration.home_archive_dir ]
def chk_acls_cmds(group, subdir=None): return [ 'sudo', 'getfacl', '-R', '%s/%s/%s%s' % ( configuration.defaults.home_base_path, configuration.groups.names['plural'], group, '/%s' % subdir if subdir else '') ]
['sudo', 'rm', '-rf', "%s/%s/%s" % (
['sudo', 'rm', '-vrf', "%s/%s/%s" % (
def chk_acls_cmds(group, subdir=None): return [ 'sudo', 'getfacl', '-R', '%s/%s/%s%s' % ( configuration.defaults.home_base_path, configuration.groups.names['plural'], group, '/%s' % subdir if subdir else '') ]
'''deleted) is deleted (avoids
def chk_acls_cmds(group, subdir=None): return [ 'sudo', 'getfacl', '-R', '%s/%s/%s%s' % ( configuration.defaults.home_base_path, configuration.groups.names['plural'], group, '/%s' % subdir if subdir else '') ]
if need_rewriting: self.save_group(gid)
def load_groups(self): """ Load groups from /etc/{group,gshadow} and /etc/licorn/group. """
return LicornWarningsDB.__warnings[item]
return LicornWarningsDB.warnings[item]
def __getitem__(self, item): return LicornWarningsDB.__warnings[item]
LicornWarningsDB.__warningsdb[item] = value
LicornWarningsDB.warnings[item] = value
def __setitem__(self, item, value): LicornWarningsDB.__warningsdb[item] = value
return LicornWarningsDB.__warningsdb.keys()
return LicornWarningsDB.warnings.keys() __warningsdb = LicornWarningsDB()
def keys(self): return LicornWarningsDB.__warningsdb.keys()
UsersController.users, UsersController.login_cache = self.backend.load_users(self.groups)
UsersController.users, UsersController.login_cache = \ self.backend.load_users(self.groups)
def reload(self): """ Load (or reload) the data structures from the system files. """ UsersController.users, UsersController.login_cache = self.backend.load_users(self.groups)
raise exceptions.LicornRuntimeError("Can't build a valid login (%s) with the firstname/lastname (%s/%s) you provided." % (login, firstname, lastname))
raise exceptions.LicornRuntimeError( "Can't build a valid login (%s) with the " \ "firstname/lastname (%s/%s) you provided." % ( login, firstname, lastname) )
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)."""
raise exceptions.BadArgumentError(logging.SYSU_MALFORMED_LOGIN % (login, styles.stylize(styles.ST_REGEX, hlstr.regex['login']))) if not login_autogenerated and len(login) > UsersController.configuration.users.login_maxlenght: raise exceptions.LicornRuntimeError("Login too long (%d characters, but must be shorter or eq...
raise exceptions.BadArgumentError( logging.SYSU_MALFORMED_LOGIN % ( login, styles.stylize(styles.ST_REGEX, hlstr.regex['login']))) if not login_autogenerated and \ len(login) > UsersController.configuration.users.login_maxlenght: raise exceptions.LicornRuntimeError( "Login too long (%d characters," \ " but must be sho...
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)."""
raise exceptions.LicornRuntimeError("Can't build a valid GECOS (%s) with the firstname/lastname (%s/%s) or login you provided." % (gecos, firstname, lastname))
raise exceptions.LicornRuntimeError( "Can't build a valid GECOS (%s) with the" \ " firstname/lastname (%s/%s) or login you provided." % ( gecos, firstname, lastname) )
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)."""
raise exceptions.BadArgumentError("The skel you specified doesn't exist on this system. Valid skels are: %s." % UsersController.configuration.users.skels)
raise exceptions.BadArgumentError( "The skel you specified doesn't exist on this system." \ " Valid skels are: %s." % \ UsersController.configuration.users.skels)
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)."""
raise exceptions.AlreadyExistsException, "A user named « %s » already exists !" % login
raise exceptions.AlreadyExistsException, \ "A user named « %s » already exists !" % login
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)."""
raise exceptions.UpstreamBugException, "A group named `%s' exists on the system, this could eventually conflict in Debian/Ubuntu system tools. Please choose another user's login." % login
raise exceptions.UpstreamBugException, \ "A group named `%s' exists on the system," \ " this could eventually conflict in Debian/Ubuntu system" \ " tools. Please choose another user's login." % login
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)."""
tmp_user_dict['loginShell'] = UsersController.profiles.profiles[profile]['shell'] tmp_user_dict['gid'] = UsersController.groups.name_to_gid(UsersController.profiles.profiles[profile]['primary_group'])
tmp_user_dict['loginShell'] = \ UsersController.profiles.profiles[profile]['shell'] tmp_user_dict['gid'] = \ UsersController.groups.name_to_gid( UsersController.profiles.profiles[profile]['primary_group'])
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)."""
skel_to_apply = UsersController.profiles.profiles[profile]['skel_dir']
skel_to_apply = \ UsersController.profiles.profiles[profile]['skel_dir']
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)."""
raise exceptions.LicornRuntimeError("The profile %s does not exist on this system (was: %s) !" % (profile, e))
raise exceptions.LicornRuntimeError( "The profile %s does not exist on this system (was: %s) !" \ % (profile, e))
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)."""
tmp_user_dict['loginShell'] = UsersController.configuration.users.default_shell tmp_user_dict['homeDirectory'] = "%s/%s" % (UsersController.configuration.users.base_path, login)
tmp_user_dict['loginShell'] = \ UsersController.configuration.users.default_shell tmp_user_dict['homeDirectory'] = "%s/%s" % ( UsersController.configuration.users.base_path, login)
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)."""
if skel is None and os.path.isdir(UsersController.groups.groups[pg_gid]['skel']):
if skel is None and \ os.path.isdir(UsersController.groups.groups[pg_gid]['skel']):
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)."""
tmp_user_dict['gid'] = UsersController.configuration.users.default_gid tmp_user_dict['loginShell'] = UsersController.configuration.users.default_shell tmp_user_dict['homeDirectory'] = "%s/%s" % (UsersController.configuration.users.base_path, login)
tmp_user_dict['gid'] = \ UsersController.configuration.users.default_gid tmp_user_dict['loginShell'] = \ UsersController.configuration.users.default_shell tmp_user_dict['homeDirectory'] = "%s/%s" % ( UsersController.configuration.users.base_path, login)
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)."""
logging.warning( "ROLLBACK because " + str(e))
logging.warning( "ROLLBACK create user because '%s'." % str(e))
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)."""
logging.warning("Home dir %s doesn't exist, thus not archived." % styles.stylize(styles.ST_PATH, homedir))
logging.warning( "Home dir %s doesn't exist, thus not archived." % \ styles.stylize(styles.ST_PATH, homedir))
def DeleteUser(self, login=None, no_archive=False, uid=None, batch=False): """ Delete a user """ if login is None and uid is None: raise exceptions.BadArgumentError(logging.SYSU_SPECIFY_LGN_OR_UID)
logging.warning(logging.SYSU_SET_EMPTY_PASSWD % styles.stylize(styles.ST_LOGIN, login))
logging.warning(logging.SYSU_SET_EMPTY_PASSWD % \ styles.stylize(styles.ST_LOGIN, login))
def ChangeUserPassword(self, login, password = None, display = False): """ Change the password of a user """ if login is None: raise exceptions.BadArgumentError(logging.SYSU_SPECIFY_LOGIN) if password is None: password = hlstr.generate_password(UsersController.configuration.mAutoPasswdSize) elif password == "": logging...
logging.notice("Set user %s's password to %s." % (styles.stylize(styles.ST_NAME, login), styles.stylize(styles.ST_IMPORTANT, password))) else: logging.info('Changed password for user %s.' % styles.stylize(styles.ST_NAME, login))
logging.notice("Set user %s's password to %s." % ( styles.stylize(styles.ST_NAME, login), styles.stylize(styles.ST_IMPORTANT, password))) else: logging.info('Changed password for user %s.' % \ styles.stylize(styles.ST_NAME, login))
def ChangeUserPassword(self, login, password = None, display = False): """ Change the password of a user """ if login is None: raise exceptions.BadArgumentError(logging.SYSU_SPECIFY_LOGIN) if password is None: password = hlstr.generate_password(UsersController.configuration.mAutoPasswdSize) elif password == "": logging...
raise exceptions.LicornRuntimeError("Invalid shell ! valid shells are %s." % UsersController.configuration.users.shells)
raise exceptions.LicornRuntimeError( "Invalid shell ! valid shells are %s." % \ UsersController.configuration.users.shells)
def ChangeUserShell(self, login, shell = ""): """ Change the shell of a user. """ if login is None: raise exceptions.BadArgumentError(logging.SYSU_SPECIFY_LOGIN)
UsersController.users[uid]['crypted_password'] = '!' + UsersController.users[uid]['crypted_password'] logging.info('Locked user account %s.' % styles.stylize(styles.ST_LOGIN, login)) else: UsersController.users[uid]['crypted_password'] = UsersController.users[uid]['crypted_password'][1:] logging.info('Unlocked user acc...
UsersController.users[uid]['crypted_password'] = '!' + \ UsersController.users[uid]['crypted_password'] logging.info('Locked user account %s.' % \ styles.stylize(styles.ST_LOGIN, login)) else: UsersController.users[uid]['crypted_password'] = \ UsersController.users[uid]['crypted_password'][1:] logging.info('Unlocked us...
def LockAccount(self, login, lock = True): """(Un)Lock a user account.""" if login is None: raise exceptions.BadArgumentError(logging.SYSU_SPECIFY_LOGIN)
data += " <groups>%s</groups>\n" % ','.join(UsersController.users[uid]['groups'])
data += " <groups>%s</groups>\n" % \ ','.join(UsersController.users[uid]['groups'])
def build_xml_output_user_data(uid): data = '''
logging.progress("Checking user %s..." % styles.stylize(styles.ST_LOGIN, user))
logging.progress("Checking user %s..." % \ styles.stylize(styles.ST_LOGIN, user))
def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer):
logging.progress("Checking user account %s..." % styles.stylize(styles.ST_NAME, user))
logging.progress("Checking user account %s..." % \ styles.stylize(styles.ST_NAME, user))
def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer):
} for dir in home_exclude_list if os.path.exists('%s/%s' % (user_home, dir)) ])
} for dir in home_exclude_list if \ os.path.exists('%s/%s' % (user_home, dir)) ])
def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer):
UsersController.configuration.users.mailbox_type == UsersController.configuration.MAIL_TYPE_HOME_MAILDIR: maildir_base = '%s/%s' % (user_home, UsersController.configuration.users.mailbox) home_exclude_list.append(UsersController.configuration.users.mailbox[:-1]) for dir in ( maildir_base, '%stmp' % maildir_bas...
UsersController.configuration.users.mailbox_type == \ UsersController.configuration.MAIL_TYPE_HOME_MAILDIR: maildir_base = '%s/%s' % (user_home, UsersController.configuration.users.mailbox) home_exclude_list.append( UsersController.configuration.users.mailbox[:-1]) for dir in ( maildir_base, '%stmp' % maildi...
def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer):
logging.progress("Checking user home dir %s contents, this can take a while..." % styles.stylize(
logging.progress("Checking user home dir %s contents," " this can take a while..." % styles.stylize(
def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer):
logging.warning("User home dir %s is missing, please repair this first." % styles.stylize(
logging.warning("User home dir %s is missing," " please repair this first." % styles.stylize(
def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer):
logging.warning("You passed an uid to login_to_uid(): %d (guess its login is « %s » )." % (login, UsersController.users[login]['login']))
logging.warning("You passed an uid to login_to_uid():" " %d (guess its login is « %s » )." % ( login, UsersController.users[login]['login']))
def login_to_uid(login): """ Return the uid of the user 'login' """ try: # use the cache, Luke ! return UsersController.login_cache[login] except KeyError: try: int(login) logging.warning("You passed an uid to login_to_uid(): %d (guess its login is « %s » )." % (login, UsersController.users[login]['login'])) except Val...
return uid < UsersController.configuration.users.uid_min or uid > UsersController.configuration.users.uid_max
return uid < UsersController.configuration.users.uid_min or \ uid > UsersController.configuration.users.uid_max
def is_system_uid(uid): """ Return true if uid is system.""" return uid < UsersController.configuration.users.uid_min or uid > UsersController.configuration.users.uid_max
raise exceptions.LicornRuntimeError("Can't build a valid login (got %s, which doesn't verify %s) with the firstname/lastname you provided (%s %s)." % (login, hlstr.regex['login'], firstname, lastname) )
raise exceptions.LicornRuntimeError( "Can't build a valid login (got %s, which doesn't verify %s)" " with the firstname/lastname you provided (%s %s)." % ( login, hlstr.regex['login'], firstname, lastname) )
def make_login(lastname = "", firstname = "", inputlogin = ""): """ Make a valid login from user's firstname and lastname."""
socket.gethostbyaddr(self.server.server_address[0])[0], wmi_port, retdata))
hostaddr, wmi_port, retdata))
def serve_virtual_uri(self): """ Serve dynamic URIs with our own code, and create pages on the fly. """
def strip_dates(str):
def strip_moving_data(str):
def strip_dates(str): """ strip dates from warnings and traces, else outputs and references always compare false .""" return re.sub(r'(\.\d\d\d\d\d\d\d\d-\d\d\d\d\d\d|\s\[\d\d\d\d/\d\d/\d\d\s\d\d:\d\d:\d\d\.\d\d\d\d\]\s)', r' [D/T] ', str)
r' [D/T] ', str)
r' [D/T] ',re.sub(r'Autogenerated\spassword\sfor\suser\s(.*):\s.*', r'Autogenerated password for user \1: [Password]', str))
def strip_dates(str): """ strip dates from warnings and traces, else outputs and references always compare false .""" return re.sub(r'(\.\d\d\d\d\d\d\d\d-\d\d\d\d\d\d|\s\[\d\d\d\d/\d\d/\d\d\s\d\d:\d\d:\d\d\.\d\d\d\d\]\s)', r' [D/T] ', str)
strip_dates(output))
strip_moving_data(output))
def SaveOutput(self, cmdnum, output, code):
output = strip_dates(output)
output = strip_moving_data(output)
def RunCommand(self, cmdnum, batch=False):
strip_dates(output),
strip_moving_data(output),
def RunCommand(self, cmdnum, batch=False):
return (strip_dates(output), retcode)
return (strip_moving_data(output), retcode)
def RunCommand(self, cmdnum, batch=False):
file = gzip.GzipFile( filename='%s/%s/out.txt.gz' % (self.base_path, cmdnum), mode='wb', compresslevel=9)
try: os.unlink(filename_txt) except (OSError, IOError), e: if e.errno != 2: raise e file = gzip.GzipFile(filename=filename_gz, mode='wb', compresslevel=9)
def SaveOutput(self, cmdnum, output, code):
file = open('%s/%s/out.txt' % (self.base_path, cmdnum), 'w')
try: os.unlink(filename_gz) except (OSError, IOError), e: if e.errno != 2: raise e file = open(filename_txt, 'w')
def SaveOutput(self, cmdnum, output, code):
for login in opts.login.split(','):
for login in opts.login.split(',') if opts.login != None else [ None ]:
def add_user(opts, args): """ Add a user account on the system. """ configuration = LicornConfiguration() users = UsersController(configuration) groups = GroupsController(configuration, users) if opts.profile: profiles = ProfilesController(configuration, groups, users) if opts.firstname is None: firstname = None els...
shutil.rmtree(home)
try: shutil.rmtree(home) except (IOError, OSError), e: if e.errno == 2: logging.notice("Can't remove %s, it doesn't exist !" % \ styles.stylize(styles.ST_PATH, home)) else: raise e
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.")
logging.warning("Can't archive %s, it doesn't exist !" % \
logging.notice("Can't archive %s, it doesn't exist !" % \
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.")
(opts.gid, groups.confirm_gid) ])
(opts.gid, groups.confirm_gid), ], selection )
def del_group(opts, args): """ delete an Licorn group. """ configuration = LicornConfiguration() users = UsersController(configuration) groups = GroupsController(configuration, users, warnings=False) profiles = ProfilesController(configuration, groups, users) gids_to_del = cli_select(groups, 'group', args, [ (opts.na...
if users.user_exists(login = authorization[0]) \ and users.check_password(authorization[0], authorization[1]): if groups.group_exists(wmi_group): if authorization[0] in \ groups.auxilliary_members(wmi_group):
try : if users.user_exists(login = authorization[0]) \ and users.check_password(authorization[0], authorization[1]): if groups.group_exists(wmi_group): if authorization[0] in \ groups.auxilliary_members(wmi_group): self.http_user = authorization[0] return True else:
def user_authorized(self): """ Return True if authorization exists AND user is authorized."""
else: self.http_user = authorization[0] return True
except exceptions.BadArgumentError: logging.warning('empty username or password sent as authentification string into WMI.') return False
def user_authorized(self): """ Return True if authorization exists AND user is authorized."""
<title>%s WMI: %s</title>
<title>%s %s</title>
def head(title = _("administration %s") % configuration.app_name): """Build the HTML Page header. Bubble Tooltips come from: http://www.dustindiaz.com/sweet-titles Rounded Divs comme from : http://www.html.it/articoli/niftycube/index.html """ return """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://w...
""" % (configuration.app_name, title)
""" % (_("%s WMI:") %configuration.app_name, title)
def head(title = _("administration %s") % configuration.app_name): """Build the HTML Page header. Bubble Tooltips come from: http://www.dustindiaz.com/sweet-titles Rounded Divs comme from : http://www.html.it/articoli/niftycube/index.html """ return """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://w...
descr='''scenario for ticket
descr='''scenario for ticket ''' --add-group and --del-groups & fix
def test_profiles(context): """Test the applying feature of profiles.""" pname = 'profil_test' gname = 'group_test' #fix #271 ScenarioTest([ ADD + [ 'profile', '--name=%s' % pname, '-v' ], GET + [ 'profiles' ], ADD + [ 'group', '--name=%s' % gname, '--system', '-v' ], ADD + [ 'group', '--name=%s2' % gname, '--system'...
if opts.profile and opts.profile not in LMC.profiles: opts.profile = LMC.profiles.name_to_group(opts.profile)
if opts.profile: opts.profile = LMC.profiles.guess_identifier(opts.profile)
def add_user(self, opts, args): """ Add a user account on the system. """
def __init__(self, configuration, users=None, groups=None):
def __init__(self, configuration, users=None, groups=None, warnings=True):
def __init__(self, configuration, users=None, groups=None): """ Init the LDAP backend instance. """
except herror: hostaddr = self.server.server_address
except socket.herror: hostaddr = self.server.server_address[0]
def serve_virtual_uri(self): """ Serve dynamic URIs with our own code, and create pages on the fly. """
return __pyc_primitive__(__pyc_symbol__("index_object"), self, key)
return __pyc_primitive__(__pyc_symbol__("index_object"), self, __pyc_clone_constants__(key))
def __getitem__(self, key): return __pyc_primitive__(__pyc_symbol__("index_object"), self, key)
return __pyc_primitive__(__pyc_symbol__("set_index_object"), self, key, value)
return __pyc_primitive__(__pyc_symbol__("set_index_object"), self, __pyc_clone_constants__(key), value)
def __setitem__(self, key, value): return __pyc_primitive__(__pyc_symbol__("set_index_object"), self, key, value)
self.longTypes = set(('ACTI','ALCH','AMMO','FURN','MISC','MSTT','PROJ','WEAP','CONT','DOOR','LIGH','STAT', 'DEBR','EXPL','MGEF','SCPT','SPEL','SOUN','NPC_','WATR','TXST','ENCH','FLST','IPDS','STAT','NOTE','QUST'))
self.longTypes = set(('ACTI','ALCH','AMMO','ARMO','BOOK','CONT','CREA','DEBR','DIAL', 'DOOR','ENCH','EXPL','FACT','FLOR','FLST','FURN','INFO','INGR', 'IPDS','KEYM','LIGH','MGEF','MISC','MSTT','NOTE','NPC_','PROJ', 'QUST','SCPT','SOUN','SPEL','STAT','TERM','TXST','WATR','WEAP'))
def initPatchFile(self,patchFile,loadMods): """Prepare to handle specified patch mod. All functions are called after this.""" Patcher.initPatchFile(self,patchFile,loadMods) self.id_data = {} #--Names keyed by long fid. self.srcClasses = set() #--Record classes actually provided by src mods/files. self.sourceMods = self...
MelString('DESC','descriptio'),
MelString('DESC','description'),
def loadData(self,record,ins,type,size,readId): if size == 4: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 3: unpacked = ins.unpack('BBB',size,readId) else: raise "Unexpected size encountered for TERM:DNAM subrecord: %s" % size unpacked += self.defaults[len(unpacked):] setter = record.__seta...
progress.setFull(len(self.sourceMods))
progress.setFull(1+len(self.sourceMods))
def checkMasterCellBlockData(cellBlock): if not cellBlock.cell.flags1.ignored: fid = cellBlock.cell.fid if fid not in tempCellData: return if fid not in cellData: cellData[fid] = {} cellData[fid+('flags',)] = {} for attr in attrs: if tempCellData[fid][attr] != cellBlock.cell.__getattribute__(attr): cellData[fid][attr] ...
progress.setFull(len(self.sourceMods))
progress.setFull(1+len(self.sourceMods))
def initData(self,progress): """Get graphics from source files.""" if not self.isActive: return id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,*recAttrs_class.keys()) longTypes = self.longTypes & set(x.classType for x in self.recAttrs_class) progress.setFull(len(self.sourceM...
progress.setFull(len(self.sourceMods))
progress.setFull(1+len(self.sourceMods))
def initData(self,progress): """Get graphics from source files.""" if not self.isActive: return id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,MreNpc,MreCrea) longTypes = self.longTypes & set(x.classType for x in self.actorClasses) progress.setFull(len(self.sourceMods)) cach...
progress.setFull(len(self.srcMods))
progress.setFull(1+len(self.srcMods))
def initData(self,progress): """Get data from source files.""" OOOandUOP = False if GPath("Oscuro's_Oblivion_Overhaul.esm") in self.srcMods or GPath("Oscuro's_Oblivion_Overhaul.esp") in self.srcMods: if GPath("Unofficial Oblivion Patch.esp") in self.srcMods: OOOandUOP = True longTypes = self.longTypes loadFactory = Loa...
progress.setFull(len(self.sourceMods))
progress.setFull(1+len(self.sourceMods))
def initData(self,progress): """Get graphics from source files.""" if not self.isActive: return self.classestemp = set() id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,*recAttrs_class.keys()) longTypes = self.longTypes & set(x.classType for x in self.recAttrs_class) progress...
progress.setFull(len(self.srcFiles))
progress.setFull(1+len(self.srcFiles))
def initData(self,progress): """Get names from source files.""" if not self.isActive: return actorFactions = ActorFactions(aliases=self.patchFile.aliases) progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if reModExt.search(srcFile.s): if src...
progress.setFull(len(self.srcFiles))
progress.setFull(1+len(self.srcFiles))
def initData(self,progress): """Get names from source files.""" if not self.isActive: return factionRelations = FactionRelations(aliases=self.patchFile.aliases) progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if reModExt.search(srcFile.s): ...
progress.setFull(len(self.sourceMods))
progress.setFull(1+len(self.sourceMods))
def initData(self,progress): """Get script links from source files.""" if not self.isActive: return self.classestemp = set() id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,*recAttrs_class.keys()) longTypes = self.longTypes & set(x.classType for x in self.recAttrs_class) prog...
progress.setFull(len(self.srcMods))
progress.setFull(1+len(self.srcMods))
def initData(self,progress): """Get data from source files.""" if not self.isActive or not self.srcMods: return loadFactory = LoadFactory(False,'CREA','NPC_','CONT') progress.setFull(len(self.srcMods)) for index,srcMod in enumerate(self.srcMods): srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory) srcFile...
progress.setFull(len(self.srcFiles))
progress.setFull(1+len(self.srcFiles))
def initData(self,progress): """Get names from source files.""" if not self.isActive: return fullNames = FullNames(aliases=self.patchFile.aliases) progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if reModExt.search(srcFile.s): if srcPath not...
progress.setFull(len(self.faceMods))
progress.setFull(1+len(self.faceMods))
def initData(self,progress): """Get faces from Project Beauty files.""" if not self.isActive: return faceData = self.faceData loadFactory = LoadFactory(False,MreNpc) progress.setFull(len(self.faceMods)) cachedMasters = {} for index,faceMod in enumerate(self.faceMods): if faceMod not in modInfos: continue temp_faceData ...
progress.setFull(len(self.sourceMods))
progress.setFull(1+len(self.sourceMods))
def initData(self,progress): """Get cells from source files.""" if not self.isActive: return loadFactory = LoadFactory(False,MreCell,MreWrld,MreRoad) progress.setFull(len(self.sourceMods)) for srcMod in self.sourceMods: if srcMod not in modInfos: continue srcInfo = modInfos[srcMod] srcFile = ModFile(srcInfo,loadFactory...
progress.setFull(len(self.sourceMods))
progress.setFull(1+len(self.sourceMods))
def initData(self,progress): """Get sounds from source files.""" if not self.isActive: return id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,*recAttrs_class.keys()) longTypes = self.longTypes & set(x.classType for x in self.recAttrs_class) progress.setFull(len(self.sourceMod...
progress.setFull(len(self.srcFiles))
progress.setFull(1+len(self.srcFiles))
def initData(self,progress): """Get stats from source files.""" if not self.isActive: return itemStats = ItemStats(aliases=self.patchFile.aliases) progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if reModExt.search(srcFile.s): if srcPath not...
progress.setFull(len(self.srcFiles))
progress.setFull(1+len(self.srcFiles))
def initData(self,progress): """Get stats from source files.""" if not self.isActive: return itemStats = SpellRecords(aliases=self.patchFile.aliases) progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if reModExt.search(srcFile.s): if srcPath ...
progress.setFull(len(self.sourceMods))
progress.setFull(1+len(self.sourceMods))
def initData(self,progress): """Get graphics from source files.""" if not self.isActive: return id_data = self.id_data recAttrs_class = self.recAttrs_class loadFactory = LoadFactory(False,*recAttrs_class.keys()) longTypes = self.longTypes & set(x.classType for x in self.recAttrs_class) progress.setFull(len(self.sourceM...
progress.setFull(len(self.srcFiles))
progress.setFull(1+len(self.srcFiles))
def initData(self,progress): """Get names from source files.""" if not self.isActive: return progress.setFull(len(self.srcFiles)) for srcFile in self.srcFiles: srcPath = GPath(srcFile) patchesDir = dirs['patches'].list() if srcPath not in patchesDir: continue self.readFromText(dirs['patches'].join(srcFile)) progress.pl...