27
29
# - Rebuild svn auth file
28
30
# - Rebuild passwd + push to nodes.
30
def activate_user(props):
32
def activate_user(store, props, config):
31
33
"""Create the on-disk stuff for the given user.
32
34
Sets the state of the user in the db from pending to enabled.
35
@param config: An ivle.config.Config object.
33
36
Expected properties:
34
37
login - the user name for the jail
42
if not os.path.exists(config['paths']['jails']['template']):
45
'message': 'Template jail has not been built -- '
46
'do you need to run ivle-buildjail?'}
39
48
os.umask(0022) # Bad, but start_server sets it worse.
41
50
login = props['login']
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):
52
# FIXME: check we're pending
54
# Get the full User object from the db associated with this
55
user = ivle.database.User.get_by_login(store, login)
57
# make svn config/auth
58
repopath = os.path.join(config['paths']['svn']['repo_path'],
60
logging.debug("Creating user's Subversion repository")
61
ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
63
rebuild_svn_config(store, props, config)
65
logging.debug("Adding Subversion authentication")
66
passwd = ivle.makeuser.make_svn_auth(store, login, config,
69
logging.debug("Creating jail")
70
ivle.makeuser.make_jail(user, config)
72
logging.info("Enabling user")
73
user.state = u'enabled'
75
return {"response": "okay"}
77
def rebuild_svn_config(store, props, config):
79
78
"""Rebuilds the svn config file
81
response (okay, failure)
79
@param config: An ivle.config.Config object.
80
@return: response (okay, failure)
84
ivle.makeuser.rebuild_svn_config()
83
ivle.makeuser.rebuild_svn_config(store, config)
85
84
except Exception, e:
86
85
logging.warning('Rebuild of Subversion authorization config failed!')
87
86
return{'response': 'failure', 'msg': repr(e)}
89
88
return {'response': 'okay'}
91
def rebuild_svn_group_config(props):
90
def rebuild_svn_group_config(store, props, config):
92
91
"""Rebuilds the svn group config file
94
response (okay, failure)
92
@param config: An ivle.config.Config object.
93
@return: response (okay, failure)
97
ivle.makeuser.rebuild_svn_group_config()
96
ivle.makeuser.rebuild_svn_group_config(store, config)
98
97
except Exception, e:
100
99
'Rebuild of Subversion group authorization config failed!')
146
150
def dispatch(props):
147
151
logging.debug(repr(props))
153
store = ivle.database.get_store(config)
148
154
action = props.keys()[0]
149
return actions[action](props[action])
155
res = actions[action](store, props[action], config)
157
if res['response'] == 'okay':
151
164
if __name__ == "__main__":
152
165
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))
158
ivle.chat.start_server(ivle.conf.usrmgt_port, ivle.conf.usrmgt_magic,
167
ivle.chat.start_server(config['usrmgt']['port'],config['usrmgt']['magic'],
159
168
True, dispatch, initializer)