Skip to content

Commit 2bcd74c

Browse files
edomora97lw
authored andcommitted
Fixed corrupted users imported after eaee3a8
The new format of stored passwords (after eaee3a8) requires that in the DB the password is a 2 part string separated by ':'. Before this patch when an old contest (like cms-dev/con_test) is imported the passwords in the db were corrupted (the "method" was not specified) and cmsContestWebServer fired 500 errors on login.
1 parent a200e4f commit 2bcd74c

3 files changed

Lines changed: 10 additions & 4 deletions

File tree

AUTHORS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Artem Iglikov (aka artikz) <artem.iglikov@gmail.com>
2525
Damien Leroy <damien.leroy@be-oi.be>
2626
Tubérculo Martínez <nlehmann@dcc.uchile.cl>
2727
Evgeny Martynov <evgeny@epochfail.com>
28-
Edoardo Morassutto <gianluigi988@gmail.com>
28+
Edoardo Morassutto <edoardo.morassutto@gmail.com>
2929
Kento Nikaido (aka snukent) <snukent@gmail.com>
3030
William Pettersson <william.pettersson@gmail.com>
3131
Ludwig Schmidt <ludwigschmidt2@gmail.com>

cmscontrib/loaders/italy_yaml.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# Copyright © 2014-2016 William Di Luigi <williamdiluigi@gmail.com>
1010
# Copyright © 2015 Luca Chiodini <luca@chiodini.org>
1111
# Copyright © 2016 Andrea Cracco <guilucand@gmail.com>
12+
# Copyright © 2018 Edoardo Morassutto <edoardo.morassutto@gmail.com>
1213
#
1314
# This program is free software: you can redistribute it and/or modify
1415
# it under the terms of the GNU Affero General Public License as
@@ -39,6 +40,7 @@
3940
from cms.db import Contest, User, Task, Statement, Attachment, \
4041
Team, SubmissionFormatElement, Dataset, Manager, Testcase
4142
from cms.grading.languagemanager import LANGUAGES, HEADER_EXTS
43+
from cmscommon.crypto import build_password
4244
from cmscommon.datetime import make_datetime
4345
from cmscontrib import touch
4446

@@ -209,6 +211,8 @@ def get_contest(self):
209211

210212
tasks = load(conf, None, ["tasks", "problemi"])
211213
participations = load(conf, None, ["users", "utenti"])
214+
for p in participations:
215+
p["password"] = build_password(p["password"])
212216

213217
# Import was successful
214218
os.remove(os.path.join(self.path, ".import_error_contest"))
@@ -245,7 +249,7 @@ def get_user(self):
245249
return None
246250

247251
load(conf, args, "username")
248-
load(conf, args, "password")
252+
load(conf, args, "password", conv=build_password)
249253

250254
load(conf, args, ["first_name", "nome"])
251255
load(conf, args, ["last_name", "cognome"])

cmscontrib/loaders/polygon.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Programming contest management system
55
# Copyright © 2014 Artem Iglikov <artem.iglikov@gmail.com>
66
# Copyright © 2014 Stefano Maggiolo <s.maggiolo@gmail.com>
7+
# Copyright © 2018 Edoardo Morassutto <edoardo.morassutto@gmail.com>
78
#
89
# This program is free software: you can redistribute it and/or modify
910
# it under the terms of the GNU Affero General Public License as
@@ -36,6 +37,7 @@
3637
from cms import config
3738
from cms.db import Contest, User, Task, Statement, \
3839
SubmissionFormatElement, Dataset, Manager, Testcase
40+
from cmscommon.crypto import build_password
3941
from cmscontrib import touch
4042

4143
from .base_loader import ContestLoader, TaskLoader, UserLoader
@@ -323,7 +325,7 @@ def get_user(self):
323325
logger.info("Loading parameters for user %s.", username)
324326
args = {}
325327
args['username'] = userdata[0]
326-
args['password'] = userdata[1]
328+
args['password'] = build_password(userdata[1])
327329
args['first_name'] = userdata[2]
328330
args['last_name'] = userdata[3]
329331
args['hidden'] = (len(userdata) > 4 and userdata[4] == '1')
@@ -448,7 +450,7 @@ def get_contest(self):
448450
user = user.split(';')
449451
participations.append({
450452
"username": user[0].strip(),
451-
"password": user[1].strip(),
453+
"password": build_password(user[1].strip()),
452454
"hidden": user[4].strip()
453455
# "ip" is not passed
454456
})

0 commit comments

Comments
 (0)