41
42
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):
48
# FIXME: check we're pending
50
details = db.get_user(login)
52
# make svn config/auth
54
repopath = os.path.join(conf.svn_repo_path, 'users', login)
55
logging.debug("Creating user's Subversion repository")
56
common.makeuser.make_svn_repo(repopath, throw_on_error=True)
58
rebuild_svn_config(props)
60
logging.debug("Adding Subversion authentication")
61
passwd = common.makeuser.make_svn_auth(login, throw_on_error=True)
62
logging.debug("passwd: %s" % passwd)
64
logging.debug("Creating jail")
65
common.makeuser.make_jail(login, details.unixid, svn_pass=passwd)
67
logging.info("Enabling user")
68
db.update_user(login, state='enabled')
70
return {"response": "okay"}
75
def rebuild_svn_config(props):
68
76
"""Rebuilds the svn config file
70
78
response (okay, failure)
73
ivle.makeuser.rebuild_svn_config(store)
81
common.makeuser.rebuild_svn_config()
74
82
except Exception, e:
75
83
logging.warning('Rebuild of Subversion authorization config failed!')
76
84
return{'response': 'failure', 'msg': repr(e)}
78
86
return {'response': 'okay'}
80
def rebuild_svn_group_config(store, props):
88
def rebuild_svn_group_config(props):
81
89
"""Rebuilds the svn group config file
83
91
response (okay, failure)
86
ivle.makeuser.rebuild_svn_group_config(store)
94
common.makeuser.rebuild_svn_group_config()
87
95
except Exception, e:
89
97
'Rebuild of Subversion group authorization config failed!')
92
100
return {'response': 'okay'}
94
def create_group_repository(store, props):
102
def create_group_repository(props):
95
103
"""Creates on disk repository for the given group
96
104
Expected properties:
97
105
subj_short_name, year, semester, groupnm
105
113
groupnm = props['groupnm']
107
115
namespace = "_".join([subj_short_name, year, semester, groupnm])
108
repopath = os.path.join(ivle.conf.svn_repo_path, 'groups', namespace)
116
repopath = os.path.join(conf.svn_repo_path, 'groups', namespace)
109
117
logging.debug("Creating Subversion repository %s"%repopath)
111
ivle.makeuser.make_svn_repo(repopath)
119
common.makeuser.make_svn_repo(repopath)
112
120
except Exception, e:
113
121
logging.error("Failed to create Subversion repository %s: %s"%
114
122
(repopath,repr(e)))
135
143
def dispatch(props):
136
144
logging.debug(repr(props))
138
store = ivle.database.get_store()
139
145
action = props.keys()[0]
140
res = actions[action](store, props[action])
142
if res['response'] == 'okay':
146
return actions[action](props[action])
149
148
if __name__ == "__main__":
150
149
pid = os.getpid()
152
151
logging.basicConfig(filename="/var/log/usrmgt.log", level=logging.INFO)
153
152
logging.info("Starting usrmgt server on port %d (pid = %d)" %
154
(ivle.conf.usrmgt_port, pid))
153
(conf.usrmgt_port, pid))
156
ivle.chat.start_server(ivle.conf.usrmgt_port, ivle.conf.usrmgt_magic,
157
True, dispatch, initializer)
155
common.chat.start_server(conf.usrmgt_port, conf.usrmgt_magic, True, dispatch, initializer)