9
# usrmgt-server <port> <magic>
11
# User management operations:
13
# - [Re]Create jail for a user
14
# - Create a svn repository for a user
18
# - Checkout repository as home directory
20
# - Disable a user's account
21
# - Enable a user's account
23
# - Rebuild svn config
24
# - Rebuild svn auth file
25
# - Rebuild passwd + push to nodes.
28
def create_user(props):
29
"""Create the database record for the given user.
31
username - used as a unix login name and svn repository name.
33
uid - the unix uid under which execution will take place
34
on the behalf of the user. Don't use 0! If not specified
35
or None, one will be allocated from the configured
38
password - the clear-text password for the user. If this property is
39
absent or None, this is an indication that external
40
authentication should be used (i.e. LDAP).
42
email - the user's email address.
44
nick - the display name to use.
46
fullname - The name of the user for results and/or other official
49
rolenm - The user's role. Must be one of "anyone", "student",
50
"tutor", "lecturer", "admin".
52
studentid - If supplied and not None, the student id of the user for
53
results and/or other official purposes.
55
Return Value: the uid associated with the user. INT
58
if 'uid' not in props or props['uid'] is None:
59
raise NotImplementedError, "No algorithm for creating uids yet!"
63
username = props['username']
66
password = props['password']
70
email = props['email']
74
fullname = props['fullname']
75
rolenm = props['rolenm']
77
studentid = props['studentid']
80
common.makeuser.make_user_db(username, uid, password, email, nick,
81
fullname, rolenm, studentid)
85
def create_jail(props):
86
"""Create the jail for a user.
88
username - the username for the jail
90
uid - the unix uid to make the owner of the home directory
93
gid - the unix group id to make the group of the home directory
94
in the jail. If not supplied (or None), then the uid is
100
if 'gid' not in props or props['gid'] is None:
103
common.makeuser.make_jail(props['username'], props['uid'], gid)
108
'create-user':create_user,
109
'init-jail':create_jail
113
action = props.keys()[0]
114
return actions[action](props[action])
116
if __name__ == "__main__":
117
port = int(sys.argv[1])
120
common.chat.start_server(port, magic, False, dispatch)