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
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?'}
48
39
os.umask(0022) # Bad, but start_server sets it worse.
50
41
login = props['login']
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):
47
# FIXME: check we're pending
49
details = db.get_user(login)
51
# make svn config/auth
53
repopath = os.path.join(ivle.conf.svn_repo_path, 'users', login)
54
logging.debug("Creating user's Subversion repository")
55
ivle.makeuser.make_svn_repo(repopath, throw_on_error=True)
57
rebuild_svn_config(props)
59
logging.debug("Adding Subversion authentication")
60
passwd = ivle.makeuser.make_svn_auth(login, throw_on_error=True)
61
logging.debug("passwd: %s" % passwd)
63
logging.debug("Creating jail")
64
ivle.makeuser.make_jail(login, details.unixid, svn_pass=passwd)
66
logging.info("Enabling user")
67
db.update_user(login, state='enabled')
69
return {"response": "okay"}
74
def rebuild_svn_config(props):
78
75
"""Rebuilds the svn config file
79
@param config: An ivle.config.Config object.
80
@return: response (okay, failure)
77
response (okay, failure)
83
ivle.makeuser.rebuild_svn_config(store, config)
80
ivle.makeuser.rebuild_svn_config()
84
81
except Exception, e:
85
82
logging.warning('Rebuild of Subversion authorization config failed!')
86
83
return{'response': 'failure', 'msg': repr(e)}
88
85
return {'response': 'okay'}
90
def rebuild_svn_group_config(store, props, config):
87
def rebuild_svn_group_config(props):
91
88
"""Rebuilds the svn group config file
92
@param config: An ivle.config.Config object.
93
@return: response (okay, failure)
90
response (okay, failure)
96
ivle.makeuser.rebuild_svn_group_config(store, config)
93
ivle.makeuser.rebuild_svn_group_config()
97
94
except Exception, e:
99
96
'Rebuild of Subversion group authorization config failed!')
150
142
def dispatch(props):
151
143
logging.debug(repr(props))
153
store = ivle.database.get_store(config)
154
144
action = props.keys()[0]
155
res = actions[action](store, props[action], config)
157
if res['response'] == 'okay':
145
return actions[action](props[action])
164
147
if __name__ == "__main__":
165
148
pid = os.getpid()
167
ivle.chat.start_server(config['usrmgt']['port'],config['usrmgt']['magic'],
150
logging.basicConfig(filename="/var/log/usrmgt.log", level=logging.INFO)
151
logging.info("Starting usrmgt server on port %d (pid = %d)" %
152
(ivle.conf.usrmgt_port, pid))
154
ivle.chat.start_server(ivle.conf.usrmgt_port, ivle.conf.usrmgt_magic,
168
155
True, dispatch, initializer)