29
27
# - Rebuild svn auth file
30
28
# - Rebuild passwd + push to nodes.
32
def activate_user(store, props, config):
30
def activate_user(props):
33
31
"""Create the on-disk stuff for the given user.
34
32
Sets the state of the user in the db from pending to enabled.
35
@param config: An ivle.config.Config object.
36
33
Expected properties:
37
34
login - the user name for the jail
42
39
os.umask(0022) # Bad, but start_server sets it worse.
44
41
login = props['login']
46
# FIXME: check we're pending
48
# Get the full User object from the db associated with this
49
user = ivle.database.User.get_by_login(store, login)
51
# make svn config/auth
52
repopath = os.path.join(config['paths']['svn']['repo_path'],
54
logging.debug("Creating user's Subversion repository")
55
ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
57
rebuild_svn_config(store, props, config)
59
logging.debug("Adding Subversion authentication")
60
passwd = ivle.makeuser.make_svn_auth(store, login, config,
63
logging.debug("Creating jail")
64
ivle.makeuser.make_jail(user, config)
66
logging.info("Enabling user")
67
user.state = u'enabled'
69
return {"response": "okay"}
71
def rebuild_svn_config(store, props, config):
43
store = ivle.database.get_store()
47
# FIXME: check we're pending
49
# Get the full User object from the db associated with this
50
user = ivle.database.User.get_by_login(store, login)
52
# make svn config/auth
54
repopath = os.path.join(ivle.conf.svn_repo_path, 'users', login)
55
logging.debug("Creating user's Subversion repository")
56
ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
58
rebuild_svn_config(props)
60
logging.debug("Adding Subversion authentication")
61
passwd = ivle.makeuser.make_svn_auth(store, login,
63
logging.debug("passwd: %s" % passwd)
65
logging.debug("Creating jail")
66
ivle.makeuser.make_jail(login, user.unixid, svn_pass=passwd)
68
logging.info("Enabling user")
69
user.state = u'enabled'
73
return {"response": "okay"}
78
def rebuild_svn_config(props):
72
79
"""Rebuilds the svn config file
73
@param config: An ivle.config.Config object.
74
@return: response (okay, failure)
81
response (okay, failure)
77
ivle.makeuser.rebuild_svn_config(store, config)
84
ivle.makeuser.rebuild_svn_config()
78
85
except Exception, e:
79
86
logging.warning('Rebuild of Subversion authorization config failed!')
80
87
return{'response': 'failure', 'msg': repr(e)}
82
89
return {'response': 'okay'}
84
def rebuild_svn_group_config(store, props, config):
91
def rebuild_svn_group_config(props):
85
92
"""Rebuilds the svn group config file
86
@param config: An ivle.config.Config object.
87
@return: response (okay, failure)
94
response (okay, failure)
90
ivle.makeuser.rebuild_svn_group_config(store, config)
97
ivle.makeuser.rebuild_svn_group_config()
91
98
except Exception, e:
93
100
'Rebuild of Subversion group authorization config failed!')
96
103
return {'response': 'okay'}
98
def create_group_repository(store, props, config):
105
def create_group_repository(props):
99
106
"""Creates on disk repository for the given group
100
@param config: An ivle.config.Config object.
101
107
Expected properties:
102
108
subj_short_name, year, semester, groupnm
103
@return: response (okay, failure)
110
response (okay, failure)
106
113
subj_short_name = props['subj_short_name']
144
146
def dispatch(props):
145
147
logging.debug(repr(props))
147
store = ivle.database.get_store(config)
148
148
action = props.keys()[0]
149
res = actions[action](store, props[action], config)
151
if res['response'] == 'okay':
149
return actions[action](props[action])
158
151
if __name__ == "__main__":
159
152
pid = os.getpid()
161
ivle.chat.start_server(config['usrmgt']['port'],config['usrmgt']['magic'],
154
logging.basicConfig(filename="/var/log/usrmgt.log", level=logging.INFO)
155
logging.info("Starting usrmgt server on port %d (pid = %d)" %
156
(ivle.conf.usrmgt_port, pid))
158
ivle.chat.start_server(ivle.conf.usrmgt_port, ivle.conf.usrmgt_magic,
162
159
True, dispatch, initializer)