From 40fa681226d0b75d5062b6c923bdf999eb577888 Mon Sep 17 00:00:00 2001
From: "gasperfele@fri1.uni-lj.si"
Date: Mon, 23 Oct 2017 18:56:39 +0000
Subject: Pripravljen pristopni 2017
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@423 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
---
kpov_judge/create_disk_images.py | 1 +
.../tasks/edit_find_grep_compile_convert/task.py | 13 +++--
kpov_judge/tasks/rename_grep_network/task.py | 66 ++++++++++++++--------
.../web/kpov_judge/templates/task_greeting.html | 1 +
4 files changed, 52 insertions(+), 29 deletions(-)
(limited to 'kpov_judge')
diff --git a/kpov_judge/create_disk_images.py b/kpov_judge/create_disk_images.py
index 09f74a2..d28ef1d 100755
--- a/kpov_judge/create_disk_images.py
+++ b/kpov_judge/create_disk_images.py
@@ -113,6 +113,7 @@ if __name__ == '__main__':
g.add_drive(snap_file)
if 'parts' in disk:
for p in disk['parts']:
+ lock_fp.write("part {}: {}\n".format(dev_prefix + p['dev'], p['path']))
manual_disks.append((dev_prefix + p['dev'],
p['path'], p.get('options', None)))
else:
diff --git a/kpov_judge/tasks/edit_find_grep_compile_convert/task.py b/kpov_judge/tasks/edit_find_grep_compile_convert/task.py
index 8b8ecb8..7a358b9 100644
--- a/kpov_judge/tasks/edit_find_grep_compile_convert/task.py
+++ b/kpov_judge/tasks/edit_find_grep_compile_convert/task.py
@@ -14,7 +14,7 @@ Ustvari dva navidezna računalnika s slikama diskov
- SimpleArbiter s sliko diska simpleArbiterDhcp in
SmallStudent s sliko diska student-entrance2.
-Na SimpleArbiter se lahko prijaviš z uporabniškim imenom tester in geslom test.
+Na SimpleArbiter se lahko prijaviš z uporabniškim imenom tester in geslom tester.
Na SmallStudent se lahko prijaviš kot root z geslom kaboom.
Poskrbi, da bo SmallStudent s SimpleArbiter dostopen na naslovu {testip}.
@@ -28,7 +28,7 @@ Brati naj jo ima pravico samo lastnik, pisati lastnik in skupina, poganjati nih
V {dstfile} zamenjaj vse vrstice oblike poXYZlz, kjer so XYZ poljubni znaki, tako, da bo namesto XYZ niz "kaka".
Napiši program v poljubnem programskem jeziku, ki kot argument sprejme število B med 0 in 7.
-Program naj prebere znak s standardnega izhoda.
+Program naj prebere znak s standardnega vhoda.
Če je B-ti bit v znaku nastavljen na 1, naj izpiše "ta".
Če je B-ti bit nastavljen na 0, naj program izpiše "ti".
Program poimenuj {progname} in ga spravi v domači imenik {testuser}.
@@ -38,7 +38,7 @@ Create two virtual machines
- SimpleArbiter using simpleArbiterDhcp as the disk image and
SmallStudent using student-entrance2 as its disk.
-You can log in as testr on SimpleArbiter with the password test.
+You can log in as tester on SimpleArbiter with the password tester.
You can log in as root on SimpleStudent with the password kaboom.
Make sure that SmallStudent is accessible from SimpleArbiter on IP {testip}.
@@ -47,7 +47,7 @@ Create a user {testuser} with the password {passwd} on SmallStudent.
There is a file containing {magicstr} hidden somewhere in the home directory of
user "bilbo".
-Copy the into the home directory of user bilbo and name it {dstfile}.
+Copy the into the home directory of user {testuser} and name it {dstfile}.
Change the owner to {testuser} and leave the group unchanged.
Make sure only the owner has the right to read it, only the owner and group members have the right to write to it and noone has the right to execute it.
In {dstfile}, replace all lines of the form poXYZlz where XYZ are arbitrary characters so that XYZ is replaced by "kaka".
@@ -60,7 +60,7 @@ Name the program {progname} and place it in the home directory of {testuser}.
''',
}
-instructions = {'si': 'Potrpite.', 'en': 'Have patience.'}
+# instructions = {'si': 'Potrpite.', 'en': 'Have patience.'}
computers = {
'SimpleArbiter': {
@@ -275,7 +275,7 @@ def task_check(results, params):
break
hints += ["wrong file contents\n" + str(diff_pos[1])]
#hints += ["wrong file contents"]
- expected_ls = u"ls -l ~/{dstfile}\r\n-rw--w---- 1 {testuser} bilbo .*{dstfile}\r\n".format(**params)
+ expected_ls = u"ls -l ~/{dstfile}\r\n-rw--w---- 1 {testuser} bilbo .*{dstfile}.*\r\n".format(**params)
if re.match(expected_ls, results["dst_ls"]):
score += 3
else:
@@ -298,6 +298,7 @@ def task_check(results, params):
if results["tita_return"] == expected_tita:
score += 2
else:
+ #hints += [u"program output incorrect\n" + results["tita_return"] + expected_tita]
hints += [u"program output incorrect\n" + results["tita_return"]]
return score, hints
diff --git a/kpov_judge/tasks/rename_grep_network/task.py b/kpov_judge/tasks/rename_grep_network/task.py
index cc21479..ce761db 100644
--- a/kpov_judge/tasks/rename_grep_network/task.py
+++ b/kpov_judge/tasks/rename_grep_network/task.py
@@ -42,7 +42,7 @@ computers = {
'SimpleArbiter': {
'disks': [
{
- 'name': 'simpleArbiterDhcpGW',
+ 'name': 'simpleArbiterEntrance',
},
],
'network_interfaces': [
@@ -60,9 +60,11 @@ computers = {
'disks': [
{
'name': 'student-entrance3',
+ 'parts': [{'dev': 'a1', 'path': '/'}],
},
{
'name': 'smallstudent-personal',
+ 'parts': [{'dev': 'b1', 'path': '/media'}, {'dev': 'b2', 'path': '/mnt'}]
}
],
'network_interfaces': [
@@ -120,7 +122,11 @@ params_meta = {
'descriptions': {
'si': 'imenik za priklop diska',
'en': 'mountpoint',
- }
+ },
+ 'w': False,
+ 'public': True,
+ 'type': 'dirname',
+ 'generated': True,
},
'magicstr' : {
'descriptions': {
@@ -181,7 +187,7 @@ def task(testip, testuser, passwd, mntdir, magicstr, pubseed):
dst_ls = target.before
target.sendline('mount')
target.prompt()
- mnt = target.before()
+ mnt = target.before
results = {
'home_ls': home_ls,
'dst_ls': dst_ls,
@@ -216,7 +222,7 @@ def task_check(results, params):
score = 0
hidden_contents = params['magicstr']
r = random.Random(params['rndseed'])
- dstfile = "".join([r.choice("qQoOp") for i in range(48)]) + "I.txt"
+ dstfile = "".join([r.choice("qQoOp") for i in range(64)]) + "I.txt"
dstfile = dstfile.replace('O', 'I')
for i in range(1000):
start = "".join([r.choice(["po", "p0", "no", "ko", "fo", "qo"]) for i in range(20)])
@@ -245,20 +251,24 @@ def task_check(results, params):
break
hints += ["wrong file contents\n" + str(diff_pos[1])]
#hints += ["wrong file contents"]
- expected_ls = u"ls -l ~/*I*.txt\r\n-rw--w---- 1 {testuser} bilbo .*{dstfile}\r\n".format(**params)
- if re.match(expected_ls, results["dst_ls"]):
- score += 3
- else:
- hints += [u"missing file or wrong user/permissions\n" + results["dst_ls"]]
- if results["home_ls"].find(params['progname']) > -1:
+ params['dstfile'] = dstfile
+ expected_dst_ls = u"ls -l ~/\\*I\\*.txt\r\n-rw--w---- 1 {testuser} bilbo .*{dstfile}\r\n".format(**params)
+ if re.match(expected_dst_ls, results["dst_ls"]):
score += 2
else:
- hints += ["missing program"]
- expected_tita = u""
- if results["tita_return"] == expected_tita:
+ hints += [u"missing file or wrong user/permissions\n" + results["dst_ls"] + "\n" + expected_dst_ls]
+ if results["home_ls"].find(params['dstfile']) > -1:
score += 2
+ expected_mnts = [
+ "/dev/sdb2 on {mntdir} type ext4".format(**params),
+ "sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)",
+ "proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)",
+ "udev on /dev type devtmpfs (rw,nosuid,relatime,size=500680k,nr_inodes=125170,mode=755)",
+ "/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)",]
+ if all([results["mnt"].find(expected_mnt) > -1 for expected_mnt in expected_mnts]):
+ score += 3
else:
- hints += [u"program output incorrect\n" + results["tita_return"]]
+ hints += ["missing or wrong mount\n"]
return score, hints
@@ -272,7 +282,7 @@ def prepare_disks(templates, task_params, global_params):
# first create the file contents to make it easyer to check.
hidden_contents = task_params['magicstr']
r = random.Random(task_params['rndseed'])
- dstfile = "".join([r.choice("qQoOp") for i in range(48)]) + "I.txt"
+ dstfile = "".join([r.choice("qQoOp") for i in range(64)]) + "I.txt"
for i in range(1000):
x = "".join([r.choice(["po", "p0", "no", "ko", "fo", "qo"]) for i in range(20)])
x += "".join([r.choice("uiasdfghjkyxcvbnm1234567890ASDFGHJKYZXCVBNM") for i in range(60)])
@@ -280,26 +290,36 @@ def prepare_disks(templates, task_params, global_params):
hidden_contents += x + "\n"
# create hidden file
dir_list = ['Qlipper', 'Thunar', 'blender', 'autostart', 'kazam', 'mc', 'netsurf', 'pulse', 'qupzilla', 'radare2', 'teamviewer', 'texstudio', 'vlc']
- ending_list = ['rc', '.conf', '']
+ ending_list = ['rc', '.conf', '', '.txt']
start_list = ['net', 'dev', 'doc', 'lib', 'time', 'conf']
+ for i in range(20):
+ start_list.append("".join([r.choice("qQoOp") for i in range(64)]) + "O")
r.shuffle(dir_list)
file_letters = ["mod", "co"]
- d.mkdir('.hideme')
+ d.mkdir('/mnt/.hideme')
+ d.mkdir('/media/.hideme')
for potential_dir in dir_list:
try:
- potential_dir = os.path.join('.hideme', potential_dir)
- d.mkdir(potential_dir)
- d.chown(1001, 1001, potential_dir)
+ potential_dir1 = os.path.join('/mnt/.hideme', potential_dir)
+ potential_dir2 = os.path.join('/media/.hideme', potential_dir)
+ d.mkdir(potential_dir1)
+ d.chown(1001, 1001, potential_dir1)
+ d.mkdir(potential_dir2)
+ d.chown(1001, 1001, potential_dir2)
except:
pass
rndstr2 = dstfile
for i in range(r.randint(2, 20)):
- hidden_file_name = os.path.join(potential_dir,
+ hidden_file_name1 = os.path.join(potential_dir1,
+ rndstr2)
+ hidden_file_name2 = os.path.join(potential_dir2,
rndstr2)
- d.write(hidden_file_name, hidden_contents)
- d.chown(1001, 1001, hidden_file_name)
+ d.write(hidden_file_name1, hidden_contents)
+ d.chown(1001, 1001, hidden_file_name1)
file_letters = ["stamp", "", "dev", "re"]
hidden_contents = "".join([r.choice("asdfghjkyxcvbnm1234567890 \n") for j in range(10000)])
+ d.write(hidden_file_name2, hidden_contents)
+ d.chown(1001, 1001, hidden_file_name2)
rndstr2 = r.choice(start_list) + \
r.choice(file_letters) + r.choice(ending_list)
file_letters = file_letters + ["mod", "co"]
diff --git a/kpov_judge/web/kpov_judge/templates/task_greeting.html b/kpov_judge/web/kpov_judge/templates/task_greeting.html
index f188def..188145c 100644
--- a/kpov_judge/web/kpov_judge/templates/task_greeting.html
+++ b/kpov_judge/web/kpov_judge/templates/task_greeting.html
@@ -15,6 +15,7 @@
Računalniki v vaji
+
{% for c in computers %}
{{c['name']}}
{% if 'disk_urls' in c %}
--
cgit v1.2.1