ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/ccs/admin/shells.py
Revision: 602
Committed: 2009-10-16T02:08:18-07:00 (15 years, 8 months ago) by douglas
Content type: text/x-python
File size: 920 byte(s)
Log Message:
Shells!

File Contents

# User Rev Content
1 douglas 602 #!/usr/bin/env python
2     # CCS Computer Science
3     # Shells
4     #
5     # Douglas Thrift
6     #
7     # $Id$
8    
9     import admin
10     import common
11     import copy
12     import ldap
13     import ldap.modlist
14    
15     if __name__ == '__main__':
16     shells = list(common.SHELLS)
17     shells[-1] = ('custom', dict(common.SHELLS)['bash'])
18    
19     connection = admin.ldap_connection()
20    
21     for shell, shells in shells:
22     for dn, old_entry in connection.search_s(admin.PEOPLE, ldap.SCOPE_ONELEVEL, '(loginShell=%s)' % shell, ['uid'] + admin.SHELLS):
23    
24     if shell != 'custom':
25     new_entry = dict(zip(admin.SHELLS, map(lambda shell: [shell], shells)))
26     else:
27     new_entry = copy.copy(old_entry)
28    
29     for type, _shell in zip(admin.SHELLS, shells):
30     if type not in new_entry:
31     new_entry[type] = _shell
32    
33     modlist = ldap.modlist.modifyModlist(old_entry, new_entry, ('uid',))
34    
35     if modlist:
36     print old_entry['uid'][0], modlist
37    
38     connection.modify_s(dn, modlist)
39    
40     connection.unbind_s()

Properties

Name Value
svn:executable *
svn:keywords Id