Tighten up a few things in fasClient and group.py, add load=effects and tg.url() to kill a bunch of 404s.
This commit is contained in:
parent
339c51f915
commit
9960e20e42
4 changed files with 39 additions and 46 deletions
|
@ -27,7 +27,7 @@ Before you can get started, make sure to have the following packages installed
|
||||||
|
|
||||||
yum install git-core postgresql-plpython postgresql-server postgresql-python \
|
yum install git-core postgresql-plpython postgresql-server postgresql-python \
|
||||||
python-TurboMail TurboGears pygpgme python-sqlalchemy python-genshi \
|
python-TurboMail TurboGears pygpgme python-sqlalchemy python-genshi \
|
||||||
python-psycopg2
|
python-psycopg2 pytz
|
||||||
|
|
||||||
# Note: on RHEL5 you need postgresql-pl instead of postgresql-plpython
|
# Note: on RHEL5 you need postgresql-pl instead of postgresql-plpython
|
||||||
|
|
||||||
|
@ -123,4 +123,5 @@ To test, look and see if your groups or users show up with getent. For
|
||||||
example:
|
example:
|
||||||
|
|
||||||
getent passwd
|
getent passwd
|
||||||
getent group
|
getent group
|
||||||
|
|
||||||
|
|
|
@ -79,19 +79,14 @@ class MakeShellAccounts(BaseClient):
|
||||||
|
|
||||||
def mk_tempdir(self):
|
def mk_tempdir(self):
|
||||||
self.temp = tempfile.mkdtemp('-tmp', 'fas-', '/var/db')
|
self.temp = tempfile.mkdtemp('-tmp', 'fas-', '/var/db')
|
||||||
os.chmod(self.temp, 00400)
|
|
||||||
|
|
||||||
def rm_tempdir(self):
|
def rm_tempdir(self):
|
||||||
rmtree(self.temp)
|
rmtree(self.temp)
|
||||||
|
|
||||||
def group_list(self, search='*'):
|
|
||||||
params = {'search' : search}
|
|
||||||
data = self.send_request('group/list', auth=True, input=params)
|
|
||||||
return data
|
|
||||||
|
|
||||||
def shadow_text(self, people=None):
|
def shadow_text(self, people=None):
|
||||||
i = 0
|
i = 0
|
||||||
file = open(self.temp + '/shadow.txt', 'w')
|
file = open(self.temp + '/shadow.txt', 'w')
|
||||||
|
os.chmod(self.temp + '/shadow.txt', 00400)
|
||||||
if not people:
|
if not people:
|
||||||
people = self.people_list()
|
people = self.people_list()
|
||||||
for person in people:
|
for person in people:
|
||||||
|
@ -103,8 +98,6 @@ class MakeShellAccounts(BaseClient):
|
||||||
file.write(".%s %s:%s:99999:0:99999:7:::\n" % (username, username, password))
|
file.write(".%s %s:%s:99999:0:99999:7:::\n" % (username, username, password))
|
||||||
i = i + 1
|
i = i + 1
|
||||||
file.close()
|
file.close()
|
||||||
os.chmod(self.temp + '/shadow.txt', 00400)
|
|
||||||
|
|
||||||
|
|
||||||
def passwd_text(self, people=None):
|
def passwd_text(self, people=None):
|
||||||
i = 0
|
i = 0
|
||||||
|
@ -136,10 +129,10 @@ class MakeShellAccounts(BaseClient):
|
||||||
for person in people:
|
for person in people:
|
||||||
uid = person['id']
|
uid = person['id']
|
||||||
username = person['username']
|
username = person['username']
|
||||||
usernames['%s' % uid] = username
|
usernames[uid] = username
|
||||||
file.write("=%i %s:x:%i:\n" % (uid, username, uid))
|
file.write("=%i %s:x:%i:\n" % (uid, username, uid))
|
||||||
file.write( "0%i %s:x:%i:\n" % (i, username, uid))
|
file.write("0%i %s:x:%i:\n" % (i, username, uid))
|
||||||
file.write( ".%s %s:x:%i:\n" % (username, username, uid))
|
file.write(".%s %s:x:%i:\n" % (username, username, uid))
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
for group in groups['groups']:
|
for group in groups['groups']:
|
||||||
|
@ -149,18 +142,23 @@ class MakeShellAccounts(BaseClient):
|
||||||
try:
|
try:
|
||||||
''' Shoot me now I know this isn't right '''
|
''' Shoot me now I know this isn't right '''
|
||||||
members = []
|
members = []
|
||||||
for member in groups['memberships'][u'%s' % gid]:
|
for member in groups['memberships'][name]:
|
||||||
members.append(usernames['%s' % member['person_id']])
|
members.append(usernames[member['person_id']])
|
||||||
memberships = ','.join(members)
|
memberships = ','.join(members)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
''' No users exist in the group '''
|
''' No users exist in the group '''
|
||||||
pass
|
pass
|
||||||
file.write( "=%i %s:x:%i:%s\n" % (gid, name, gid, memberships))
|
file.write("=%i %s:x:%i:%s\n" % (gid, name, gid, memberships))
|
||||||
file.write("0%i %s:x:%i:%s\n" % (i, name, gid, memberships))
|
file.write("0%i %s:x:%i:%s\n" % (i, name, gid, memberships))
|
||||||
file.write(".%s %s:x:%i:%s\n" % (name, name, gid, memberships))
|
file.write(".%s %s:x:%i:%s\n" % (name, name, gid, memberships))
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
def group_list(self, search='*'):
|
||||||
|
params = {'search' : search}
|
||||||
|
data = self.send_request('group/list', auth=True, input=params)
|
||||||
|
return data
|
||||||
|
|
||||||
def people_list(self, search='*'):
|
def people_list(self, search='*'):
|
||||||
params = {'search' : search}
|
params = {'search' : search}
|
||||||
|
@ -205,14 +203,11 @@ def enable():
|
||||||
if line.startswith('passwd') or line.startswith('shadow') or line.startswith('group'):
|
if line.startswith('passwd') or line.startswith('shadow') or line.startswith('group'):
|
||||||
parts = line.split()
|
parts = line.split()
|
||||||
if 'db' in parts:
|
if 'db' in parts:
|
||||||
new.write(line)
|
|
||||||
print "%s already has db enabled" % parts[0].split(':')[0]
|
print "%s already has db enabled" % parts[0].split(':')[0]
|
||||||
else:
|
else:
|
||||||
tmp = line.strip('\n')
|
line = line.strip('\n')
|
||||||
tmp = tmp + ' db\n'
|
line += ' db\n'
|
||||||
new.write(tmp)
|
new.write(line)
|
||||||
else:
|
|
||||||
new.write(line)
|
|
||||||
new.close()
|
new.close()
|
||||||
try:
|
try:
|
||||||
move('/tmp/.fas.nsswitch.conf', '/etc/nsswitch.conf')
|
move('/tmp/.fas.nsswitch.conf', '/etc/nsswitch.conf')
|
||||||
|
@ -226,13 +221,10 @@ def disable():
|
||||||
if line.startswith('passwd') or line.startswith('shadow') or line.startswith('group'):
|
if line.startswith('passwd') or line.startswith('shadow') or line.startswith('group'):
|
||||||
parts = line.split()
|
parts = line.split()
|
||||||
if 'db' in parts:
|
if 'db' in parts:
|
||||||
tmp = line.replace(' db', '')
|
line = line.replace(' db', '')
|
||||||
new.write(tmp)
|
|
||||||
else:
|
else:
|
||||||
print "%s already has db disabled" % parts[0].split(':')[0]
|
print "%s already has db disabled" % parts[0].split(':')[0]
|
||||||
new.write(line)
|
new.write(line)
|
||||||
else:
|
|
||||||
new.write(line)
|
|
||||||
new.close()
|
new.close()
|
||||||
try:
|
try:
|
||||||
move('/tmp/.fas.nsswitch.conf', '/etc/nsswitch.conf')
|
move('/tmp/.fas.nsswitch.conf', '/etc/nsswitch.conf')
|
||||||
|
@ -240,13 +232,7 @@ def disable():
|
||||||
print "ERROR: Could not write nsswitch.conf - %s" % e
|
print "ERROR: Could not write nsswitch.conf - %s" % e
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if opts.enable:
|
if opts.install:
|
||||||
enable()
|
|
||||||
sys.exit()
|
|
||||||
elif opts.disable:
|
|
||||||
disable()
|
|
||||||
sys.exit()
|
|
||||||
elif opts.install:
|
|
||||||
try:
|
try:
|
||||||
fas = MakeShellAccounts(FAS_URL, 'admin', 'admin', False)
|
fas = MakeShellAccounts(FAS_URL, 'admin', 'admin', False)
|
||||||
except AuthError, e:
|
except AuthError, e:
|
||||||
|
@ -263,5 +249,9 @@ if __name__ == '__main__':
|
||||||
if not opts.no_shadow:
|
if not opts.no_shadow:
|
||||||
fas.install_shadow_db()
|
fas.install_shadow_db()
|
||||||
fas.rm_tempdir()
|
fas.rm_tempdir()
|
||||||
else:
|
if opts.enable:
|
||||||
|
enable()
|
||||||
|
if opts.disable:
|
||||||
|
disable()
|
||||||
|
if not (opts.install or opts.enable or opts.disable):
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
|
|
@ -247,14 +247,16 @@ class Group(controllers.Controller):
|
||||||
username = turbogears.identity.current.user_name
|
username = turbogears.identity.current.user_name
|
||||||
person = People.by_username(username)
|
person = People.by_username(username)
|
||||||
|
|
||||||
re_search = re.sub(r'\*', r'%', search).lower()
|
|
||||||
groups = Groups.query.filter(Groups.name.like(re_search)).order_by('name')
|
|
||||||
groups = filter(lambda group: canViewGroup(person, group), groups)
|
|
||||||
if len(groups) <= 0:
|
|
||||||
turbogears.flash(_("No Groups found matching '%s'") % search)
|
|
||||||
memberships = {}
|
memberships = {}
|
||||||
for group in groups:
|
groups = []
|
||||||
memberships[group.id] = group.approved_roles
|
re_search = re.sub(r'\*', r'%', search).lower()
|
||||||
|
results = Groups.query.filter(Groups.name.like(re_search)).order_by('name').all()
|
||||||
|
for group in results:
|
||||||
|
if canViewGroup(person, group):
|
||||||
|
groups.append(group)
|
||||||
|
memberships[group.name] = group.approved_roles
|
||||||
|
if not len(groups):
|
||||||
|
turbogears.flash(_("No Groups found matching '%s'") % search)
|
||||||
return dict(groups=groups, search=search, memberships=memberships)
|
return dict(groups=groups, search=search, memberships=memberships)
|
||||||
|
|
||||||
@identity.require(turbogears.identity.not_anonymous())
|
@identity.require(turbogears.identity.not_anonymous())
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
<head py:match="head" py:attrs="select('@*')">
|
<head py:match="head" py:attrs="select('@*')">
|
||||||
<link href="${tg.url('/static/css/style.css')}" rel="stylesheet" type="text/css" />
|
<link href="${tg.url('/static/css/style.css')}" rel="stylesheet" type="text/css" />
|
||||||
<meta py:replace="select('*|text()')" />
|
<meta py:replace="select('*|text()')" />
|
||||||
<script type="text/javascript" src="/static/js/prototype.js"></script>
|
<script type="text/javascript" src="${tg.url('/static/js/prototype.js')}"></script>
|
||||||
<script type="text/javascript" src="/static/js/prototype.improvements.js"></script>
|
<script type="text/javascript" src="${tg.url('/static/js/prototype.improvements.js')}"></script>
|
||||||
<script type="text/javascript" src="/static/js/scriptaculous.js"></script>
|
<script type="text/javascript" src="${tg.url('/static/js/scriptaculous.js?load=effects')}"></script>
|
||||||
<script type="text/javascript" language="JavaScript" src="/static/js/HelpBalloon.js"></script>
|
<script type="text/javascript" src="${tg.url('/static/js/HelpBalloon.js')}"></script>
|
||||||
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue