From 9c72d4b26bf6211833bc9e1e154fdeb45a889b7e Mon Sep 17 00:00:00 2001 From: "ss5781@student.uni-lj.si" Date: Tue, 3 Feb 2015 14:02:07 +0000 Subject: popravljanje prepare_disc v simple_smb git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@264 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/tasks/openvpn_simple_smb/task.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'kpov_judge/tasks') diff --git a/kpov_judge/tasks/openvpn_simple_smb/task.py b/kpov_judge/tasks/openvpn_simple_smb/task.py index d57804c..ce47d3f 100644 --- a/kpov_judge/tasks/openvpn_simple_smb/task.py +++ b/kpov_judge/tasks/openvpn_simple_smb/task.py @@ -265,12 +265,10 @@ def gen_params(user_id, params_meta): #(ime imenika kjer naj bo shranjena skupna skrivnost naj bo openvpn) #(HASH bo naključno generiran niz iz user_id s katerim se bo preverjalo plagiatorstvo) import random - r = Random.random(user_id) - net = kpov_random_helpers.IPv4_subnet_gen(r, '10.168.0.0', 24) + r = random.Random(user_id) + net = kpov_random_helpers.IPv4_subnet_gen(r, '10.168.0.0/16', 24) params['IP_VPNClient1'], params['IP_VPNClient2'], params['IP_VPNArbiter'] = kpov_random_helpers.IPv4_addr_gen(r, net, 3) params['DIRNAME'] = kpov_random_helpers.fname_gen(r, extension=False) - 'IP_VPNClient1': {'descriptions':{'si':'IP za 1. klienta'}, 'w': False, 'public': True, 'type': 'IP', 'generated': True}, - 'IP_VPNClient2': {'descriptions':{'si':'IP za 2. klienta'}, 'w': False, 'public': True, 'type': 'IP', 'generated': True}, params['secret_random_seed']=str(r.random()) return params @@ -307,14 +305,15 @@ def prepare_disks(templates, params): #guestmount -a d -m /dev/VG/LV -m /dev/sda1:/boot --ro /mnt #asistent je pocasnela :) + import random r = random.Random(params['secret_random_seed']) - s = "\n".[ + s = "\n".join([ "".join([r.choice("0123456789abcdef") for i in xrange(16)]) - for i in xrange(16)] + for i in xrange(16)]) s = """-----BEGIN OpenVPN Static Key V1----- {} -----END OpenVPN Static Key V1----- -""" +""".format(s) keyfile = kpov_random_helpers.fname_gen(r, extension=False) + ".key" templates['SimpleArbiterVPN'].write("/etc/openvpn/secret.key", s) netaddr_s = """auto tap0 @@ -322,6 +321,7 @@ iface tap0 inet static address {} netmask 255.255.255.0 """.format(params['IP_VPNArbiter']) - templates['SimpleArbiterVPN'].write_a("/etc/network/interfaces", netaddr_s) - templates['VPNClient1'].write("/home/tester/" + keyfile, s) + templates['SimpleArbiterVPN'].write_append("/etc/network/interfaces", netaddr_s) + templates['VPNClient1'].write("/home/student/" + keyfile, s) + templates['VPNClient1'].chown("student", "student", "/home/student/" + keyfile) -- cgit v1.2.1