diff options
Diffstat (limited to 'kpov_judge/tasks')
-rw-r--r-- | kpov_judge/tasks/copy_rename_20_files_tail_env/task.py | 55 | ||||
-rw-r--r-- | kpov_judge/tasks/custom_rdate/task.py | 2 | ||||
-rw-r--r-- | kpov_judge/tasks/openvpn_simple_smb/task.py | 5 | ||||
-rw-r--r-- | kpov_judge/tasks/set_motd/task.py | 2 | ||||
-rw-r--r-- | kpov_judge/tasks/snmp_agent_uptime/task.py | 2 |
5 files changed, 46 insertions, 20 deletions
diff --git a/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py b/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py index 504d102..b4f11ef 100644 --- a/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py +++ b/kpov_judge/tasks/copy_rename_20_files_tail_env/task.py @@ -22,9 +22,6 @@ V domači mapi najdeš imenik {file_rename_dirname} z 20 datotekami. Poleg tega naj program med sledenjem syslog-u odšteva od 5 do 1 (vsako sekundo naj se izpiše naslednja številka. Program naj bo v /home/student/syslog_ukaz.sh - Namesti paket "cowsay" in ga preizkusi :) - - Nastavi okoljsko spremenljivko TEST, da bo imela isto vrednost kot okoljska - spremenljivka USER + število okoljskih spremenljivk, ki v imenu ali -vrednosti ne vsebujejo besede TEST. Primer: polz37 - S pomočjo programa cURL preštej število pojavitev niza "images" v html kodi, ki jo dobiš na naslovu http://localhost/{curl_fname} na malishell in število zapiši v spremenljivko $images na simpleArbiter v lupini, kjer poganjaš @@ -52,15 +49,14 @@ In your home folder you will find a directory called {file_rename_dirname} In addition, the script should count down from 5 to 1 with a 1 second interval. Store the script in /home/student/syslog_ukaz.sh . - Install the packet "cowsay" and test it :) - - Set the variable TEST, which will have the same value as the - variable USER + the number of variables which do not include the name - TEST, for example polz37. - - With the help of cURL count the number of "images" string occurences in the - page accessible from malishell at http://localhost/{curl_fname}. + - With the help of cURL count the number of occurences of the string + "images" on the web page accessible from malishell at + http://localhost/{curl_fname}. On simpleArbiter within the shell where you are running test_task.py, set the environment variable $images to this number. - In the directory {wc_dirname} there is a file called count.txt. Write the - number of lines in this file into a file in the same directory. + number of lines in this file into the file lines.txt in the same + directory. """ } @@ -105,10 +101,15 @@ params_meta = { 'mv_dst_dir': {'descriptions': {'si': 'imenik, v katerega premakni datoteke'}, 'w': False, 'public':True, 'type': 'dirname', 'generated': True}, 'cowsay_string': {'descriptions': {'si': 'Kaj rece krava?'}, 'w': False, 'public':True, 'type': 'short', 'generated': True}, 'syslog_n_zmeda': {'descriptions': {'si': 'st. zapisov zmeda v 5s'}, 'w': False, 'public':True, 'type': 'uint', 'generated': True}, + 'curl_fname': {'descriptions': {'si': 'ime datoteke, dostopne prek http'}, 'w': False, 'public':True, 'type': 'filename', 'generated': True}, + 'curl_n_images': {'descriptions': {'si': 'n pojavitev niza images'}, 'w': False, 'public':False, 'type': 'integer', 'generated': True}, + 'wc_dirname': {'descriptions': {'si': 'imenik, v katerem je datoteka count.txt'}, 'w': False, 'public':True, 'type': 'dirname', 'generated': True}, + 'wc_n_lines': {'descriptions': {'si': 'n vrstic v count.txt'}, 'w': False, 'public':False, 'type': 'integer', 'generated': True}, } def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_string): import pxssh + import os # TODO: (polz) this has to be changed! Get a move on! # # sv: Z primozem lavricem sva skusala nekaj narediti @@ -169,6 +170,13 @@ def task(IP_malishell, file_rename_dirname, mv_src_dir, mv_dst_dir, cowsay_strin conn.sendline('cowsay "{}"'.format(cowsay_string)) conn.prompt() results['cowsay'] = conn.before + results['curl_env'] = os.environ['images'] + conn.sendline('cat {wc_dirname}/count.txt') + conn.prompt() + results['wc_origfile'] = conn.before + conn.sendline('cat {wc_dirname}/lines.txt') + conn.prompt() + results['wc_lines'] = conn.before conn.logout() #results['curl'] = subprocess.check_output(["cat","/home/student/Desktop/website.txt"]) @@ -195,6 +203,10 @@ def gen_params(user_id, params_meta): params['mv_dst_dir'] = homedir + "".join([r.choice("ijklmnop") for i in xrange(6)]) params['syslog_n_zmeda'] = str(r.randint(5, 15)) params['cowsay_string'] = kpov_random_helpers.default_generators['short_text'](r) + params['curl_fname'] = kpov_random_helpers.default_generators['filename'](r) + params['curl_n_images'] = str(r.randint(30,100)) + params['wc_dirname'] = homedir + "".join([r.choice("rstuvxz") for i in xrange(8)]) + params['wc_n_lines'] = str(r.randint(200, 600)) #params['phttp'] = "8080" #params['images'] = subprocess.check_output(["echo","$images"]) return params @@ -289,22 +301,22 @@ def prepare_disks(templates, params): r = random.Random(params['file_creator_random_seed']) # rename d.mkdir(params['file_rename_dirname']) - d.chown("student", "student", params['file_rename_dirname']) + d.chown(1000, 1000, params['file_rename_dirname']) for i in xrange(20): fname = params['file_rename_dirname'] + '/' + "".join( [r.choice("-abcdefghijk") for j in xrange(8)]) d.touch(fname) - d.chown("student", "student", fname) + d.chown(1000, 1000, fname) # mv ukaz d.mkdir(params['mv_src_dir']) - d.chown("student", "student", params['mv_src_dir']) + d.chown(1000, 1000, params['mv_src_dir']) for i in xrange(40): fname = params['mv_src_dir'] + '/' +"".join( [r.choice("123456789abcdefghijk") for j in xrange(8)]) d.touch(fname) - d.chown("student", "student", fname) + d.chown(1000, 1000, fname) d.mkdir(params['mv_dst_dir']) - d.chown("student", 'student', params['mv_dst_dir']) + d.chown(1000, 1000, params['mv_dst_dir']) # grep mama # mama fnames d.mkdir('/home/student/grep_test_dir') @@ -328,4 +340,17 @@ def prepare_disks(templates, params): # sledenje syslog spammer_source = "#!/bin/sh\n" + int(params['syslog_n_zmeda']) * "logger zmeda\n" d.write("/usr/local/bin/syslog_spammer", spammer_source) - d.chmod("0775", "/usr/local/bin/syslog_spammer") + d.chmod(0775, "/usr/local/bin/syslog_spammer") + # curl + l1 = ['images'] * int(params['curl_n_images']) + l2 = ['imeges'] * r.randint(30, 100) + lx = l1 + l2 + r.shuffle(lx) + d.write("/var/www/html/{}".format(params['curl_fname']), ''.join(lx)) + d.write("/var/www/html/{}".format(params['curl_fname']), ''.join(lx)) + # wc + lx = ['\n']*int(params['wc_n_lines']) + lx += ['a', 'b', 'c', 'repa', 'in', 'krompir', + 'raus', 'e', 'patacis'] * r.randint(50, 150) + r.shuffle(lx) + d.write("{}".format(params['wc_dirname']), "".join(lx)) diff --git a/kpov_judge/tasks/custom_rdate/task.py b/kpov_judge/tasks/custom_rdate/task.py index 1f73887..3a72b5d 100644 --- a/kpov_judge/tasks/custom_rdate/task.py +++ b/kpov_judge/tasks/custom_rdate/task.py @@ -167,4 +167,4 @@ t = time.time() + 2208988800 + offset sys.stdout.write(struct.pack("!I", int(t))) """ d.write('/usr/local/bin/kpovrdate', s2) - d.chmod('0775', '/usr/local/bin/kpovrdate') + d.chmod(0775, '/usr/local/bin/kpovrdate') diff --git a/kpov_judge/tasks/openvpn_simple_smb/task.py b/kpov_judge/tasks/openvpn_simple_smb/task.py index e530bf0..edaeef7 100644 --- a/kpov_judge/tasks/openvpn_simple_smb/task.py +++ b/kpov_judge/tasks/openvpn_simple_smb/task.py @@ -305,8 +305,9 @@ iface tap0 inet static templates['SimpleArbiterVPN'].write( "/srv/smb/" + fname + '.txt', kpov_random_helpers.fortune(r, 4096)) - templates['VPNClient1'].write("/home/student/" + keyfile, s) - templates['VPNClient1'].chown("student", "student", "/home/student/" + keyfile) + templates['VPNClient1'].write("/home/student/" + keyfile, s) + # uid, gid (student = ) + templates['VPNClient1'].chown(1000, 1000, "/home/student/" + keyfile) diff --git a/kpov_judge/tasks/set_motd/task.py b/kpov_judge/tasks/set_motd/task.py index b5d1b3c..3f24cb2 100644 --- a/kpov_judge/tasks/set_motd/task.py +++ b/kpov_judge/tasks/set_motd/task.py @@ -46,7 +46,7 @@ string you got in these instructions. computers = { 'SimpleArbiterDhcpGW': { 'disks': [ - { 'name': 'SimpleArbiterDhcpGW', + { 'name': 'simpleArbiterDhcpGW', }, ], 'flavor': 'm1.tiny', diff --git a/kpov_judge/tasks/snmp_agent_uptime/task.py b/kpov_judge/tasks/snmp_agent_uptime/task.py index 70cfa1b..b0c4dd9 100644 --- a/kpov_judge/tasks/snmp_agent_uptime/task.py +++ b/kpov_judge/tasks/snmp_agent_uptime/task.py @@ -214,4 +214,4 @@ elif action == '-n' and oid < ".{oid}": print "{val}" """.format(oid = params['SNMP_CLIENT_OID'], val = params['SNMP_VALUE']) templates['SNMPServer'].write('/usr/local/bin/snmpext.py', prog) - templates['SNMPServer'].chmod('766', '/usr/local/bin/snmpext.py') + templates['SNMPServer'].chmod(0766, '/usr/local/bin/snmpext.py') |