summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'kpov_judge/tasks')
-rw-r--r--kpov_judge/tasks/openvpn_simple_smb/task.py18
1 files changed, 9 insertions, 9 deletions
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)