rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
self.configuration.groups.names['plural'])):
self.configuration.groups.names['plural'])) \ or home.find('/tmp') != -1:
def validate_home_dir(home=home, login=login, system=system, force=force): """ Do some basic but sane tests on the home dir provided. """
b410e15f1096285bc18bb2325c5ae83b8b5aefbb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/b410e15f1096285bc18bb2325c5ae83b8b5aefbb/users.py
'''%s is outside %s and /var, or inside %s/%s. '''
'''%s is outside %s and /var, or inside %s/%s ''' '''and a temporary directory (/var/tmp, /tmp). '''
def validate_home_dir(home=home, login=login, system=system, force=force): """ Do some basic but sane tests on the home dir provided. """
b410e15f1096285bc18bb2325c5ae83b8b5aefbb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/b410e15f1096285bc18bb2325c5ae83b8b5aefbb/users.py
def clear_term(): sys.stdout.write(clear) sys.stdout.flush()
68ddcd089decd22f0c14469b85d4c5afbbd34f54 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/68ddcd089decd22f0c14469b85d4c5afbbd34f54/core.py
def cmdfmt(cmd): '''convert a sequence to a colorized string.''' return styles.stylize(styles.ST_NAME, ' '.join(cmd))
68ddcd089decd22f0c14469b85d4c5afbbd34f54 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/68ddcd089decd22f0c14469b85d4c5afbbd34f54/core.py
def test_message(msg): """ display a message to stderr. """ sys.stderr.write("%s>>> %s%s\n" % (styles.colors[styles.ST_LOG], msg, styles.colors[styles.ST_NO]) )
68ddcd089decd22f0c14469b85d4c5afbbd34f54 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/68ddcd089decd22f0c14469b85d4c5afbbd34f54/core.py
def log_and_exec (command, inverse_test=False, result_code=0, comment="", verb=verbose): """Display a command, execute it, and exit if soemthing went wrong.""" #if not command.startswith('colordiff'): # command += ' %s' % ' '.join(args) sys.stderr.write("%s>>> running %s%s%s\n" % (styles.colors[styles.ST_LOG], styles.colors[styles.ST_PATH], command, styles.colors[styles.ST_NO])) output, retcode = execute(command) must_exit = False # # TODO: implement a precise test on a precise exit value. # for example, when you try to add a group with an invalid name, # licorn-add should exit (e.g.) 34. We must test on this precise # value and not on != 0, because if something wrong but *other* than # errno 34 happened, we won't know it if we don't check carefully the # program output. # if inverse_test: if retcode != result_code: must_exit = True else: if retcode != 0: must_exit = True if must_exit: if inverse_test: test = (" %s→ it should have failed with reason: %s%s%s\n" % (styles.colors[styles.ST_PATH], styles.colors[styles.ST_BAD], comment, styles.colors[styles.ST_NO])) else: test = "" sys.stderr.write(" %s→ return code of command: %s%d%s (expected: %d)%s\n%s → log follows:\n" % ( styles.colors[styles.ST_LOG], styles.colors[styles.ST_BAD], retcode, styles.colors[styles.ST_LOG], result_code, styles.colors[styles.ST_NO], test) ) sys.stderr.write(output) sys.stderr.write( "The last command failed to execute, or return something wrong !\n") raise SystemExit(retcode) if verb: sys.stderr.write(output)
68ddcd089decd22f0c14469b85d4c5afbbd34f54 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/68ddcd089decd22f0c14469b85d4c5afbbd34f54/core.py
def strip_dates(str): """ strip dates from warnings and traces, else outputs and references always compare false .""" return re.sub(r'\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)
68ddcd089decd22f0c14469b85d4c5afbbd34f54 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/68ddcd089decd22f0c14469b85d4c5afbbd34f54/core.py
make_path = lambda x: ('_'.join(x)).replace('../', '').replace('//','_').replace('/','_')
make_path = lambda x: ('_'.join(x)).replace('__', '_').replace( './', '').replace('../', '').replace('//','_').replace( '/','_').replace('>','').replace('&', '')
def Prepare(self, cmd): """ Run commands mandatory for func_test to succeed. """
68ddcd089decd22f0c14469b85d4c5afbbd34f54 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/68ddcd089decd22f0c14469b85d4c5afbbd34f54/core.py
logging.warning('command "%s" failed (retcode %d instead of %d).\nPath: %s' % ( cmdfmt(cmd), retcode, ref_code, self.ref_code_file))
logging.warning( '''command "%s" failed (retcode %d instead of %d).\n''' '''(Reference path: %s)''' % ( styles.stylize(styles.ST_NAME, cmdfmt(cmd)), styles.stylize(styles.ST_BAD,retcode), styles.stylize(styles.ST_OK, ref_code), self.ref_code_file))
def RunAndCheck(self, cmd, batch = False, inverse_test=False): ref_output, ref_code = self.PrepareReferenceOutput(cmd)
68ddcd089decd22f0c14469b85d4c5afbbd34f54 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/68ddcd089decd22f0c14469b85d4c5afbbd34f54/core.py
gid = manual_gid
if (system and GroupsController.is_system_gid(manual_gid)) \ or (not system and GroupsController.is_standard_gid( manual_gid)): gid = manual_gid else: raise exceptions.BadArgumentError('''GID out of range ''' '''for the kind of group you specified. System GID ''' '''must be between %d and %d, standard GID must be ''' '''between %d and %d.''' % ( self.configuration.groups.system_gid_min, self.configuration.groups.system_gid_max, self.configuration.groups.gid_min, self.configuration.groups.gid_max) )
def __add_group(self, name, system, manual_gid=None, description = "", groupSkel = "", batch=False, force=False): """ Add a POSIX group, write the system data files. Return the gid of the group created."""
f0e4c86365a195e4a5db9a817af2516760012569 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/f0e4c86365a195e4a5db9a817af2516760012569/groups.py
return (w.HTTP_TYPE_TEXT, w.page(title, w.error(_("Forbidden action"),
return (HTTP_TYPE_TEXT, page(title, error(_("Forbidden action"),
def forgery_error(title): return (w.HTTP_TYPE_TEXT, w.page(title, w.error(_("Forbidden action"), [ _("Some parts of the system cannot be modified.") ], _("insufficient permissions to perform operation."))))
1630a65f4364354de82f4b2bcfdc9d564e55ac6e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1630a65f4364354de82f4b2bcfdc9d564e55ac6e/utils.py
title = _("Showing details of group %s") % name data = '%s\n%s\n%s\n' % (w.backto(), __groups_actions(), w.menu(uri))
title = _("Details of group %s") % name data = w.page_body_start(uri, http_user, ctxtnav, title)
def view(uri, http_user, name): """Prepare a group view to be printed.""" users.reload() groups.reload() title = _("Showing details of group %s") % name data = '%s\n%s\n%s\n' % (w.backto(), __groups_actions(), w.menu(uri)) 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) members.sort() members_html = ''' <h2>%s</h2><div style="text-align:center;">%s</div> <table class="group_members"> <tr> <td><strong>%s</strong></td> <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>' if not groups.is_system_group(name): resps = groups.all_members(configuration.groups.resp_prefix + name) resps.sort() guests = \ groups.all_members(configuration.groups.guest_prefix + name) guests.sort() if resps != []: resps_html = ''' <h2>%s</h2><div style="text-align:center;">%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.') if guests != []: guests_html = ''' <h2>%s</h2><div style="text-align:center;">%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 for this group.') else: resps_html = guests_html = '' form_name = "group_print_form" data += ''' <div id="content"> <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['gid'], _('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))
eb92fc56664814fed9f428d02ee7bb3f8903a836 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/eb92fc56664814fed9f428d02ee7bb3f8903a836/groups.py
members.sort() members_html = ''' <h2>%s</h2><div style="text-align:center;">%s</div> <table class="group_members"> <tr> <td><strong>%s</strong></td> <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>'
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.')
def view(uri, http_user, name): """Prepare a group view to be printed.""" users.reload() groups.reload() title = _("Showing details of group %s") % name data = '%s\n%s\n%s\n' % (w.backto(), __groups_actions(), w.menu(uri)) 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) members.sort() members_html = ''' <h2>%s</h2><div style="text-align:center;">%s</div> <table class="group_members"> <tr> <td><strong>%s</strong></td> <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>' if not groups.is_system_group(name): resps = groups.all_members(configuration.groups.resp_prefix + name) resps.sort() guests = \ groups.all_members(configuration.groups.guest_prefix + name) guests.sort() if resps != []: resps_html = ''' <h2>%s</h2><div style="text-align:center;">%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.') if guests != []: guests_html = ''' <h2>%s</h2><div style="text-align:center;">%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 for this group.') else: resps_html = guests_html = '' form_name = "group_print_form" data += ''' <div id="content"> <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['gid'], _('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))
eb92fc56664814fed9f428d02ee7bb3f8903a836 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/eb92fc56664814fed9f428d02ee7bb3f8903a836/groups.py
resps = groups.all_members(configuration.groups.resp_prefix + name) resps.sort() guests = \ groups.all_members(configuration.groups.guest_prefix + name) guests.sort()
resps = 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)
eb92fc56664814fed9f428d02ee7bb3f8903a836 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/eb92fc56664814fed9f428d02ee7bb3f8903a836/groups.py
<h2>%s</h2><div style="text-align:center;">%s</div>
<h2>%s</h2> <div style="text-align:left;">%s</div>
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)
eb92fc56664814fed9f428d02ee7bb3f8903a836 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/eb92fc56664814fed9f428d02ee7bb3f8903a836/groups.py
''' % (_('Responsibles'), _('(ordered by login)'), _('Full Name'), _('Identifier'), _('UID'), "\n".join(map(user_line, resps)))
''' % ( _('Responsibles'), _('(ordered by login)'), _('Full Name'), _('Identifier'), _('UID'), "\n".join(map(user_line, resps)) )
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)
eb92fc56664814fed9f428d02ee7bb3f8903a836 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/eb92fc56664814fed9f428d02ee7bb3f8903a836/groups.py
<h2>%s</h2><div style="text-align:center;">%s</div>
<h2>%s</h2> <div style="text-align:left;">%s</div>
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)
eb92fc56664814fed9f428d02ee7bb3f8903a836 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/eb92fc56664814fed9f428d02ee7bb3f8903a836/groups.py
''' % (_('Guests'), _('(ordered by login)'), _('Full Name'), _('Identifier'), _('UID'), "\n".join(map(user_line, guests))) else: guests_html = "<h2>%s</h2>" % _('No guests for this group.')
''' % ( _('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.')
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)
eb92fc56664814fed9f428d02ee7bb3f8903a836 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/eb92fc56664814fed9f428d02ee7bb3f8903a836/groups.py
<div id="content">
<div id="details">
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)
eb92fc56664814fed9f428d02ee7bb3f8903a836 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/eb92fc56664814fed9f428d02ee7bb3f8903a836/groups.py
_('GID'), _('immutable'), group['gid'], _('Name'), _('immutable'), name, members_html, resps_html, guests_html,
_('GID'), _('immutable'), group['gid'], _('Name'), _('immutable'), name, members_html, resps_html, guests_html,
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)
eb92fc56664814fed9f428d02ee7bb3f8903a836 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/eb92fc56664814fed9f428d02ee7bb3f8903a836/groups.py
onClick="javascript:window.print(); return false;", accesskey=_('P'))
onClick="javascript:window.print(); return false;", accesskey=_('P'))
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)
eb92fc56664814fed9f428d02ee7bb3f8903a836 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/eb92fc56664814fed9f428d02ee7bb3f8903a836/groups.py
if not UsersController.is_system_uid(uid):
if UsersController.is_system_uid(uid): logging.progress("Checking system account %s..." % \ styles.stylize(styles.ST_NAME, user)) if os.path.exists(self.users[uid]['homeDirectory']): home_dir_info = [ { 'path' : self.users[uid]['homeDirectory'], 'user' : user, 'group' : self.groups.groups[ self.users[uid]['gidNumber']]['name'], 'mode' : 00700, 'content_mode': 00600 } ] all_went_ok &= fsapi.check_dirs_and_contents_perms_and_acls( home_dir_info, batch, auto_answer, UsersController.groups, self) else:
def check_user(user, minimal = minimal, batch = batch, auto_answer = auto_answer):
c1402cdb75c740c515f02436db8af8480233b421 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/c1402cdb75c740c515f02436db8af8480233b421/users.py
print dir(self.backends)
def SetMissingMandatoryDefauts(self): """ The defaults set here are expected to exist by other parts of the programs. """
3930e7f08f68e0a95f2ebab937f10236c8299314 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/3930e7f08f68e0a95f2ebab937f10236c8299314/configuration.py
raise exceptions.LicornRuntimeError("Filesystem must be mounted with `acl' option:\n\t%s" % e)
raise exceptions.LicornRuntimeError("Filesystem must be mounted with 'acl' option:\n\t%s" % e)
def CheckBaseDirs(self, minimal = True, batch = False, auto_answer = None) : """Check and eventually repair default needed dirs."""
5f520867b3ef14a7fdba756665f78d5a9a2ce3de /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/5f520867b3ef14a7fdba756665f78d5a9a2ce3de/configuration.py
dirs_to_verify = [ { 'path' : self.home_backup_dir, 'user' : 'root', 'group' : 'acl', 'access_acl' : "%s,%s,%s" % (acl_base, acl_admins_ro, acl_mask), 'default_acl' : "%s,%s,%s" % (acl_base, acl_admins_ro, acl_mask), 'content_acl' : ("%s,%s,%s" % (acl_base, acl_admins_ro, acl_mask)).replace('r-x', 'r--').replace('rwx', 'rw-'), }, { 'path' : self.home_archive_dir, 'user' : 'root', 'group' : 'acl', 'access_acl' : "%s,%s,%s" % (acl_base, acl_admins_rw, acl_mask), 'default_acl' : "%s,%s,%s" % (acl_base, acl_admins_rw, acl_mask), 'content_acl' : ("%s,%s,%s" % (acl_base, acl_admins_rw, acl_mask)).replace('r-x', 'r--').replace('rwx', 'rw-'), } ] fsapi.check_dirs_and_contents_perms_and_acls(dirs_to_verify, batch = True, allgroups = groups)
home_backup_dir_info['content_acl'] = ("%s,%s,%s" % (acl_base, acl_admins_ro, acl_mask) ).replace('r-x', 'r--').replace('rwx', 'rw-') home_archive_dir_info['content_acl'] = ("%s,%s,%s" % (acl_base, acl_admins_rw, acl_mask) ).replace('r-x', 'r--').replace('rwx', 'rw-') dirs_to_verify = [ home_backup_dir_info, home_archive_dir_info ] fsapi.check_dirs_and_contents_perms_and_acls(dirs_to_verify, batch = True, allgroups = groups)
def CheckBaseDirs(self, minimal = True, batch = False, auto_answer = None) : """Check and eventually repair default needed dirs."""
5f520867b3ef14a7fdba756665f78d5a9a2ce3de /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/5f520867b3ef14a7fdba756665f78d5a9a2ce3de/configuration.py
_("Definitely remove account from the LMC.system."))
_("Definitely remove account from the system."))
def html_build_compact(index, accounts = accounts): uid = ordered[index] login = u[uid]['login'] edit = (_('''<em>Click to edit current user account parameters:</em> <br /> UID: <strong>%d</strong><br /> GID: %d (primary group <strong>%s</strong>)<br /><br /> Groups:&#160;<strong>%s</strong><br /><br /> Privileges:&#160;<strong>%s</strong><br /><br /> Responsabilities:&#160;<strong>%s</strong><br /><br /> Invitations:&#160;<strong>%s</strong><br /><br /> ''') % ( uid, u[uid]['gidNumber'], g[u[uid]['gidNumber']]['name'], ", ".join(filter(lambda x: x in std_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in pri_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in rsp_grps, u[uid]['groups'])), ", ".join(filter( lambda x: x in gst_grps, u[uid]['groups'])))).replace( '<','&lt;').replace('>','&gt;')
e97f363143e453c04ea24ae1f95dda2b53bdd037 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/e97f363143e453c04ea24ae1f95dda2b53bdd037/users.py
'(objectClass=o)')
'(objectClass=organization)')
def last_init_check(self): """ do a quick LDAP content check, to validate everything is valid. """
22534bce6c23ef61f6a54317db57e0068cfa1fb3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/22534bce6c23ef61f6a54317db57e0068cfa1fb3/ldap_backend.py
onClick = 'onClick="javascript: return(false);"'
onClick = 'onClick="javascript: return(false);"'
def ctxtnav(active = True): if active: disabled = ''; onClick = ''; else: disabled = 'un-clickable'; onClick = 'onClick="javascript: return(false);"' return ''' <div id="ctxtnav" class="nav"> <h2>Context Navigation</h2> <ul> <li><a href="/users/new" title="%s" %s class="%s"><div class="ctxt-icon %s" id="icon-add">%s</div></a></li> <li><a href="/users/import" title="%s" %s class="%s"><div class="ctxt-icon %s" id="icon-import">%s</div></a></li> <li><a href="/users/export" title="%s" %s class="%s"><div class="ctxt-icon %s" id="icon-export">%s</div></a></li> </ul> </div> ''' % ( _("Add a new user account on the system."), onClick, disabled, disabled, _("Add an account"), _("Import new user accounts from a CSV-delimited file."), onClick, disabled, disabled, _("Import accounts"), _("Export current user accounts list to a CSV or XML file."), onClick, disabled, disabled, _("Export accounts") )
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
w.backto(), w.metanav(http_user), w.menu(uri), ctxtnav(), title)
w.backto(), w.metanav(http_user), w.menu(uri), ctxtnav(), title)
def export(uri, http_user, type = "", yes = None): """ Export user accounts list.""" # TODO: reload(profiles) groups.reload() users.reload() del yes title = _("Export user accounts list") data = '<div id="banner">\n%s\n%s</div>\n%s\n<div id="main">\n%s\n<div id="content"><h1>%s</h1>' % ( w.backto(), w.metanav(http_user), w.menu(uri), ctxtnav(), title) if type == "": description = _('''CSV file-format is used by spreadsheets and most systems which offer import functionnalities. XML file-format is a modern exchange format, used in soma applications which respect interoperability constraints.<br /><br />When you submit this form, your web browser will automatically offer you to download and save the export-file (it won't be displayed). When you're done, please click the “back” button of your browser.''') form_options = _("Which file format do you want accounts to be exported to? %s") % w.select("type", [ "CSV", "XML"]) data += w.question(_("Please choose file format for export list"), description, yes_values = [ _("Export >>"), "/users/export", "E" ], no_values = [ _("<< Cancel"), "/users/list", "N" ], form_options = form_options) data += '</div><!-- end main -->' return w.page(title, data) else: users.Select(users.FILTER_STANDARD) # TODO: convert this. #req.headers_out["Content-type"] = "application/force-download" #req.headers_out["Content-Disposition"] = "attachment; filename=export.%s" % type.lower() #header("Pragma: no-cache"); #header("Expires: 0"); if type == "CSV": return users.ExportCSV() else: return users.ExportXML()
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def export(uri, http_user, type = "", yes = None): """ Export user accounts list.""" # TODO: reload(profiles) groups.reload() users.reload() del yes title = _("Export user accounts list") data = '<div id="banner">\n%s\n%s</div>\n%s\n<div id="main">\n%s\n<div id="content"><h1>%s</h1>' % ( w.backto(), w.metanav(http_user), w.menu(uri), ctxtnav(), title) if type == "": description = _('''CSV file-format is used by spreadsheets and most systems which offer import functionnalities. XML file-format is a modern exchange format, used in soma applications which respect interoperability constraints.<br /><br />When you submit this form, your web browser will automatically offer you to download and save the export-file (it won't be displayed). When you're done, please click the “back” button of your browser.''') form_options = _("Which file format do you want accounts to be exported to? %s") % w.select("type", [ "CSV", "XML"]) data += w.question(_("Please choose file format for export list"), description, yes_values = [ _("Export >>"), "/users/export", "E" ], no_values = [ _("<< Cancel"), "/users/list", "N" ], form_options = form_options) data += '</div><!-- end main -->' return w.page(title, data) else: users.Select(users.FILTER_STANDARD) # TODO: convert this. #req.headers_out["Content-type"] = "application/force-download" #req.headers_out["Content-Disposition"] = "attachment; filename=export.%s" % type.lower() #header("Pragma: no-cache"); #header("Expires: 0"); if type == "CSV": return users.ExportCSV() else: return users.ExportXML()
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def export(uri, http_user, type = "", yes = None): """ Export user accounts list.""" # TODO: reload(profiles) groups.reload() users.reload() del yes title = _("Export user accounts list") data = '<div id="banner">\n%s\n%s</div>\n%s\n<div id="main">\n%s\n<div id="content"><h1>%s</h1>' % ( w.backto(), w.metanav(http_user), w.menu(uri), ctxtnav(), title) if type == "": description = _('''CSV file-format is used by spreadsheets and most systems which offer import functionnalities. XML file-format is a modern exchange format, used in soma applications which respect interoperability constraints.<br /><br />When you submit this form, your web browser will automatically offer you to download and save the export-file (it won't be displayed). When you're done, please click the “back” button of your browser.''') form_options = _("Which file format do you want accounts to be exported to? %s") % w.select("type", [ "CSV", "XML"]) data += w.question(_("Please choose file format for export list"), description, yes_values = [ _("Export >>"), "/users/export", "E" ], no_values = [ _("<< Cancel"), "/users/list", "N" ], form_options = form_options) data += '</div><!-- end main -->' return w.page(title, data) else: users.Select(users.FILTER_STANDARD) # TODO: convert this. #req.headers_out["Content-type"] = "application/force-download" #req.headers_out["Content-Disposition"] = "attachment; filename=export.%s" % type.lower() #header("Pragma: no-cache"); #header("Expires: 0"); if type == "CSV": return users.ExportCSV() else: return users.ExportXML()
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
if type == "CSV":
if type == "CSV":
def export(uri, http_user, type = "", yes = None): """ Export user accounts list.""" # TODO: reload(profiles) groups.reload() users.reload() del yes title = _("Export user accounts list") data = '<div id="banner">\n%s\n%s</div>\n%s\n<div id="main">\n%s\n<div id="content"><h1>%s</h1>' % ( w.backto(), w.metanav(http_user), w.menu(uri), ctxtnav(), title) if type == "": description = _('''CSV file-format is used by spreadsheets and most systems which offer import functionnalities. XML file-format is a modern exchange format, used in soma applications which respect interoperability constraints.<br /><br />When you submit this form, your web browser will automatically offer you to download and save the export-file (it won't be displayed). When you're done, please click the “back” button of your browser.''') form_options = _("Which file format do you want accounts to be exported to? %s") % w.select("type", [ "CSV", "XML"]) data += w.question(_("Please choose file format for export list"), description, yes_values = [ _("Export >>"), "/users/export", "E" ], no_values = [ _("<< Cancel"), "/users/list", "N" ], form_options = form_options) data += '</div><!-- end main -->' return w.page(title, data) else: users.Select(users.FILTER_STANDARD) # TODO: convert this. #req.headers_out["Content-type"] = "application/force-download" #req.headers_out["Content-Disposition"] = "attachment; filename=export.%s" % type.lower() #header("Pragma: no-cache"); #header("Expires: 0"); if type == "CSV": return users.ExportCSV() else: return users.ExportXML()
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def delete(uri, http_user, login, sure = False, no_archive = False, yes = None): """remove user account.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes title = _("Remove user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: data += w.question(_("Are you sure you want to remove account <strong>%s</strong>?") % login, _("""User's <strong>personnal data</strong> (his/her HOME dir) will be <strong>archived</strong> in directory <code>%s</code> and members of group <strong>%s</strong> will be able to access it to operate an eventual recover.<br />However, you can decide to permanently remove it.""") % (configuration.home_archive_dir, configuration.defaults.admin_group), yes_values = [ _("Remove >>"), "/users/delete/%s/sure" % login, _("R") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = w.checkbox("no_archive", "True", _("Definitely remove account data (no archiving)."), checked = False) ) data += w.page_body_end() return w.page(title, data) else: users.reload() if users.is_system_login(login): return w.page(title, w.error(_("Failed to remove account"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) # we are sure, do it ! command = [ 'sudo', 'del', 'user', '--quiet', '--no-colors', '--login', login ] if no_archive: command.extend(['--no-archive']) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to remove account <strong>%s</strong>!") % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
it to operate an eventual recover.<br />However, you can decide to permanently
it to operate an eventual recover.<br />However, you can decide to permanently
def delete(uri, http_user, login, sure = False, no_archive = False, yes = None): """remove user account.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes title = _("Remove user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: data += w.question(_("Are you sure you want to remove account <strong>%s</strong>?") % login, _("""User's <strong>personnal data</strong> (his/her HOME dir) will be <strong>archived</strong> in directory <code>%s</code> and members of group <strong>%s</strong> will be able to access it to operate an eventual recover.<br />However, you can decide to permanently remove it.""") % (configuration.home_archive_dir, configuration.defaults.admin_group), yes_values = [ _("Remove >>"), "/users/delete/%s/sure" % login, _("R") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = w.checkbox("no_archive", "True", _("Definitely remove account data (no archiving)."), checked = False) ) data += w.page_body_end() return w.page(title, data) else: users.reload() if users.is_system_login(login): return w.page(title, w.error(_("Failed to remove account"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) # we are sure, do it ! command = [ 'sudo', 'del', 'user', '--quiet', '--no-colors', '--login', login ] if no_archive: command.extend(['--no-archive']) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to remove account <strong>%s</strong>!") % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
form_options = w.checkbox("no_archive", "True",
form_options = w.checkbox("no_archive", "True",
def delete(uri, http_user, login, sure = False, no_archive = False, yes = None): """remove user account.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes title = _("Remove user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: data += w.question(_("Are you sure you want to remove account <strong>%s</strong>?") % login, _("""User's <strong>personnal data</strong> (his/her HOME dir) will be <strong>archived</strong> in directory <code>%s</code> and members of group <strong>%s</strong> will be able to access it to operate an eventual recover.<br />However, you can decide to permanently remove it.""") % (configuration.home_archive_dir, configuration.defaults.admin_group), yes_values = [ _("Remove >>"), "/users/delete/%s/sure" % login, _("R") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = w.checkbox("no_archive", "True", _("Definitely remove account data (no archiving)."), checked = False) ) data += w.page_body_end() return w.page(title, data) else: users.reload() if users.is_system_login(login): return w.page(title, w.error(_("Failed to remove account"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) # we are sure, do it ! command = [ 'sudo', 'del', 'user', '--quiet', '--no-colors', '--login', login ] if no_archive: command.extend(['--no-archive']) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to remove account <strong>%s</strong>!") % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def delete(uri, http_user, login, sure = False, no_archive = False, yes = None): """remove user account.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes title = _("Remove user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: data += w.question(_("Are you sure you want to remove account <strong>%s</strong>?") % login, _("""User's <strong>personnal data</strong> (his/her HOME dir) will be <strong>archived</strong> in directory <code>%s</code> and members of group <strong>%s</strong> will be able to access it to operate an eventual recover.<br />However, you can decide to permanently remove it.""") % (configuration.home_archive_dir, configuration.defaults.admin_group), yes_values = [ _("Remove >>"), "/users/delete/%s/sure" % login, _("R") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = w.checkbox("no_archive", "True", _("Definitely remove account data (no archiving)."), checked = False) ) data += w.page_body_end() return w.page(title, data) else: users.reload() if users.is_system_login(login): return w.page(title, w.error(_("Failed to remove account"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) # we are sure, do it ! command = [ 'sudo', 'del', 'user', '--quiet', '--no-colors', '--login', login ] if no_archive: command.extend(['--no-archive']) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to remove account <strong>%s</strong>!") % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def delete(uri, http_user, login, sure = False, no_archive = False, yes = None): """remove user account.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes title = _("Remove user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: data += w.question(_("Are you sure you want to remove account <strong>%s</strong>?") % login, _("""User's <strong>personnal data</strong> (his/her HOME dir) will be <strong>archived</strong> in directory <code>%s</code> and members of group <strong>%s</strong> will be able to access it to operate an eventual recover.<br />However, you can decide to permanently remove it.""") % (configuration.home_archive_dir, configuration.defaults.admin_group), yes_values = [ _("Remove >>"), "/users/delete/%s/sure" % login, _("R") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = w.checkbox("no_archive", "True", _("Definitely remove account data (no archiving)."), checked = False) ) data += w.page_body_end() return w.page(title, data) else: users.reload() if users.is_system_login(login): return w.page(title, w.error(_("Failed to remove account"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) # we are sure, do it ! command = [ 'sudo', 'del', 'user', '--quiet', '--no-colors', '--login', login ] if no_archive: command.extend(['--no-archive']) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to remove account <strong>%s</strong>!") % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
return w.page(title, data +
return w.page(title, data +
def unlock(uri, http_user, login): """unlock a user account password.""" title = _("Unlock account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) users.reload() data += w.page_body_end() if users.is_system_login(login): return w.page(title, w.error(_("Failed to unlock account"), [ _("alter system account.") ], _("insufficient permission to perform operation."))) command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, "--unlock" ] return w.page(title, data + w.run(command, uri, err_msg = _("Failed to unlock account <strong>%s</strong>!") % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def lock(uri, http_user, login, sure = False, remove_remotessh = False, yes = None): """lock a user account password.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes groups.reload() users.reload() title = _("Lock account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: description = _('''This will prevent user to connect to network clients (thin ones, and Windows&reg;, %s/Linux&reg; and Macintosh&reg; ones).''') % w.acr('GNU') # TODO: Vérifier que le groupe "remotessh" existe bien sur le système... if login in groups.all_members('remotessh'): description += _("""<br /><br /> But this will not block incoming %s network connections, if the user uses %s %s or %s public/private keys. To block ANY access to the system, <strong>remove him/her from remotessh group</strong>.""") % (w.acr('SSH'), w.acr('SSH'), w.acr('RSA'), w.acr('DSA')) form_options = w.checkbox("remove_remotessh", "True", _("Remove user from group <code>remotessh</code> in the same time."), checked = True, accesskey = _('R')) else: form_options = None data += w.question(_("Are you sure you want to lock account <strong>%s</strong>?") % login, description, yes_values = [ _("Lock >>"), "/users/lock/%s/sure" % login, _("L") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = form_options) data += w.page_body_end() return w.page(title, data) else: if users.is_system_login(login): return w.page(title, w.error(_("Failed to lock account"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) # we are sure, do it ! command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, "--lock" ] if remove_remotessh: command.extend(['--del-groups', 'remotessh']) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to lock account <strong>%s</strong>!") % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
if login in groups.all_members('remotessh'): description += _("""<br /><br /> But this will not block incoming %s network connections, if the user uses %s %s or %s public/private keys. To block ANY access to the system, <strong>remove him/her from remotessh group</strong>.""") % (w.acr('SSH'), w.acr('SSH'), w.acr('RSA'), w.acr('DSA')) form_options = w.checkbox("remove_remotessh", "True", _("Remove user from group <code>remotessh</code> in the same time."), checked = True, accesskey = _('R'))
if configuration.ssh.enabled : if login in groups.all_members(configuration.ssh.group): description += _("""<br /><br /> But this will not block incoming %s network connections, if the user uses %s %s or %s public/private keys. To block ANY access to the system, <strong>remove him/her from %s group</strong>.""") % (w.acr('SSH'), w.acr('SSH'), w.acr('RSA'), w.acr('DSA'), configuration.ssh.group) form_options = w.checkbox("remove_remotessh", "True", _("Remove user from group <code>remotessh</code> in the same time."), checked = True, accesskey = _('R')) else: form_options = None
def lock(uri, http_user, login, sure = False, remove_remotessh = False, yes = None): """lock a user account password.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes groups.reload() users.reload() title = _("Lock account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: description = _('''This will prevent user to connect to network clients (thin ones, and Windows&reg;, %s/Linux&reg; and Macintosh&reg; ones).''') % w.acr('GNU') # TODO: Vérifier que le groupe "remotessh" existe bien sur le système... if login in groups.all_members('remotessh'): description += _("""<br /><br /> But this will not block incoming %s network connections, if the user uses %s %s or %s public/private keys. To block ANY access to the system, <strong>remove him/her from remotessh group</strong>.""") % (w.acr('SSH'), w.acr('SSH'), w.acr('RSA'), w.acr('DSA')) form_options = w.checkbox("remove_remotessh", "True", _("Remove user from group <code>remotessh</code> in the same time."), checked = True, accesskey = _('R')) else: form_options = None data += w.question(_("Are you sure you want to lock account <strong>%s</strong>?") % login, description, yes_values = [ _("Lock >>"), "/users/lock/%s/sure" % login, _("L") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = form_options) data += w.page_body_end() return w.page(title, data) else: if users.is_system_login(login): return w.page(title, w.error(_("Failed to lock account"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) # we are sure, do it ! command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, "--lock" ] if remove_remotessh: command.extend(['--del-groups', 'remotessh']) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to lock account <strong>%s</strong>!") % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def lock(uri, http_user, login, sure = False, remove_remotessh = False, yes = None): """lock a user account password.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes groups.reload() users.reload() title = _("Lock account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: description = _('''This will prevent user to connect to network clients (thin ones, and Windows&reg;, %s/Linux&reg; and Macintosh&reg; ones).''') % w.acr('GNU') # TODO: Vérifier que le groupe "remotessh" existe bien sur le système... if login in groups.all_members('remotessh'): description += _("""<br /><br /> But this will not block incoming %s network connections, if the user uses %s %s or %s public/private keys. To block ANY access to the system, <strong>remove him/her from remotessh group</strong>.""") % (w.acr('SSH'), w.acr('SSH'), w.acr('RSA'), w.acr('DSA')) form_options = w.checkbox("remove_remotessh", "True", _("Remove user from group <code>remotessh</code> in the same time."), checked = True, accesskey = _('R')) else: form_options = None data += w.question(_("Are you sure you want to lock account <strong>%s</strong>?") % login, description, yes_values = [ _("Lock >>"), "/users/lock/%s/sure" % login, _("L") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = form_options) data += w.page_body_end() return w.page(title, data) else: if users.is_system_login(login): return w.page(title, w.error(_("Failed to lock account"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) # we are sure, do it ! command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, "--lock" ] if remove_remotessh: command.extend(['--del-groups', 'remotessh']) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to lock account <strong>%s</strong>!") % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
if remove_remotessh: command.extend(['--del-groups', 'remotessh'])
if configuration.ssh.enabled and remove_remotessh: command.extend(['--del-groups', configuration.ssh.group])
def lock(uri, http_user, login, sure = False, remove_remotessh = False, yes = None): """lock a user account password.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes groups.reload() users.reload() title = _("Lock account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if not sure: description = _('''This will prevent user to connect to network clients (thin ones, and Windows&reg;, %s/Linux&reg; and Macintosh&reg; ones).''') % w.acr('GNU') # TODO: Vérifier que le groupe "remotessh" existe bien sur le système... if login in groups.all_members('remotessh'): description += _("""<br /><br /> But this will not block incoming %s network connections, if the user uses %s %s or %s public/private keys. To block ANY access to the system, <strong>remove him/her from remotessh group</strong>.""") % (w.acr('SSH'), w.acr('SSH'), w.acr('RSA'), w.acr('DSA')) form_options = w.checkbox("remove_remotessh", "True", _("Remove user from group <code>remotessh</code> in the same time."), checked = True, accesskey = _('R')) else: form_options = None data += w.question(_("Are you sure you want to lock account <strong>%s</strong>?") % login, description, yes_values = [ _("Lock >>"), "/users/lock/%s/sure" % login, _("L") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = form_options) data += w.page_body_end() return w.page(title, data) else: if users.is_system_login(login): return w.page(title, w.error(_("Failed to lock account"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) # we are sure, do it ! command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, "--lock" ] if remove_remotessh: command.extend(['--del-groups', 'remotessh']) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to lock account <strong>%s</strong>!") % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def skel(uri, http_user, login, sure = False, apply_skel = configuration.users.default_skel, yes = None): """reapply a user's skel with confirmation.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes # TODO: profiles.reload() groups.reload() users.reload() u = users.users g = groups.groups title = _("Reapply skel to user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if users.is_system_login(login): return w.page(title, w.error(_("Failed to reapply skel"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) if not sure: description = _('''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.''') pri_group = g[u[users.login_to_uid(login)]['gid']]['name'] # liste des skels du profile en cours. def filter_skels(pri_group, sk_list): ''' TODO: to be converted to licorn model if pri_group == configuration.mNames['RESPONSABLES_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['RESPONSABLES_GROUP']) != -1, sk_list) elif pri_group == configuration.mNames['USAGERS_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['USAGERS_GROUP']) != -1, sk_list) else: ''' return sk_list form_options = _("Which skel do you want to apply? %s") % w.select("apply_skel", filter_skels(pri_group, configuration.users.skels), func = os.path.basename) data += w.question(_("Are you sure you want to apply this skel to account <strong>%s</strong>?") % login, description, yes_values = [ _("Apply >>"), "/users/skel/%s/sure" % login, _("A") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = form_options) data += w.page_body_end() return w.page(title, data) else: # we are sure, do it ! command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, '--apply-skel', apply_skel ] data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to apply skel <strong>%s</strong> on user account <strong>%s</strong>!") % (os.path.basename(apply_skel), login)))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def skel(uri, http_user, login, sure = False, apply_skel = configuration.users.default_skel, yes = None): """reapply a user's skel with confirmation.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes # TODO: profiles.reload() groups.reload() users.reload() u = users.users g = groups.groups title = _("Reapply skel to user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if users.is_system_login(login): return w.page(title, w.error(_("Failed to reapply skel"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) if not sure: description = _('''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.''') pri_group = g[u[users.login_to_uid(login)]['gid']]['name'] # liste des skels du profile en cours. def filter_skels(pri_group, sk_list): ''' TODO: to be converted to licorn model if pri_group == configuration.mNames['RESPONSABLES_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['RESPONSABLES_GROUP']) != -1, sk_list) elif pri_group == configuration.mNames['USAGERS_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['USAGERS_GROUP']) != -1, sk_list) else: ''' return sk_list form_options = _("Which skel do you want to apply? %s") % w.select("apply_skel", filter_skels(pri_group, configuration.users.skels), func = os.path.basename) data += w.question(_("Are you sure you want to apply this skel to account <strong>%s</strong>?") % login, description, yes_values = [ _("Apply >>"), "/users/skel/%s/sure" % login, _("A") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = form_options) data += w.page_body_end() return w.page(title, data) else: # we are sure, do it ! command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, '--apply-skel', apply_skel ] data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to apply skel <strong>%s</strong> on user account <strong>%s</strong>!") % (os.path.basename(apply_skel), login)))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def skel(uri, http_user, login, sure = False, apply_skel = configuration.users.default_skel, yes = None): """reapply a user's skel with confirmation.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes # TODO: profiles.reload() groups.reload() users.reload() u = users.users g = groups.groups title = _("Reapply skel to user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if users.is_system_login(login): return w.page(title, w.error(_("Failed to reapply skel"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) if not sure: description = _('''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.''') pri_group = g[u[users.login_to_uid(login)]['gid']]['name'] # liste des skels du profile en cours. def filter_skels(pri_group, sk_list): ''' TODO: to be converted to licorn model if pri_group == configuration.mNames['RESPONSABLES_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['RESPONSABLES_GROUP']) != -1, sk_list) elif pri_group == configuration.mNames['USAGERS_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['USAGERS_GROUP']) != -1, sk_list) else: ''' return sk_list form_options = _("Which skel do you want to apply? %s") % w.select("apply_skel", filter_skels(pri_group, configuration.users.skels), func = os.path.basename) data += w.question(_("Are you sure you want to apply this skel to account <strong>%s</strong>?") % login, description, yes_values = [ _("Apply >>"), "/users/skel/%s/sure" % login, _("A") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = form_options) data += w.page_body_end() return w.page(title, data) else: # we are sure, do it ! command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, '--apply-skel', apply_skel ] data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to apply skel <strong>%s</strong> on user account <strong>%s</strong>!") % (os.path.basename(apply_skel), login)))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def skel(uri, http_user, login, sure = False, apply_skel = configuration.users.default_skel, yes = None): """reapply a user's skel with confirmation.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del yes # TODO: profiles.reload() groups.reload() users.reload() u = users.users g = groups.groups title = _("Reapply skel to user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title) if users.is_system_login(login): return w.page(title, w.error(_("Failed to reapply skel"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) if not sure: description = _('''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.''') pri_group = g[u[users.login_to_uid(login)]['gid']]['name'] # liste des skels du profile en cours. def filter_skels(pri_group, sk_list): ''' TODO: to be converted to licorn model if pri_group == configuration.mNames['RESPONSABLES_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['RESPONSABLES_GROUP']) != -1, sk_list) elif pri_group == configuration.mNames['USAGERS_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['USAGERS_GROUP']) != -1, sk_list) else: ''' return sk_list form_options = _("Which skel do you want to apply? %s") % w.select("apply_skel", filter_skels(pri_group, configuration.users.skels), func = os.path.basename) data += w.question(_("Are you sure you want to apply this skel to account <strong>%s</strong>?") % login, description, yes_values = [ _("Apply >>"), "/users/skel/%s/sure" % login, _("A") ], no_values = [ _("<< Cancel"), "/users/list", _("C") ], form_options = form_options) data += w.page_body_end() return w.page(title, data) else: # we are sure, do it ! command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, '--apply-skel', apply_skel ] data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _("Failed to apply skel <strong>%s</strong> on user account <strong>%s</strong>!") % (os.path.basename(apply_skel), login)))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def filter_skels(pri_group, sk_list): ''' TODO: to be converted to licorn model if pri_group == configuration.mNames['RESPONSABLES_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['RESPONSABLES_GROUP']) != -1, sk_list) elif pri_group == configuration.mNames['USAGERS_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['USAGERS_GROUP']) != -1, sk_list) else: ''' return sk_list
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def filter_skels(pri_group, sk_list): ''' TODO: to be converted to licorn model if pri_group == configuration.mNames['RESPONSABLES_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['RESPONSABLES_GROUP']) != -1, sk_list) elif pri_group == configuration.mNames['USAGERS_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['USAGERS_GROUP']) != -1, sk_list) else: ''' return sk_list
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def new(uri, http_user): """Generate a form to create a new user on the system.""" # TODO: profiles.reload() groups.reload() g = groups.groups p = profiles.profiles title = _("New user account") data = w.page_body_start(uri, http_user, ctxtnav, title, False) def profile_input(): #TODO: To be rewritten ? return """ <tr> <td><strong>%s</strong></td> <td class="right">
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def new(uri, http_user): """Generate a form to create a new user on the system.""" # TODO: profiles.reload() groups.reload() g = groups.groups p = profiles.profiles title = _("New user account") data = w.page_body_start(uri, http_user, ctxtnav, title, False) def profile_input(): #TODO: To be rewritten ? return """ <tr> <td><strong>%s</strong></td> <td class="right">
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def create(uri, http_user, loginShell, password, password_confirm, profile = None, login = "", gecos = "", firstname = "", lastname = "", standard_groups_dest = [], privileged_groups_dest = [], responsible_groups_dest = [], guest_groups_dest = [], standard_groups_source = [], privileged_groups_source = [], responsible_groups_source = [], guest_groups_source = [], create = None ): # forget about it, this is a scoria from the POST FORM to variable conversion. del create title = _("New user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title, False) if password != password_confirm: return w.page(title, data + w.error(_("Passwords do not match!%s") % rewind)) if len(password) < configuration.mAutoPasswdSize: return w.page(title, data + w.error(_("Password must be at least %d characters long!%s") % (configuration.mAutoPasswdSize, rewind))) command = [ "sudo", "add", "user", '--quiet', '--no-colors', '--password', password ] if firstname != '' and lastname != '': command.extend(['--firstname', firstname, '--lastname', lastname]) if gecos != '': command.extend(['--gecos', gecos]) # TODO: set a default profile (see issue #6) if profile != None: command.extend([ "--profile", profile ]) if login != "": command.extend([ "--login", login ]) else: # TODO: Idem, "gecos" should be tested against emptyness command.extend([ '--login', hlstr.validate_name(gecos).replace('_', '.').rstrip('.') ]) retval = w.run(command, uri, err_msg = _('Failed to create account <strong>%s</strong>!') % login) # TODO: Change test since message received: Added user <login> if retval != "": return w.page(title, data + retval) # XXX: this is less than suboptimal to have to do this here... # but without this, adding to supplemental groups doesnt work. users.reload() command = [ "sudo", "mod", "user", '--quiet', "--no-colors", "--login", login, "--shell", loginShell ] add_groups = ','.join(__merge_multi_select(standard_groups_dest, privileged_groups_dest, responsible_groups_dest, guest_groups_dest)) if add_groups != "": command.extend([ '--add-groups', add_groups ]) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _('Failed to add user <strong>%s</strong> to requested groups/privileges/responsibilities/invitations!') % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def create(uri, http_user, loginShell, password, password_confirm, profile = None, login = "", gecos = "", firstname = "", lastname = "", standard_groups_dest = [], privileged_groups_dest = [], responsible_groups_dest = [], guest_groups_dest = [], standard_groups_source = [], privileged_groups_source = [], responsible_groups_source = [], guest_groups_source = [], create = None ): # forget about it, this is a scoria from the POST FORM to variable conversion. del create title = _("New user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title, False) if password != password_confirm: return w.page(title, data + w.error(_("Passwords do not match!%s") % rewind)) if len(password) < configuration.mAutoPasswdSize: return w.page(title, data + w.error(_("Password must be at least %d characters long!%s") % (configuration.mAutoPasswdSize, rewind))) command = [ "sudo", "add", "user", '--quiet', '--no-colors', '--password', password ] if firstname != '' and lastname != '': command.extend(['--firstname', firstname, '--lastname', lastname]) if gecos != '': command.extend(['--gecos', gecos]) # TODO: set a default profile (see issue #6) if profile != None: command.extend([ "--profile", profile ]) if login != "": command.extend([ "--login", login ]) else: # TODO: Idem, "gecos" should be tested against emptyness command.extend([ '--login', hlstr.validate_name(gecos).replace('_', '.').rstrip('.') ]) retval = w.run(command, uri, err_msg = _('Failed to create account <strong>%s</strong>!') % login) # TODO: Change test since message received: Added user <login> if retval != "": return w.page(title, data + retval) # XXX: this is less than suboptimal to have to do this here... # but without this, adding to supplemental groups doesnt work. users.reload() command = [ "sudo", "mod", "user", '--quiet', "--no-colors", "--login", login, "--shell", loginShell ] add_groups = ','.join(__merge_multi_select(standard_groups_dest, privileged_groups_dest, responsible_groups_dest, guest_groups_dest)) if add_groups != "": command.extend([ '--add-groups', add_groups ]) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _('Failed to add user <strong>%s</strong> to requested groups/privileges/responsibilities/invitations!') % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def create(uri, http_user, loginShell, password, password_confirm, profile = None, login = "", gecos = "", firstname = "", lastname = "", standard_groups_dest = [], privileged_groups_dest = [], responsible_groups_dest = [], guest_groups_dest = [], standard_groups_source = [], privileged_groups_source = [], responsible_groups_source = [], guest_groups_source = [], create = None ): # forget about it, this is a scoria from the POST FORM to variable conversion. del create title = _("New user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title, False) if password != password_confirm: return w.page(title, data + w.error(_("Passwords do not match!%s") % rewind)) if len(password) < configuration.mAutoPasswdSize: return w.page(title, data + w.error(_("Password must be at least %d characters long!%s") % (configuration.mAutoPasswdSize, rewind))) command = [ "sudo", "add", "user", '--quiet', '--no-colors', '--password', password ] if firstname != '' and lastname != '': command.extend(['--firstname', firstname, '--lastname', lastname]) if gecos != '': command.extend(['--gecos', gecos]) # TODO: set a default profile (see issue #6) if profile != None: command.extend([ "--profile", profile ]) if login != "": command.extend([ "--login", login ]) else: # TODO: Idem, "gecos" should be tested against emptyness command.extend([ '--login', hlstr.validate_name(gecos).replace('_', '.').rstrip('.') ]) retval = w.run(command, uri, err_msg = _('Failed to create account <strong>%s</strong>!') % login) # TODO: Change test since message received: Added user <login> if retval != "": return w.page(title, data + retval) # XXX: this is less than suboptimal to have to do this here... # but without this, adding to supplemental groups doesnt work. users.reload() command = [ "sudo", "mod", "user", '--quiet', "--no-colors", "--login", login, "--shell", loginShell ] add_groups = ','.join(__merge_multi_select(standard_groups_dest, privileged_groups_dest, responsible_groups_dest, guest_groups_dest)) if add_groups != "": command.extend([ '--add-groups', add_groups ]) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _('Failed to add user <strong>%s</strong> to requested groups/privileges/responsibilities/invitations!') % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def create(uri, http_user, loginShell, password, password_confirm, profile = None, login = "", gecos = "", firstname = "", lastname = "", standard_groups_dest = [], privileged_groups_dest = [], responsible_groups_dest = [], guest_groups_dest = [], standard_groups_source = [], privileged_groups_source = [], responsible_groups_source = [], guest_groups_source = [], create = None ): # forget about it, this is a scoria from the POST FORM to variable conversion. del create title = _("New user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title, False) if password != password_confirm: return w.page(title, data + w.error(_("Passwords do not match!%s") % rewind)) if len(password) < configuration.mAutoPasswdSize: return w.page(title, data + w.error(_("Password must be at least %d characters long!%s") % (configuration.mAutoPasswdSize, rewind))) command = [ "sudo", "add", "user", '--quiet', '--no-colors', '--password', password ] if firstname != '' and lastname != '': command.extend(['--firstname', firstname, '--lastname', lastname]) if gecos != '': command.extend(['--gecos', gecos]) # TODO: set a default profile (see issue #6) if profile != None: command.extend([ "--profile", profile ]) if login != "": command.extend([ "--login", login ]) else: # TODO: Idem, "gecos" should be tested against emptyness command.extend([ '--login', hlstr.validate_name(gecos).replace('_', '.').rstrip('.') ]) retval = w.run(command, uri, err_msg = _('Failed to create account <strong>%s</strong>!') % login) # TODO: Change test since message received: Added user <login> if retval != "": return w.page(title, data + retval) # XXX: this is less than suboptimal to have to do this here... # but without this, adding to supplemental groups doesnt work. users.reload() command = [ "sudo", "mod", "user", '--quiet', "--no-colors", "--login", login, "--shell", loginShell ] add_groups = ','.join(__merge_multi_select(standard_groups_dest, privileged_groups_dest, responsible_groups_dest, guest_groups_dest)) if add_groups != "": command.extend([ '--add-groups', add_groups ]) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _('Failed to add user <strong>%s</strong> to requested groups/privileges/responsibilities/invitations!') % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def create(uri, http_user, loginShell, password, password_confirm, profile = None, login = "", gecos = "", firstname = "", lastname = "", standard_groups_dest = [], privileged_groups_dest = [], responsible_groups_dest = [], guest_groups_dest = [], standard_groups_source = [], privileged_groups_source = [], responsible_groups_source = [], guest_groups_source = [], create = None ): # forget about it, this is a scoria from the POST FORM to variable conversion. del create title = _("New user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title, False) if password != password_confirm: return w.page(title, data + w.error(_("Passwords do not match!%s") % rewind)) if len(password) < configuration.mAutoPasswdSize: return w.page(title, data + w.error(_("Password must be at least %d characters long!%s") % (configuration.mAutoPasswdSize, rewind))) command = [ "sudo", "add", "user", '--quiet', '--no-colors', '--password', password ] if firstname != '' and lastname != '': command.extend(['--firstname', firstname, '--lastname', lastname]) if gecos != '': command.extend(['--gecos', gecos]) # TODO: set a default profile (see issue #6) if profile != None: command.extend([ "--profile", profile ]) if login != "": command.extend([ "--login", login ]) else: # TODO: Idem, "gecos" should be tested against emptyness command.extend([ '--login', hlstr.validate_name(gecos).replace('_', '.').rstrip('.') ]) retval = w.run(command, uri, err_msg = _('Failed to create account <strong>%s</strong>!') % login) # TODO: Change test since message received: Added user <login> if retval != "": return w.page(title, data + retval) # XXX: this is less than suboptimal to have to do this here... # but without this, adding to supplemental groups doesnt work. users.reload() command = [ "sudo", "mod", "user", '--quiet', "--no-colors", "--login", login, "--shell", loginShell ] add_groups = ','.join(__merge_multi_select(standard_groups_dest, privileged_groups_dest, responsible_groups_dest, guest_groups_dest)) if add_groups != "": command.extend([ '--add-groups', add_groups ]) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _('Failed to add user <strong>%s</strong> to requested groups/privileges/responsibilities/invitations!') % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
return w.page(title,
return w.page(title,
def create(uri, http_user, loginShell, password, password_confirm, profile = None, login = "", gecos = "", firstname = "", lastname = "", standard_groups_dest = [], privileged_groups_dest = [], responsible_groups_dest = [], guest_groups_dest = [], standard_groups_source = [], privileged_groups_source = [], responsible_groups_source = [], guest_groups_source = [], create = None ): # forget about it, this is a scoria from the POST FORM to variable conversion. del create title = _("New user account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title, False) if password != password_confirm: return w.page(title, data + w.error(_("Passwords do not match!%s") % rewind)) if len(password) < configuration.mAutoPasswdSize: return w.page(title, data + w.error(_("Password must be at least %d characters long!%s") % (configuration.mAutoPasswdSize, rewind))) command = [ "sudo", "add", "user", '--quiet', '--no-colors', '--password', password ] if firstname != '' and lastname != '': command.extend(['--firstname', firstname, '--lastname', lastname]) if gecos != '': command.extend(['--gecos', gecos]) # TODO: set a default profile (see issue #6) if profile != None: command.extend([ "--profile", profile ]) if login != "": command.extend([ "--login", login ]) else: # TODO: Idem, "gecos" should be tested against emptyness command.extend([ '--login', hlstr.validate_name(gecos).replace('_', '.').rstrip('.') ]) retval = w.run(command, uri, err_msg = _('Failed to create account <strong>%s</strong>!') % login) # TODO: Change test since message received: Added user <login> if retval != "": return w.page(title, data + retval) # XXX: this is less than suboptimal to have to do this here... # but without this, adding to supplemental groups doesnt work. users.reload() command = [ "sudo", "mod", "user", '--quiet', "--no-colors", "--login", login, "--shell", loginShell ] add_groups = ','.join(__merge_multi_select(standard_groups_dest, privileged_groups_dest, responsible_groups_dest, guest_groups_dest)) if add_groups != "": command.extend([ '--add-groups', add_groups ]) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _('Failed to add user <strong>%s</strong> to requested groups/privileges/responsibilities/invitations!') % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
title = _('Edit account %s') % login
title = _('Edit account %s') % login
def edit(uri, http_user, login): """Edit an user account, based on login.""" groups.reload() users.reload() # TODO: profiles.reload() title = _('Edit account %s') % login data = w.page_body_start(uri, http_user, ctxtnav, title, False) if users.is_system_login(login): return w.minipage(title, w.error(_('Account edition impossible.'), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) try: user = users.users[users.login_to_uid(login)] try: profile = profiles.profiles[groups.groups[user['gid']]['name']]['name'] except KeyError: profile = _("Standard account") dbl_lists = {} for filter, titles, id in groups_filters_lists_ids: groups.Select(filter) dest = list(user['groups'].copy()) source = [ groups.groups[gid]['name'] for gid in groups.filtered_groups ] for current in dest[:]: try: source.remove(current) except ValueError: dest.remove(current) dest.sort() source.sort() dbl_lists[filter] = w.doubleListBox(titles, id, source, dest) form_name = "user_edit_form" data += '''<div id="edit_form">
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def edit(uri, http_user, login): """Edit an user account, based on login.""" groups.reload() users.reload() # TODO: profiles.reload() title = _('Edit account %s') % login data = w.page_body_start(uri, http_user, ctxtnav, title, False) if users.is_system_login(login): return w.minipage(title, w.error(_('Account edition impossible.'), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) try: user = users.users[users.login_to_uid(login)] try: profile = profiles.profiles[groups.groups[user['gid']]['name']]['name'] except KeyError: profile = _("Standard account") dbl_lists = {} for filter, titles, id in groups_filters_lists_ids: groups.Select(filter) dest = list(user['groups'].copy()) source = [ groups.groups[gid]['name'] for gid in groups.filtered_groups ] for current in dest[:]: try: source.remove(current) except ValueError: dest.remove(current) dest.sort() source.sort() dbl_lists[filter] = w.doubleListBox(titles, id, source, dest) form_name = "user_edit_form" data += '''<div id="edit_form">
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def edit(uri, http_user, login): """Edit an user account, based on login.""" groups.reload() users.reload() # TODO: profiles.reload() title = _('Edit account %s') % login data = w.page_body_start(uri, http_user, ctxtnav, title, False) if users.is_system_login(login): return w.minipage(title, w.error(_('Account edition impossible.'), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) try: user = users.users[users.login_to_uid(login)] try: profile = profiles.profiles[groups.groups[user['gid']]['name']]['name'] except KeyError: profile = _("Standard account") dbl_lists = {} for filter, titles, id in groups_filters_lists_ids: groups.Select(filter) dest = list(user['groups'].copy()) source = [ groups.groups[gid]['name'] for gid in groups.filtered_groups ] for current in dest[:]: try: source.remove(current) except ValueError: dest.remove(current) dest.sort() source.sort() dbl_lists[filter] = w.doubleListBox(titles, id, source, dest) form_name = "user_edit_form" data += '''<div id="edit_form">
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def record(uri, http_user, login, loginShell = configuration.users.default_shell, password = "", password_confirm = "", firstname = "", lastname = "", gecos = "", standard_groups_source = [], standard_groups_dest = [], privileged_groups_source = [], privileged_groups_dest = [], responsible_groups_source = [], responsible_groups_dest = [], guest_groups_source = [], guest_groups_dest = [], record = None): """Record user account changes.""" # forget about it, this is a scoria from the POST FORM to variable conversion. del record title = _("Modification of account %s") % login data = w.page_body_start(uri, http_user, ctxtnav, title, False) command = [ "sudo", "mod", "user", '--quiet', "--no-colors", "--login", login, "--shell", loginShell ] users.reload() if users.is_system_login(login): return w.page(title, w.error(_("Recording of informations failed"), [ _("alter system account.") ], _("insufficient permissions to perform operation."))) if password != "": if password != password_confirm: return w.page(title, data + w.error(_("Passwords do not match!%s") % rewind)) if len(password) < configuration.mAutoPasswdSize: return w.page(title, data + w.error(_("The password --%s-- must be at least %d characters long!%s") % (password, configuration.mAutoPasswdSize, rewind))) command.extend([ '--password', password ]) command.extend( [ "--gecos", gecos ] ) add_groups = ','.join(__merge_multi_select(standard_groups_dest, privileged_groups_dest, responsible_groups_dest, guest_groups_dest)) del_groups = ','.join(__merge_multi_select(standard_groups_source, privileged_groups_source, responsible_groups_source, guest_groups_source)) if add_groups != "": command.extend([ '--add-groups', add_groups ]) if del_groups != "": command.extend(['--del-groups', del_groups ]) data += w.page_body_end() return w.page(title, data + w.run(command, uri, err_msg = _('Failed to modify one or more parameters of account <strong>%s</strong>!') % login))
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def main(uri, http_user, sort = "login", order = "asc"): start = time.time() groups.reload() users.reload() # TODO: profiles.reload() u = users.users g = groups.groups p = profiles.profiles groups.Select(groups.FILTER_PRIVILEGED) pri_grps = [ g[gid]['name'] for gid in groups.filtered_groups ] groups.Select(groups.FILTER_RESPONSIBLE) rsp_grps = [ g[gid]['name'] for gid in groups.filtered_groups ] groups.Select(groups.FILTER_GUEST) gst_grps = [ g[gid]['name'] for gid in groups.filtered_groups ] groups.Select(groups.FILTER_STANDARD) std_grps = [ g[gid]['name'] for gid in groups.filtered_groups ] accounts = {} ordered = {} totals = {} prof = {} for profile in p: prof[groups.name_to_gid(profile)] = p[profile] totals[p[profile]['name']] = 0 totals[_('Standard account')] = 0 title = _("User accounts") data = w.page_body_start(uri, http_user, ctxtnav, title) if order == "asc": reverseorder = "desc" else: reverseorder = "asc" data += '<table>\n <tr>\n' for (sortcolumn, sortname) in ( ("gecos", _("Full name")), ("login", _("Identifier")), ("profile", _("Profile")), ("locked", _("Locked")) ): if sortcolumn == sort: data += ''' <th><img src="/images/sort_%s.gif" alt="%s order image" />&#160; <a href="/users/list/%s/%s" title="%s">%s</a> </th>\n''' % (order, order, sortcolumn, reverseorder, _("Click to sort in reverse order."), sortname) else: data += ' <th><a href="/users/list/%s/asc" title="%s">%s</a></th>\n' % (sortcolumn, _("Click to sort on this column."), sortname) data += ' </tr>\n' def html_build_compact(index, accounts = accounts): uid = ordered[index] login = u[uid]['login'] edit = (_("""<em>Click to edit current user account parameters:</em><br /> UID: <strong>%d</strong><br /> GID: %d (primary group <strong>%s</strong>)<br /><br /> Groups:&#160;<strong>%s</strong><br /><br /> Privileges:&#160;<strong>%s</strong><br /><br /> Responsabilities:&#160;<strong>%s</strong><br /><br /> Invitations:&#160;<strong>%s</strong><br /><br /> """) % ( uid, u[uid]['gid'], g[u[uid]['gid']]['name'], ", ".join(filter(lambda x: x in std_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in pri_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in rsp_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in gst_grps, u[uid]['groups'])))).replace('<','&lt;').replace('>','&gt;') html_data = ''' <tr class="userdata"> <td class="paddedleft"> <a href="/users/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td class="paddedright"> <a href="/users/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td style="text-align:center;">%s</td> ''' % (login, edit, u[uid]['gecos'], login, edit, login, accounts[uid]['profile_name']) if u[uid]['locked']: html_data += ''' <td class="user_action_center"> <a href="/users/unlock/%s" title="%s"> <img src="/images/16x16/locked.png" alt="%s"/></a> </td> ''' % (login, _("Unlock password (re-grant access to machines)."), _("Remove account.")) else: html_data += ''' <td class="user_action_center"> <a href="/users/lock/%s" title="%s"> <img src="/images/16x16/unlocked.png" alt="%s"/></a> </td> ''' % (login, _("Lock password (revoke access to machines)."), _("Lock account.")) html_data += ''' <td class="user_action"> <a href="/users/skel/%s" title="%s" class="reapply-skel"><span class="delete-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span></a> </td> <td class="user_action"> <a href="/users/delete/%s" title="%s" class="delete-entry"><span class="delete-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span></a> </td> </tr> ''' % (login, _("""Reapply origin skel data in the personnal directory of user. This is usefull when user has lost icons, or modified too much his/her desktop (menus, panels and so on). This will get all his/her desktop back."""), login, _("Definitely remove account from the system.")) return html_data users.Select(users.FILTER_STANDARD) for uid in users.filtered_users: user = u[uid] login = user['login'] # we add the login to gecosValue and lockedValue to be sure to obtain # unique values. This prevents problems with empty or non-unique GECOS # and when sorting on locked status (accounts would be overwritten and # lost because sorting must be done on unique values). accounts[uid] = { 'login' : login, 'gecos' : "%s %s" % ( user['gecos'], login ), 'locked' : "%s %s" % ( str(user['locked']), login ) } try: p = prof[user['gid']]['name'] except KeyError: p = _("Standard account") accounts[uid]['profile'] = "%s %s" % ( p, login ) accounts[uid]['profile_name'] = p totals[p] += 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(accounts[uid][sort])] = uid memberkeys = ordered.keys() memberkeys.sort() if order == "desc": memberkeys.reverse() data += ''.join(map(html_build_compact, memberkeys)) def print_totals(totals): output = "" for total in totals: if totals[total] != 0: output += ''' <tr class="list_total"> <td colspan="3" class="total_left">%s</td> <td colspan="3" 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="3" class="total_left">%s</td> <td colspan="3" class="total_right">%d</td> </tr>
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def main(uri, http_user, sort = "login", order = "asc"): start = time.time() groups.reload() users.reload() # TODO: profiles.reload() u = users.users g = groups.groups p = profiles.profiles groups.Select(groups.FILTER_PRIVILEGED) pri_grps = [ g[gid]['name'] for gid in groups.filtered_groups ] groups.Select(groups.FILTER_RESPONSIBLE) rsp_grps = [ g[gid]['name'] for gid in groups.filtered_groups ] groups.Select(groups.FILTER_GUEST) gst_grps = [ g[gid]['name'] for gid in groups.filtered_groups ] groups.Select(groups.FILTER_STANDARD) std_grps = [ g[gid]['name'] for gid in groups.filtered_groups ] accounts = {} ordered = {} totals = {} prof = {} for profile in p: prof[groups.name_to_gid(profile)] = p[profile] totals[p[profile]['name']] = 0 totals[_('Standard account')] = 0 title = _("User accounts") data = w.page_body_start(uri, http_user, ctxtnav, title) if order == "asc": reverseorder = "desc" else: reverseorder = "asc" data += '<table>\n <tr>\n' for (sortcolumn, sortname) in ( ("gecos", _("Full name")), ("login", _("Identifier")), ("profile", _("Profile")), ("locked", _("Locked")) ): if sortcolumn == sort: data += ''' <th><img src="/images/sort_%s.gif" alt="%s order image" />&#160; <a href="/users/list/%s/%s" title="%s">%s</a> </th>\n''' % (order, order, sortcolumn, reverseorder, _("Click to sort in reverse order."), sortname) else: data += ' <th><a href="/users/list/%s/asc" title="%s">%s</a></th>\n' % (sortcolumn, _("Click to sort on this column."), sortname) data += ' </tr>\n' def html_build_compact(index, accounts = accounts): uid = ordered[index] login = u[uid]['login'] edit = (_("""<em>Click to edit current user account parameters:</em><br /> UID: <strong>%d</strong><br /> GID: %d (primary group <strong>%s</strong>)<br /><br /> Groups:&#160;<strong>%s</strong><br /><br /> Privileges:&#160;<strong>%s</strong><br /><br /> Responsabilities:&#160;<strong>%s</strong><br /><br /> Invitations:&#160;<strong>%s</strong><br /><br /> """) % ( uid, u[uid]['gid'], g[u[uid]['gid']]['name'], ", ".join(filter(lambda x: x in std_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in pri_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in rsp_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in gst_grps, u[uid]['groups'])))).replace('<','&lt;').replace('>','&gt;') html_data = ''' <tr class="userdata"> <td class="paddedleft"> <a href="/users/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td class="paddedright"> <a href="/users/edit/%s" title="%s" class="edit-entry">%s</a> </td> <td style="text-align:center;">%s</td> ''' % (login, edit, u[uid]['gecos'], login, edit, login, accounts[uid]['profile_name']) if u[uid]['locked']: html_data += ''' <td class="user_action_center"> <a href="/users/unlock/%s" title="%s"> <img src="/images/16x16/locked.png" alt="%s"/></a> </td> ''' % (login, _("Unlock password (re-grant access to machines)."), _("Remove account.")) else: html_data += ''' <td class="user_action_center"> <a href="/users/lock/%s" title="%s"> <img src="/images/16x16/unlocked.png" alt="%s"/></a> </td> ''' % (login, _("Lock password (revoke access to machines)."), _("Lock account.")) html_data += ''' <td class="user_action"> <a href="/users/skel/%s" title="%s" class="reapply-skel"><span class="delete-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span></a> </td> <td class="user_action"> <a href="/users/delete/%s" title="%s" class="delete-entry"><span class="delete-entry">&nbsp;&nbsp;&nbsp;&nbsp;</span></a> </td> </tr> ''' % (login, _("""Reapply origin skel data in the personnal directory of user. This is usefull when user has lost icons, or modified too much his/her desktop (menus, panels and so on). This will get all his/her desktop back."""), login, _("Definitely remove account from the system.")) return html_data users.Select(users.FILTER_STANDARD) for uid in users.filtered_users: user = u[uid] login = user['login'] # we add the login to gecosValue and lockedValue to be sure to obtain # unique values. This prevents problems with empty or non-unique GECOS # and when sorting on locked status (accounts would be overwritten and # lost because sorting must be done on unique values). accounts[uid] = { 'login' : login, 'gecos' : "%s %s" % ( user['gecos'], login ), 'locked' : "%s %s" % ( str(user['locked']), login ) } try: p = prof[user['gid']]['name'] except KeyError: p = _("Standard account") accounts[uid]['profile'] = "%s %s" % ( p, login ) accounts[uid]['profile_name'] = p totals[p] += 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(accounts[uid][sort])] = uid memberkeys = ordered.keys() memberkeys.sort() if order == "desc": memberkeys.reverse() data += ''.join(map(html_build_compact, memberkeys)) def print_totals(totals): output = "" for total in totals: if totals[total] != 0: output += ''' <tr class="list_total"> <td colspan="3" class="total_left">%s</td> <td colspan="3" 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="3" class="total_left">%s</td> <td colspan="3" class="total_right">%d</td> </tr>
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
login, edit, login,
login, edit, login,
def html_build_compact(index, accounts = accounts): uid = ordered[index] login = u[uid]['login'] edit = (_("""<em>Click to edit current user account parameters:</em><br /> UID: <strong>%d</strong><br /> GID: %d (primary group <strong>%s</strong>)<br /><br /> Groups:&#160;<strong>%s</strong><br /><br /> Privileges:&#160;<strong>%s</strong><br /><br /> Responsabilities:&#160;<strong>%s</strong><br /><br /> Invitations:&#160;<strong>%s</strong><br /><br /> """) % ( uid, u[uid]['gid'], g[u[uid]['gid']]['name'], ", ".join(filter(lambda x: x in std_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in pri_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in rsp_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in gst_grps, u[uid]['groups'])))).replace('<','&lt;').replace('>','&gt;')
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
when user has lost icons, or modified too much his/her desktop (menus, panels and so on).
when user has lost icons, or modified too much his/her desktop (menus, panels and so on).
def html_build_compact(index, accounts = accounts): uid = ordered[index] login = u[uid]['login'] edit = (_("""<em>Click to edit current user account parameters:</em><br /> UID: <strong>%d</strong><br /> GID: %d (primary group <strong>%s</strong>)<br /><br /> Groups:&#160;<strong>%s</strong><br /><br /> Privileges:&#160;<strong>%s</strong><br /><br /> Responsabilities:&#160;<strong>%s</strong><br /><br /> Invitations:&#160;<strong>%s</strong><br /><br /> """) % ( uid, u[uid]['gid'], g[u[uid]['gid']]['name'], ", ".join(filter(lambda x: x in std_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in pri_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in rsp_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in gst_grps, u[uid]['groups'])))).replace('<','&lt;').replace('>','&gt;')
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def html_build_compact(index, accounts = accounts): uid = ordered[index] login = u[uid]['login'] edit = (_("""<em>Click to edit current user account parameters:</em><br /> UID: <strong>%d</strong><br /> GID: %d (primary group <strong>%s</strong>)<br /><br /> Groups:&#160;<strong>%s</strong><br /><br /> Privileges:&#160;<strong>%s</strong><br /><br /> Responsabilities:&#160;<strong>%s</strong><br /><br /> Invitations:&#160;<strong>%s</strong><br /><br /> """) % ( uid, u[uid]['gid'], g[u[uid]['gid']]['name'], ", ".join(filter(lambda x: x in std_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in pri_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in rsp_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in gst_grps, u[uid]['groups'])))).replace('<','&lt;').replace('>','&gt;')
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
login = user['login']
login = user['login']
def html_build_compact(index, accounts = accounts): uid = ordered[index] login = u[uid]['login'] edit = (_("""<em>Click to edit current user account parameters:</em><br /> UID: <strong>%d</strong><br /> GID: %d (primary group <strong>%s</strong>)<br /><br /> Groups:&#160;<strong>%s</strong><br /><br /> Privileges:&#160;<strong>%s</strong><br /><br /> Responsabilities:&#160;<strong>%s</strong><br /><br /> Invitations:&#160;<strong>%s</strong><br /><br /> """) % ( uid, u[uid]['gid'], g[u[uid]['gid']]['name'], ", ".join(filter(lambda x: x in std_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in pri_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in rsp_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in gst_grps, u[uid]['groups'])))).replace('<','&lt;').replace('>','&gt;')
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def html_build_compact(index, accounts = accounts): uid = ordered[index] login = u[uid]['login'] edit = (_("""<em>Click to edit current user account parameters:</em><br /> UID: <strong>%d</strong><br /> GID: %d (primary group <strong>%s</strong>)<br /><br /> Groups:&#160;<strong>%s</strong><br /><br /> Privileges:&#160;<strong>%s</strong><br /><br /> Responsabilities:&#160;<strong>%s</strong><br /><br /> Invitations:&#160;<strong>%s</strong><br /><br /> """) % ( uid, u[uid]['gid'], g[u[uid]['gid']]['name'], ", ".join(filter(lambda x: x in std_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in pri_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in rsp_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in gst_grps, u[uid]['groups'])))).replace('<','&lt;').replace('>','&gt;')
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
def html_build_compact(index, accounts = accounts): uid = ordered[index] login = u[uid]['login'] edit = (_("""<em>Click to edit current user account parameters:</em><br /> UID: <strong>%d</strong><br /> GID: %d (primary group <strong>%s</strong>)<br /><br /> Groups:&#160;<strong>%s</strong><br /><br /> Privileges:&#160;<strong>%s</strong><br /><br /> Responsabilities:&#160;<strong>%s</strong><br /><br /> Invitations:&#160;<strong>%s</strong><br /><br /> """) % ( uid, u[uid]['gid'], g[u[uid]['gid']]['name'], ", ".join(filter(lambda x: x in std_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in pri_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in rsp_grps, u[uid]['groups'])), ", ".join(filter(lambda x: x in gst_grps, u[uid]['groups'])))).replace('<','&lt;').replace('>','&gt;')
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
''' % (print_totals(totals), _("<strong>Total number of accounts:</strong>"),
''' % (print_totals(totals), _("<strong>Total number of accounts:</strong>"),
def print_totals(totals): output = "" for total in totals: if totals[total] != 0: output += '''
1ac7de7fa0474fe0812c899f93a87f4be2a8eadb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/1ac7de7fa0474fe0812c899f93a87f4be2a8eadb/users.py
'''command "%s" failed (retcode %d instead of %d).\n'''
'''command "%s" failed (retcode %s instead of %s).\n'''
def RunAndCheck(self, cmd, batch = False, inverse_test=False): ref_output, ref_code = self.PrepareReferenceOutput(cmd)
11c2b6b6f98781896ba8bed27998ea4bdd46dd93 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/11c2b6b6f98781896ba8bed27998ea4bdd46dd93/core.py
ProfilesController.configuration.users.base_path,
def ExportCLI(self): """ Export the user profiles list to human readable form. """ data = ""
05b33e0a707a748843b535af7ccbcba280a9447c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/05b33e0a707a748843b535af7ccbcba280a9447c/profiles.py
and gid > LMC.configuration.groups.gid_max
or gid > LMC.configuration.groups.gid_max
def is_restricted_system_gid(self, gid): """ Return true if gid is system, but outside the range of Licorn® controlled GIDs.""" return gid < LMC.configuration.groups.system_gid_min \ and gid > LMC.configuration.groups.gid_max
7eec532cdc560cadf103bebae014cc1914d2cc08 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/7eec532cdc560cadf103bebae014cc1914d2cc08/groups.py
command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, '--apply-skel', skel ]
command = [ "sudo", "mod", "user", "--quiet", "--no-colors", "--login", login, '--apply-skel', apply_skel ]
def filter_skels(pri_group, sk_list): ''' TODO: to be converted to licorn model if pri_group == configuration.mNames['RESPONSABLES_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['RESPONSABLES_GROUP']) != -1, sk_list) elif pri_group == configuration.mNames['USAGERS_GROUP']: return filter(lambda x: x.rfind("/%s/" % configuration.mNames['USAGERS_GROUP']) != -1, sk_list) else: ''' return sk_list
b1c965e2c6d0e0f8c814177d2f5c4d4dc29a16c2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/b1c965e2c6d0e0f8c814177d2f5c4d4dc29a16c2/users.py
return styles.stylize(styles.ST_NAME, ' '.join(cmd))
return stylize(ST_NAME, ' '.join(cmd))
def cmdfmt(cmd): '''convert a sequence to a colorized string.''' return styles.stylize(styles.ST_NAME, ' '.join(cmd))
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
% (styles.colors[styles.ST_LOG], msg, styles.colors[styles.ST_NO]) )
% (colors[ST_LOG], msg, colors[ST_NO]) )
def test_message(msg): """ display a message to stderr. """ sys.stderr.write("%s>>> %s%s\n" % (styles.colors[styles.ST_LOG], msg, styles.colors[styles.ST_NO]) )
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
sys.stderr.write("%s>>> running %s%s%s\n" % (styles.colors[styles.ST_LOG], styles.colors[styles.ST_PATH], command, styles.colors[styles.ST_NO]))
sys.stderr.write("%s>>> running %s%s%s\n" % (colors[ST_LOG], colors[ST_PATH], command, colors[ST_NO]))
def log_and_exec (command, inverse_test=False, result_code=0, comment="", verb=verbose): """Display a command, execute it, and exit if soemthing went wrong.""" #if not command.startswith('colordiff'): # command += ' %s' % ' '.join(args) sys.stderr.write("%s>>> running %s%s%s\n" % (styles.colors[styles.ST_LOG], styles.colors[styles.ST_PATH], command, styles.colors[styles.ST_NO])) output, retcode = execute(command) must_exit = False # # TODO: implement a precise test on a precise exit value. # for example, when you try to add a group with an invalid name, # licorn-add should exit (e.g.) 34. We must test on this precise # value and not on != 0, because if something wrong but *other* than # errno 34 happened, we won't know it if we don't check carefully the # program output. # if inverse_test: if retcode != result_code: must_exit = True else: if retcode != 0: must_exit = True if must_exit: if inverse_test: test = (" %s→ it should have failed with reason: %s%s%s\n" % (styles.colors[styles.ST_PATH], styles.colors[styles.ST_BAD], comment, styles.colors[styles.ST_NO])) else: test = "" sys.stderr.write(" %s→ return code of command: %s%d%s (expected: %d)%s\n%s → log follows:\n" % ( styles.colors[styles.ST_LOG], styles.colors[styles.ST_BAD], retcode, styles.colors[styles.ST_LOG], result_code, styles.colors[styles.ST_NO], test) ) sys.stderr.write(output) sys.stderr.write( "The last command failed to execute, or return something wrong !\n") raise SystemExit(retcode) if verb: sys.stderr.write(output)
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
% (styles.colors[styles.ST_PATH], styles.colors[styles.ST_BAD], comment, styles.colors[styles.ST_NO]))
% (colors[ST_PATH], colors[ST_BAD], comment, colors[ST_NO]))
def log_and_exec (command, inverse_test=False, result_code=0, comment="", verb=verbose): """Display a command, execute it, and exit if soemthing went wrong.""" #if not command.startswith('colordiff'): # command += ' %s' % ' '.join(args) sys.stderr.write("%s>>> running %s%s%s\n" % (styles.colors[styles.ST_LOG], styles.colors[styles.ST_PATH], command, styles.colors[styles.ST_NO])) output, retcode = execute(command) must_exit = False # # TODO: implement a precise test on a precise exit value. # for example, when you try to add a group with an invalid name, # licorn-add should exit (e.g.) 34. We must test on this precise # value and not on != 0, because if something wrong but *other* than # errno 34 happened, we won't know it if we don't check carefully the # program output. # if inverse_test: if retcode != result_code: must_exit = True else: if retcode != 0: must_exit = True if must_exit: if inverse_test: test = (" %s→ it should have failed with reason: %s%s%s\n" % (styles.colors[styles.ST_PATH], styles.colors[styles.ST_BAD], comment, styles.colors[styles.ST_NO])) else: test = "" sys.stderr.write(" %s→ return code of command: %s%d%s (expected: %d)%s\n%s → log follows:\n" % ( styles.colors[styles.ST_LOG], styles.colors[styles.ST_BAD], retcode, styles.colors[styles.ST_LOG], result_code, styles.colors[styles.ST_NO], test) ) sys.stderr.write(output) sys.stderr.write( "The last command failed to execute, or return something wrong !\n") raise SystemExit(retcode) if verb: sys.stderr.write(output)
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
% ( styles.colors[styles.ST_LOG], styles.colors[styles.ST_BAD], retcode, styles.colors[styles.ST_LOG], result_code, styles.colors[styles.ST_NO], test) )
% ( colors[ST_LOG], colors[ST_BAD], retcode, colors[ST_LOG], result_code, colors[ST_NO], test) )
def log_and_exec (command, inverse_test=False, result_code=0, comment="", verb=verbose): """Display a command, execute it, and exit if soemthing went wrong.""" #if not command.startswith('colordiff'): # command += ' %s' % ' '.join(args) sys.stderr.write("%s>>> running %s%s%s\n" % (styles.colors[styles.ST_LOG], styles.colors[styles.ST_PATH], command, styles.colors[styles.ST_NO])) output, retcode = execute(command) must_exit = False # # TODO: implement a precise test on a precise exit value. # for example, when you try to add a group with an invalid name, # licorn-add should exit (e.g.) 34. We must test on this precise # value and not on != 0, because if something wrong but *other* than # errno 34 happened, we won't know it if we don't check carefully the # program output. # if inverse_test: if retcode != result_code: must_exit = True else: if retcode != 0: must_exit = True if must_exit: if inverse_test: test = (" %s→ it should have failed with reason: %s%s%s\n" % (styles.colors[styles.ST_PATH], styles.colors[styles.ST_BAD], comment, styles.colors[styles.ST_NO])) else: test = "" sys.stderr.write(" %s→ return code of command: %s%d%s (expected: %d)%s\n%s → log follows:\n" % ( styles.colors[styles.ST_LOG], styles.colors[styles.ST_BAD], retcode, styles.colors[styles.ST_LOG], result_code, styles.colors[styles.ST_NO], test) ) sys.stderr.write(output) sys.stderr.write( "The last command failed to execute, or return something wrong !\n") raise SystemExit(retcode) if verb: sys.stderr.write(output)
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
return re.sub(r'\s\[\d\d\d\d/\d\d/\d\d\s\d\d:\d\d:\d\d\.\d\d\d\d\]\s',
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)',
def strip_dates(str): """ strip dates from warnings and traces, else outputs and references always compare false .""" return re.sub(r'\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)
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
class FunctionnalTest:
def save_state(num, state_type='scenarii'): open(state_files[state_type],'w').write('%d' % num) def get_state(state_type='scenarii'): if os.path.exists(state_files[state_type]): return int(open(state_files[state_type]).read()) else: return 0 class ScenarioTest:
def strip_dates(str): """ strip dates from warnings and traces, else outputs and references always compare false .""" return re.sub(r'\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)
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
def __init__(self, cmd, pre_cmds=[], chk_cmds=[], manual_output=False, reference_cmd=[], context='std'): if type(cmd) == type(''): self.cmd = cmd.split(' ') else: self.cmd = cmd self.pre_cmds = pre_cmds self.chk_cmds = chk_cmds self.reference_cmd = reference_cmd self.context = context self.manual_output = manual_output FunctionnalTest.counter += 1 def Prepare(self, cmd): """ Run commands mandatory for func_test to succeed. """ make_path = lambda x: ('_'.join(x)).replace( '../', '').replace('./', '').replace('//','_').replace( '/','_').replace('>','_').replace('&', '_').replace( '`', '_').replace('\\','_').replace("'",'_').replace( '|','_').replace('^','_').replace('%', '_').replace( '(', '_').replace(')', '_').replace ('*', '_').replace( ' ', '_').replace('__', '_') out_path = 'data/' if self.reference_cmd != []: out_path += 'ref_%s/' % make_path(self.reference_cmd) if self.pre_cmds != []: logging.progress('preparing system for cmd %s.' % cmd) for pre_cmd in self.pre_cmds: out_path += 'pre_%s/' % make_path(pre_cmd) execute(pre_cmd) out_path += 'cmd_%s/context_%s' % (make_path(cmd), self.context) self.ref_output_file = '%s/out.txt' % out_path self.ref_code_file = '%s/code.txt' % out_path def SaveOutput(self, output, code):
def __init__(self, cmds, context='std', descr=None): self.context = context self.sce_number = ScenarioTest.counter self.cmd_counter = 0 self.name = '%s%s%s%s%s' % ( stylize(ST_NAME, 'Scenario stylize(ST_OK, ScenarioTest.counter), stylize(ST_NAME, ' (%s)' % descr) if descr else '', stylize(ST_NAME, ', context '), stylize(ST_OK, self.context)) ScenarioTest.counter += 1 self.cmds = {} for cmd in cmds: self.cmds[self.cmd_counter] = cmd self.cmd_counter += 1 self.hash = hashlib.sha1(self.name).hexdigest() self.base_path = 'data/scenarii/%s' % self.hash def SaveOutput(self, cmdnum, output, code):
def __init__(self, cmd, pre_cmds=[], chk_cmds=[], manual_output=False, reference_cmd=[], context='std'):
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
os.makedirs(os.path.dirname(self.ref_output_file))
os.makedirs('%s/%s' % (self.base_path, cmdnum))
def SaveOutput(self, output, code):
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
open(self.ref_output_file, 'w').write(strip_dates(output)) open(self.ref_code_file, 'w').write(str(code)) def PrepareReferenceOutput(self, cmd): if os.path.exists(self.ref_output_file): return (open(self.ref_output_file).read(), int(open(self.ref_code_file).read()))
open('%s/%s/cmdline.txt' % (self.base_path, cmdnum), 'w').write( ' '.join(self.cmds[cmdnum])) open('%s/%s/out.txt' % (self.base_path, cmdnum), 'w').write( strip_dates(output)) open('%s/%s/code.txt' % (self.base_path, cmdnum), 'w').write(str(code)) def RunCommand(self, cmdnum, batch=False): if os.path.exists('%s/%s' % (self.base_path, cmdnum)): ref_output = open('%s/%s/out.txt' % (self.base_path, cmdnum)).read() ref_code = int(open( '%s/%s/code.txt' % (self.base_path, cmdnum)).read()) output, retcode = execute(self.cmds[cmdnum]) output = strip_dates(output) if retcode != ref_code or ref_output != output: handle, tmpfilename = tempfile.mkstemp( prefix=clean_path_name(self.cmds[cmdnum])) open(tmpfilename, 'w').write(output) diff_output = process.execute(['colordiff', '-u', '%s/%s/out.txt' % (self.base_path, cmdnum), tmpfilename])[0] logging.warning( '''command '''Diffed output follows:\n%s\n%s''' % ( stylize(ST_OK, cmdnum), stylize(ST_BAD, retcode), stylize(ST_OK, ref_code), stylize(ST_NAME, cmdfmt(self.cmds[cmdnum])), '-' * 50, diff_output, '-' * 50)) if batch or logging.ask_for_repair('''Should I keep the new ''' '''return code and trace as reference for future runs?'''): self.SaveOutput(cmdnum, output, retcode) else: raise exceptions.LicornRuntimeException( 'command "%s" failed.\nPath: %s.' % ( cmdfmt(self.cmds[cmdnum]), '%s/%s/*' % ( self.base_path, cmdnum))) else: logging.notice('command cmdnum, cmdfmt(self.cmds[cmdnum])))
def SaveOutput(self, output, code):
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
logging.notice('no reference output for cmd FunctionnalTest.counter, cmdfmt(cmd), 'referer=%s, ' % cmdfmt(self.reference_cmd) \ if self.reference_cmd != [] else '', self.context)) output, retcode = execute(cmd)
logging.notice('''no reference output for %s, cmd ''' creating one…''' % (self.name, stylize(ST_OK, cmdnum), cmdfmt(self.cmds[cmdnum]))) output, retcode = execute(self.cmds[cmdnum])
def PrepareReferenceOutput(self, cmd):
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
if logging.ask_for_repair('is this output good to keep as reference for future runs?'): self.SaveOutput(output, retcode)
if logging.ask_for_repair('''is this output good to keep as ''' '''reference for future runs?'''): self.SaveOutput(cmdnum, output, retcode)
def PrepareReferenceOutput(self, cmd):
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
logging.error('you MUST have a reference output; please fix code or rerun this test.') def RunAndCheck(self, cmd, batch = False, inverse_test=False): ref_output, ref_code = self.PrepareReferenceOutput(cmd) output, retcode = execute(cmd) bad_run = False message = '' if retcode != ref_code: logging.warning( '''command "%s" failed (retcode %s instead of %s).\n''' '''(Reference path: %s)''' % ( styles.stylize(styles.ST_NAME, cmdfmt(cmd)), styles.stylize(styles.ST_BAD,retcode), styles.stylize(styles.ST_OK, ref_code), self.ref_code_file)) if batch or logging.ask_for_repair( 'Should I keep the new return code as reference for future runs?'): self.SaveOutput(output, retcode) else: raise exceptions.LicornRuntimeException( 'command "%s" failed.\nPath: %s.' % (cmdfmt(cmd), self.ref_output_file)) if ref_output != strip_dates(output): logging.warning('command "%s" failed.\nPath: %s.\n%s New output follows:' % ( cmdfmt(cmd), self.ref_output_file, '-' * 50)) sys.stdout.write(strip_dates(output) + ('-' * 50) + '\n') if batch or logging.ask_for_repair( 'Should I keep this new trace as reference for future runs?'): self.SaveOutput(output, retcode) else: raise exceptions.LicornRuntimeException( 'command "%s" failed.\nPath: %s.' % (cmdfmt(cmd), self.ref_output_file)) logging.notice('command FunctionnalTest.counter, cmdfmt(cmd), 'referer=%s, ' % cmdfmt(self.reference_cmd) \ if self.reference_cmd != [] else '', self.context, retcode)) def Run(self, options=[], batch=False, inverse_test=False): if self.manual_output: if batch: logging.warning('batch mode, cmd "%s" not tested !' % \ cmdfmt(self.cmd)) else: clear_term() test_message('running FunctionnalTest.counter, cmdfmt(self.cmd))) sys.stderr.write(execute(self.cmd)[0]) return logging.ask_for_repair( 'does this output seems right to you for this command?') else: self.Prepare(self.cmd) self.RunAndCheck(self.cmd, batch=batch, inverse_test=inverse_test) for chk_cmd in self.chk_cmds: FunctionnalTest(chk_cmd, reference_cmd=self.cmd).Run() for option in options: FunctionnalTest.counter += 1 self.Prepare(self.cmd + option) self.RunAndCheck(self.cmd + option, batch=batch, inverse_test=inverse_test) for chk_cmd in self.chk_cmds: FunctionnalTest(chk_cmd, reference_cmd=self.cmd).Run() def test_integrated_help ():
logging.error('''you MUST have a reference output; please ''' '''fix code or rerun this test.''') def Run(self, options=[], batch=False, inverse_test=False, ): """ run each command of the scenario, in turn. """ start_scenario = get_state() if self.sce_number < start_scenario: logging.notice('Skipping %s' % stylize(ST_NAME, self.name)) return logging.notice('Running %s' % stylize(ST_NAME, self.name)) for cmdnum in self.cmds: self.RunCommand(cmdnum) save_state(self.sce_number+1) logging.notice('End run %s' % stylize(ST_NAME, self.name)) @staticmethod def reinit(): ScenarioTest.counter = 0 save_state(0) def test_integrated_help():
def PrepareReferenceOutput(self, cmd):
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
test_message('testing integrated help.') for program in (GETENT, ADD, MODIFY, DELETE, CHECK): FunctionnalTest(program).Run(options = [['-h'], ['--help']])
commands = [] for program in (GET, ADD, MOD, DEL, CHK): commands.extend([ program + ['-h'], program + ['--help']])
def test_integrated_help (): """Test extensively argmarser contents and intergated help.""" test_message('testing integrated help.') for program in (GETENT, ADD, MODIFY, DELETE, CHECK): FunctionnalTest(program).Run(options = [['-h'], ['--help']]) if program == ADD: modes = [ 'user', 'users', 'group', 'profile' ] elif program == MODIFY: modes = [ 'configuration', 'user', 'group', 'profile' ] elif program == DELETE: modes = [ 'user', 'group', 'groups', 'profile' ] elif program == GETENT: modes = ['user', 'users', 'passwd', 'group', 'groups', 'profiles', 'configuration' ] elif program == CHECK: modes = ['user', 'users', 'group', 'groups', 'profile', 'profiles', 'configuration' ] for mode in modes: if program == GETENT and mode == 'configuration': FunctionnalTest(program + [mode]).Run() else: FunctionnalTest(program + [mode]).Run(options = [['-h'], ['--help']]) test_message('integrated help testing finished.')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
elif program == MODIFY:
elif program == MOD:
def test_integrated_help (): """Test extensively argmarser contents and intergated help.""" test_message('testing integrated help.') for program in (GETENT, ADD, MODIFY, DELETE, CHECK): FunctionnalTest(program).Run(options = [['-h'], ['--help']]) if program == ADD: modes = [ 'user', 'users', 'group', 'profile' ] elif program == MODIFY: modes = [ 'configuration', 'user', 'group', 'profile' ] elif program == DELETE: modes = [ 'user', 'group', 'groups', 'profile' ] elif program == GETENT: modes = ['user', 'users', 'passwd', 'group', 'groups', 'profiles', 'configuration' ] elif program == CHECK: modes = ['user', 'users', 'group', 'groups', 'profile', 'profiles', 'configuration' ] for mode in modes: if program == GETENT and mode == 'configuration': FunctionnalTest(program + [mode]).Run() else: FunctionnalTest(program + [mode]).Run(options = [['-h'], ['--help']]) test_message('integrated help testing finished.')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
elif program == DELETE:
elif program == DEL:
def test_integrated_help (): """Test extensively argmarser contents and intergated help.""" test_message('testing integrated help.') for program in (GETENT, ADD, MODIFY, DELETE, CHECK): FunctionnalTest(program).Run(options = [['-h'], ['--help']]) if program == ADD: modes = [ 'user', 'users', 'group', 'profile' ] elif program == MODIFY: modes = [ 'configuration', 'user', 'group', 'profile' ] elif program == DELETE: modes = [ 'user', 'group', 'groups', 'profile' ] elif program == GETENT: modes = ['user', 'users', 'passwd', 'group', 'groups', 'profiles', 'configuration' ] elif program == CHECK: modes = ['user', 'users', 'group', 'groups', 'profile', 'profiles', 'configuration' ] for mode in modes: if program == GETENT and mode == 'configuration': FunctionnalTest(program + [mode]).Run() else: FunctionnalTest(program + [mode]).Run(options = [['-h'], ['--help']]) test_message('integrated help testing finished.')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
elif program == GETENT:
elif program == GET:
def test_integrated_help (): """Test extensively argmarser contents and intergated help.""" test_message('testing integrated help.') for program in (GETENT, ADD, MODIFY, DELETE, CHECK): FunctionnalTest(program).Run(options = [['-h'], ['--help']]) if program == ADD: modes = [ 'user', 'users', 'group', 'profile' ] elif program == MODIFY: modes = [ 'configuration', 'user', 'group', 'profile' ] elif program == DELETE: modes = [ 'user', 'group', 'groups', 'profile' ] elif program == GETENT: modes = ['user', 'users', 'passwd', 'group', 'groups', 'profiles', 'configuration' ] elif program == CHECK: modes = ['user', 'users', 'group', 'groups', 'profile', 'profiles', 'configuration' ] for mode in modes: if program == GETENT and mode == 'configuration': FunctionnalTest(program + [mode]).Run() else: FunctionnalTest(program + [mode]).Run(options = [['-h'], ['--help']]) test_message('integrated help testing finished.')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
elif program == CHECK:
elif program == CHK:
def test_integrated_help (): """Test extensively argmarser contents and intergated help.""" test_message('testing integrated help.') for program in (GETENT, ADD, MODIFY, DELETE, CHECK): FunctionnalTest(program).Run(options = [['-h'], ['--help']]) if program == ADD: modes = [ 'user', 'users', 'group', 'profile' ] elif program == MODIFY: modes = [ 'configuration', 'user', 'group', 'profile' ] elif program == DELETE: modes = [ 'user', 'group', 'groups', 'profile' ] elif program == GETENT: modes = ['user', 'users', 'passwd', 'group', 'groups', 'profiles', 'configuration' ] elif program == CHECK: modes = ['user', 'users', 'group', 'groups', 'profile', 'profiles', 'configuration' ] for mode in modes: if program == GETENT and mode == 'configuration': FunctionnalTest(program + [mode]).Run() else: FunctionnalTest(program + [mode]).Run(options = [['-h'], ['--help']]) test_message('integrated help testing finished.')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
if program == GETENT and mode == 'configuration': FunctionnalTest(program + [mode]).Run()
if program == GET and mode == 'configuration': commands.append(program + [ mode ])
def test_integrated_help (): """Test extensively argmarser contents and intergated help.""" test_message('testing integrated help.') for program in (GETENT, ADD, MODIFY, DELETE, CHECK): FunctionnalTest(program).Run(options = [['-h'], ['--help']]) if program == ADD: modes = [ 'user', 'users', 'group', 'profile' ] elif program == MODIFY: modes = [ 'configuration', 'user', 'group', 'profile' ] elif program == DELETE: modes = [ 'user', 'group', 'groups', 'profile' ] elif program == GETENT: modes = ['user', 'users', 'passwd', 'group', 'groups', 'profiles', 'configuration' ] elif program == CHECK: modes = ['user', 'users', 'group', 'groups', 'profile', 'profiles', 'configuration' ] for mode in modes: if program == GETENT and mode == 'configuration': FunctionnalTest(program + [mode]).Run() else: FunctionnalTest(program + [mode]).Run(options = [['-h'], ['--help']]) test_message('integrated help testing finished.')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
FunctionnalTest(program + [mode]).Run(options = [['-h'], ['--help']]) test_message('integrated help testing finished.')
commands.extend([ program + [ mode, '-h'], program + [ mode, '--help'] ]) ScenarioTest(commands, descr="integrated help").Run()
def test_integrated_help (): """Test extensively argmarser contents and intergated help.""" test_message('testing integrated help.') for program in (GETENT, ADD, MODIFY, DELETE, CHECK): FunctionnalTest(program).Run(options = [['-h'], ['--help']]) if program == ADD: modes = [ 'user', 'users', 'group', 'profile' ] elif program == MODIFY: modes = [ 'configuration', 'user', 'group', 'profile' ] elif program == DELETE: modes = [ 'user', 'group', 'groups', 'profile' ] elif program == GETENT: modes = ['user', 'users', 'passwd', 'group', 'groups', 'profiles', 'configuration' ] elif program == CHECK: modes = ['user', 'users', 'group', 'groups', 'profile', 'profiles', 'configuration' ] for mode in modes: if program == GETENT and mode == 'configuration': FunctionnalTest(program + [mode]).Run() else: FunctionnalTest(program + [mode]).Run(options = [['-h'], ['--help']]) test_message('integrated help testing finished.')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
test_message('''starting get tests.''')
commands = []
def test_get(context): """Test GET a lot.""" test_message('''starting get tests.''') for category in [ 'config_dir', 'main_config_file', 'extendedgroup_data_file' ]: for mode in [ '', '-s', '-b', '--bourne-shell', '-c', '--c-shell', '-p', '--php-code' ]: FunctionnalTest(GETENT + [ 'configuration', category, mode ], context=context).Run() for category in [ 'skels', 'shells', 'backends' ]: FunctionnalTest(GETENT + [ 'config', category ], context=context).Run() commands = ( # users GETENT + [ "users" ], GETENT + [ "users", "--xml" ], GETENT + [ "users", "--long" ], GETENT + [ "users", "--long", "--xml" ], GETENT + [ "users", "--all" ], GETENT + [ "users", "--xml", "--all" ], GETENT + [ "users", "--all", "--long" ], GETENT + [ "users", "--xml", "--all", "--long" ], # groups GETENT + [ "groups" ], GETENT + [ "groups", "--xml" ], GETENT + [ "groups", "--long" ], GETENT + [ "groups", "--long", "--xml" ], GETENT + [ "groups", "--xml", "--all" ], GETENT + [ "groups", "--xml", "--all", "--long" ], GETENT + [ "groups", "--xml", "--guests" ], GETENT + [ "groups", "--xml", "--guests", "--long " ], GETENT + [ "groups", "--xml", "--responsibles" ], GETENT + [ "groups", "--xml", "--responsibles", "--long" ], GETENT + [ "groups", "--xml", "--privileged" ], GETENT + [ "groups", "--xml", "--privileged", "--long" ], # Profiles GETENT + [ "profiles" ], GETENT + [ "profiles", "--xml" ], ) for command in commands: FunctionnalTest(command, context=context) test_message('''`get` tests finished.''')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
FunctionnalTest(GETENT + [ 'configuration', category, mode ], context=context).Run()
commands.append(GET + [ 'configuration', category, mode ])
def test_get(context): """Test GET a lot.""" test_message('''starting get tests.''') for category in [ 'config_dir', 'main_config_file', 'extendedgroup_data_file' ]: for mode in [ '', '-s', '-b', '--bourne-shell', '-c', '--c-shell', '-p', '--php-code' ]: FunctionnalTest(GETENT + [ 'configuration', category, mode ], context=context).Run() for category in [ 'skels', 'shells', 'backends' ]: FunctionnalTest(GETENT + [ 'config', category ], context=context).Run() commands = ( # users GETENT + [ "users" ], GETENT + [ "users", "--xml" ], GETENT + [ "users", "--long" ], GETENT + [ "users", "--long", "--xml" ], GETENT + [ "users", "--all" ], GETENT + [ "users", "--xml", "--all" ], GETENT + [ "users", "--all", "--long" ], GETENT + [ "users", "--xml", "--all", "--long" ], # groups GETENT + [ "groups" ], GETENT + [ "groups", "--xml" ], GETENT + [ "groups", "--long" ], GETENT + [ "groups", "--long", "--xml" ], GETENT + [ "groups", "--xml", "--all" ], GETENT + [ "groups", "--xml", "--all", "--long" ], GETENT + [ "groups", "--xml", "--guests" ], GETENT + [ "groups", "--xml", "--guests", "--long " ], GETENT + [ "groups", "--xml", "--responsibles" ], GETENT + [ "groups", "--xml", "--responsibles", "--long" ], GETENT + [ "groups", "--xml", "--privileged" ], GETENT + [ "groups", "--xml", "--privileged", "--long" ], # Profiles GETENT + [ "profiles" ], GETENT + [ "profiles", "--xml" ], ) for command in commands: FunctionnalTest(command, context=context) test_message('''`get` tests finished.''')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
FunctionnalTest(GETENT + [ 'config', category ], context=context).Run() commands = (
commands.append(GET + [ 'config', category ]) commands += [
def test_get(context): """Test GET a lot.""" test_message('''starting get tests.''') for category in [ 'config_dir', 'main_config_file', 'extendedgroup_data_file' ]: for mode in [ '', '-s', '-b', '--bourne-shell', '-c', '--c-shell', '-p', '--php-code' ]: FunctionnalTest(GETENT + [ 'configuration', category, mode ], context=context).Run() for category in [ 'skels', 'shells', 'backends' ]: FunctionnalTest(GETENT + [ 'config', category ], context=context).Run() commands = ( # users GETENT + [ "users" ], GETENT + [ "users", "--xml" ], GETENT + [ "users", "--long" ], GETENT + [ "users", "--long", "--xml" ], GETENT + [ "users", "--all" ], GETENT + [ "users", "--xml", "--all" ], GETENT + [ "users", "--all", "--long" ], GETENT + [ "users", "--xml", "--all", "--long" ], # groups GETENT + [ "groups" ], GETENT + [ "groups", "--xml" ], GETENT + [ "groups", "--long" ], GETENT + [ "groups", "--long", "--xml" ], GETENT + [ "groups", "--xml", "--all" ], GETENT + [ "groups", "--xml", "--all", "--long" ], GETENT + [ "groups", "--xml", "--guests" ], GETENT + [ "groups", "--xml", "--guests", "--long " ], GETENT + [ "groups", "--xml", "--responsibles" ], GETENT + [ "groups", "--xml", "--responsibles", "--long" ], GETENT + [ "groups", "--xml", "--privileged" ], GETENT + [ "groups", "--xml", "--privileged", "--long" ], # Profiles GETENT + [ "profiles" ], GETENT + [ "profiles", "--xml" ], ) for command in commands: FunctionnalTest(command, context=context) test_message('''`get` tests finished.''')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
GETENT + [ "users" ], GETENT + [ "users", "--xml" ], GETENT + [ "users", "--long" ], GETENT + [ "users", "--long", "--xml" ], GETENT + [ "users", "--all" ], GETENT + [ "users", "--xml", "--all" ], GETENT + [ "users", "--all", "--long" ], GETENT + [ "users", "--xml", "--all", "--long" ],
GET + [ "users" ], GET + [ "users", "--xml" ], GET + [ "users", "--long" ], GET + [ "users", "--long", "--xml" ], GET + [ "users", "--all" ], GET + [ "users", "--xml", "--all" ], GET + [ "users", "--all", "--long" ], GET + [ "users", "--xml", "--all", "--long" ],
def test_get(context): """Test GET a lot.""" test_message('''starting get tests.''') for category in [ 'config_dir', 'main_config_file', 'extendedgroup_data_file' ]: for mode in [ '', '-s', '-b', '--bourne-shell', '-c', '--c-shell', '-p', '--php-code' ]: FunctionnalTest(GETENT + [ 'configuration', category, mode ], context=context).Run() for category in [ 'skels', 'shells', 'backends' ]: FunctionnalTest(GETENT + [ 'config', category ], context=context).Run() commands = ( # users GETENT + [ "users" ], GETENT + [ "users", "--xml" ], GETENT + [ "users", "--long" ], GETENT + [ "users", "--long", "--xml" ], GETENT + [ "users", "--all" ], GETENT + [ "users", "--xml", "--all" ], GETENT + [ "users", "--all", "--long" ], GETENT + [ "users", "--xml", "--all", "--long" ], # groups GETENT + [ "groups" ], GETENT + [ "groups", "--xml" ], GETENT + [ "groups", "--long" ], GETENT + [ "groups", "--long", "--xml" ], GETENT + [ "groups", "--xml", "--all" ], GETENT + [ "groups", "--xml", "--all", "--long" ], GETENT + [ "groups", "--xml", "--guests" ], GETENT + [ "groups", "--xml", "--guests", "--long " ], GETENT + [ "groups", "--xml", "--responsibles" ], GETENT + [ "groups", "--xml", "--responsibles", "--long" ], GETENT + [ "groups", "--xml", "--privileged" ], GETENT + [ "groups", "--xml", "--privileged", "--long" ], # Profiles GETENT + [ "profiles" ], GETENT + [ "profiles", "--xml" ], ) for command in commands: FunctionnalTest(command, context=context) test_message('''`get` tests finished.''')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
GETENT + [ "groups" ], GETENT + [ "groups", "--xml" ], GETENT + [ "groups", "--long" ], GETENT + [ "groups", "--long", "--xml" ], GETENT + [ "groups", "--xml", "--all" ], GETENT + [ "groups", "--xml", "--all", "--long" ], GETENT + [ "groups", "--xml", "--guests" ], GETENT + [ "groups", "--xml", "--guests", "--long " ], GETENT + [ "groups", "--xml", "--responsibles" ], GETENT + [ "groups", "--xml", "--responsibles", "--long" ], GETENT + [ "groups", "--xml", "--privileged" ], GETENT + [ "groups", "--xml", "--privileged", "--long" ],
GET + [ "groups" ], GET + [ "groups", "--xml" ], GET + [ "groups", "--long" ], GET + [ "groups", "--long", "--xml" ], GET + [ "groups", "--xml", "--all" ], GET + [ "groups", "--xml", "--all", "--long" ], GET + [ "groups", "--xml", "--guests" ], GET + [ "groups", "--xml", "--guests", "--long" ], GET + [ "groups", "--xml", "--responsibles" ], GET + [ "groups", "--xml", "--responsibles", "--long" ], GET + [ "groups", "--xml", "--privileged" ], GET + [ "groups", "--xml", "--privileged", "--long" ],
def test_get(context): """Test GET a lot.""" test_message('''starting get tests.''') for category in [ 'config_dir', 'main_config_file', 'extendedgroup_data_file' ]: for mode in [ '', '-s', '-b', '--bourne-shell', '-c', '--c-shell', '-p', '--php-code' ]: FunctionnalTest(GETENT + [ 'configuration', category, mode ], context=context).Run() for category in [ 'skels', 'shells', 'backends' ]: FunctionnalTest(GETENT + [ 'config', category ], context=context).Run() commands = ( # users GETENT + [ "users" ], GETENT + [ "users", "--xml" ], GETENT + [ "users", "--long" ], GETENT + [ "users", "--long", "--xml" ], GETENT + [ "users", "--all" ], GETENT + [ "users", "--xml", "--all" ], GETENT + [ "users", "--all", "--long" ], GETENT + [ "users", "--xml", "--all", "--long" ], # groups GETENT + [ "groups" ], GETENT + [ "groups", "--xml" ], GETENT + [ "groups", "--long" ], GETENT + [ "groups", "--long", "--xml" ], GETENT + [ "groups", "--xml", "--all" ], GETENT + [ "groups", "--xml", "--all", "--long" ], GETENT + [ "groups", "--xml", "--guests" ], GETENT + [ "groups", "--xml", "--guests", "--long " ], GETENT + [ "groups", "--xml", "--responsibles" ], GETENT + [ "groups", "--xml", "--responsibles", "--long" ], GETENT + [ "groups", "--xml", "--privileged" ], GETENT + [ "groups", "--xml", "--privileged", "--long" ], # Profiles GETENT + [ "profiles" ], GETENT + [ "profiles", "--xml" ], ) for command in commands: FunctionnalTest(command, context=context) test_message('''`get` tests finished.''')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
GETENT + [ "profiles" ], GETENT + [ "profiles", "--xml" ], ) for command in commands: FunctionnalTest(command, context=context) test_message('''`get` tests finished.''')
GET + [ "profiles" ], GET + [ "profiles", "--xml" ], ] ScenarioTest(commands, context=context, descr="get tests").Run()
def test_get(context): """Test GET a lot.""" test_message('''starting get tests.''') for category in [ 'config_dir', 'main_config_file', 'extendedgroup_data_file' ]: for mode in [ '', '-s', '-b', '--bourne-shell', '-c', '--c-shell', '-p', '--php-code' ]: FunctionnalTest(GETENT + [ 'configuration', category, mode ], context=context).Run() for category in [ 'skels', 'shells', 'backends' ]: FunctionnalTest(GETENT + [ 'config', category ], context=context).Run() commands = ( # users GETENT + [ "users" ], GETENT + [ "users", "--xml" ], GETENT + [ "users", "--long" ], GETENT + [ "users", "--long", "--xml" ], GETENT + [ "users", "--all" ], GETENT + [ "users", "--xml", "--all" ], GETENT + [ "users", "--all", "--long" ], GETENT + [ "users", "--xml", "--all", "--long" ], # groups GETENT + [ "groups" ], GETENT + [ "groups", "--xml" ], GETENT + [ "groups", "--long" ], GETENT + [ "groups", "--long", "--xml" ], GETENT + [ "groups", "--xml", "--all" ], GETENT + [ "groups", "--xml", "--all", "--long" ], GETENT + [ "groups", "--xml", "--guests" ], GETENT + [ "groups", "--xml", "--guests", "--long " ], GETENT + [ "groups", "--xml", "--responsibles" ], GETENT + [ "groups", "--xml", "--responsibles", "--long" ], GETENT + [ "groups", "--xml", "--privileged" ], GETENT + [ "groups", "--xml", "--privileged", "--long" ], # Profiles GETENT + [ "profiles" ], GETENT + [ "profiles", "--xml" ], ) for command in commands: FunctionnalTest(command, context=context) test_message('''`get` tests finished.''')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py
ADD + [ 'group', "--name='_- -_'"], CHECK + [ 'group', "--name='_- -_'"], ADD + [ 'group', "--name=';-)'"], ADD + [ 'group', "--name='^_^'"], ADD + [ 'group', "--name='le copain des groupes'"], CHECK + [ 'group', '-v', "--name='le copain des groupes'"], ADD + [ 'group', "--name='héhéhé'"], ADD + [ 'group', "--name='%(\`ls -la /etc/passwd\`)'"], ADD + [ 'group', "--name='echo print coucou | python | nothing'"], ADD + [ 'group', "--name='**/*-'"], CHECK + [ 'group', '-v', "--name='**/*-'"]
ADD + [ 'group', "--name='_- -_'"], CHK + [ 'group', "--name='_- -_'"], ADD + [ 'group', "--name=';-)'"], ADD + [ 'group', "--name='^_^'"], ADD + [ 'group', "--name='le copain des groupes'"], CHK + [ 'group', '-v', "--name='le copain des groupes'"], ADD + [ 'group', "--name='héhéhé'"], ADD + [ 'group', "--name='%(\`ls -la /etc/passwd\`)'"], ADD + [ 'group', "--name='echo print coucou | python | nothing'"], ADD + [ 'group', "--name='**/*-'"], CHK + [ 'group', '-v', "--name='**/*-'"]
def test_regexes(): """ Try funky strings to make regexes fail (they should not).""" # TODO: test regexes directly from defs in licorn.core.... test_message('''starting regexes tests.''') regexes_commands = [] # groups related regexes_commands.extend([ ADD + [ 'group', "--name='_- -_'"], CHECK + [ 'group', "--name='_- -_'"], ADD + [ 'group', "--name=';-)'"], ADD + [ 'group', "--name='^_^'"], ADD + [ 'group', "--name='le copain des groupes'"], CHECK + [ 'group', '-v', "--name='le copain des groupes'"], ADD + [ 'group', "--name='héhéhé'"], ADD + [ 'group', "--name='%(\`ls -la /etc/passwd\`)'"], ADD + [ 'group', "--name='echo print coucou | python | nothing'"], ADD + [ 'group', "--name='**/*-'"], CHECK + [ 'group', '-v', "--name='**/*-'"] ]) # users related regexes_commands.extend([ ADD + [ 'user', "--login='_- -_'"], ADD + [ 'user', "--login=';-)'"], ADD + [ 'user', "--login='^_^'"], ADD + [ 'user', "--login='le copain des utilisateurs'"], ADD + [ 'user', "--login='héhéhé'"], ADD + [ 'user', "--login='%(\`ls -la /etc/passwd\`)'"], ADD + [ 'user', "--login='echo print coucou | python'"], ADD + [ 'user', "--login='**/*-'"] ]) for cmd in regexes_commands: FunctionnalTest(cmd).Run() # TODO: profiles ? test_message('''regexes tests finished.''')
07cb13c975b820cb15074a8378ec89357e5846f4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7650/07cb13c975b820cb15074a8378ec89357e5846f4/core.py