32
32
# TODO: When creating a new home directory, chown it to its owner
45
def make_svn_repo(login):
46
"""Create a repository for the given user.
48
path = os.path.join(conf.svn_repo_path, login)
49
res = os.system("svnadmin create '%s'" % path)
51
raise Exception("Cannot create repository for %s" % login)
53
def rebuild_svn_config():
54
"""Build the complete SVN configuration file.
57
res = conn.query("SELECT login, rolenm FROM login;").dictresult()
61
if role not in groups:
63
groups[role].append(r['login'])
64
f = open(conf.svn_conf + ".new", "w")
65
f.write("# IVLE SVN Repositories Configuration\n")
66
f.write("# Auto-generated on %s\n" % time.asctime())
69
for (g,ls) in groups.iteritems():
70
f.write("%s = %s\n" % (g, ",".join(ls)))
74
f.write("[%s:/]\n" % login)
75
f.write("%s = rw\n" % login)
76
f.write("@tutor = r\n")
77
f.write("@lecturer = rw\n")
78
f.write("@admin = rw\n")
81
os.rename(conf.svn_conf + ".new", conf.svn_conf)
83
def make_svn_config(login):
84
"""Add an entry to the apache-svn config file for the given user.
85
Assumes the given user is either a guest or a student.
87
f = open(conf.svn_conf, "a")
88
f.write("[%s:/]\n" % login)
89
f.write("%s = rw\n" % login)
90
f.write("@tutor = r\n")
91
f.write("@lecturer = rw\n")
92
f.write("@admin = rw\n")
96
def make_svn_auth(login):
97
"""Setup svn authentication for the given user.
98
FIXME: create local.auth entry
100
passwd = md5.new(uuid.uuid4().bytes).digest().encode('hex')
101
if os.path.exists(conf.svn_auth_ivle):
106
db.DB().update_user({'svn_pass':passwd})
108
res = os.system("htpasswd -%smb %s %s" % (create,
112
raise Exception("Unable to create ivle-auth for %s" % login)
114
42
def make_jail(username, uid, force=True):
115
43
"""Creates a new user's jail space, in the jail directory as configured in
238
166
raise Exception, errors
240
def make_user_db(**kwargs):
168
def make_user_db(login, uid, password, nick, fullname, rolenm, studentid,
241
170
"""Creates a user's entry in the database, filling in all the fields.
242
All arguments must be keyword args. They are the fields in the table.
243
However, instead of supplying a "passhash", you must supply a
244
"password" argument, which will be hashed internally.
245
Also do not supply a state. All users are created in the "no_agreement"
247
Throws an exception if the user already exists.
171
If force is False, throws an exception if the user already exists.
172
If True, overwrites the user's entry in the DB.
250
dbconn.create_user(**kwargs)
176
# Delete user if it exists
178
dbconn.delete_user(login)
181
dbconn.create_user(login, uid, password, nick, fullname, rolenm, studentid)