41
41
login = props['login']
43
# FIXME: check we're pending
45
# Get the full User object from the db associated with this
46
user = ivle.database.User.get_by_login(store, login)
48
# make svn config/auth
49
repopath = os.path.join(ivle.conf.svn_repo_path, 'users', login)
50
logging.debug("Creating user's Subversion repository")
51
ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
53
rebuild_svn_config(store, props)
55
logging.debug("Adding Subversion authentication")
56
passwd = ivle.makeuser.make_svn_auth(store, login,
59
logging.debug("Creating jail")
60
ivle.makeuser.make_jail(user)
62
logging.info("Enabling user")
63
user.state = u'enabled'
65
return {"response": "okay"}
67
def rebuild_svn_config(store, props):
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):
68
79
"""Rebuilds the svn config file
70
81
response (okay, failure)
73
ivle.makeuser.rebuild_svn_config(store)
84
ivle.makeuser.rebuild_svn_config()
74
85
except Exception, e:
75
86
logging.warning('Rebuild of Subversion authorization config failed!')
76
87
return{'response': 'failure', 'msg': repr(e)}
78
89
return {'response': 'okay'}
80
def rebuild_svn_group_config(store, props):
91
def rebuild_svn_group_config(props):
81
92
"""Rebuilds the svn group config file
83
94
response (okay, failure)
86
ivle.makeuser.rebuild_svn_group_config(store)
97
ivle.makeuser.rebuild_svn_group_config()
87
98
except Exception, e:
89
100
'Rebuild of Subversion group authorization config failed!')
139
146
def dispatch(props):
140
147
logging.debug(repr(props))
142
store = ivle.database.get_store()
143
148
action = props.keys()[0]
144
res = actions[action](store, props[action])
146
if res['response'] == 'okay':
149
return actions[action](props[action])
153
151
if __name__ == "__main__":
154
152
pid = os.getpid()
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))
156
158
ivle.chat.start_server(ivle.conf.usrmgt_port, ivle.conf.usrmgt_magic,
157
159
True, dispatch, initializer)