summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/custom_rdate
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-24 21:05:27 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-24 21:05:27 +0100
commit8081a5520a441b43a8a7a73f3a90c7aacfaa8e10 (patch)
treec7f49bd33ed19d53afc0ee9df8b2c82c200c5910 /kpov_judge/tasks/custom_rdate
parent9963b74f777edf985540eac71b1ca095f88b8bca (diff)
Move everything one level up
Diffstat (limited to 'kpov_judge/tasks/custom_rdate')
-rw-r--r--kpov_judge/tasks/custom_rdate/CustomRDate.java21
-rw-r--r--kpov_judge/tasks/custom_rdate/TejoLicen/rServe.zipbin499 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/en/index.html65
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu1.pngbin979 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu15.pngbin679 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu2.pngbin826 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu3.pngbin13656 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu4.pngbin1564 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu5.pngbin11278 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu6.pngbin15244 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu7.pngbin3842 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu8.pngbin3420 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/bu9.pngbin4245 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/predvaja_clip_image003.gifbin686 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/s1.pngbin700 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/s2.pngbin3882 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/images/s3.pngbin3569 -> 0 bytes
-rw-r--r--kpov_judge/tasks/custom_rdate/howtos/si/index.html67
-rw-r--r--kpov_judge/tasks/custom_rdate/rDate.java34
-rw-r--r--kpov_judge/tasks/custom_rdate/rDate.py18
-rw-r--r--kpov_judge/tasks/custom_rdate/task.py146
21 files changed, 0 insertions, 351 deletions
diff --git a/kpov_judge/tasks/custom_rdate/CustomRDate.java b/kpov_judge/tasks/custom_rdate/CustomRDate.java
deleted file mode 100644
index 426dece..0000000
--- a/kpov_judge/tasks/custom_rdate/CustomRDate.java
+++ /dev/null
@@ -1,21 +0,0 @@
-import java.io.InputStream;
-import java.net.Socket;
-import java.nio.ByteBuffer;
-import java.util.Date;
-
-public class CustomRDate {
- public static void main(String main[]) throws Exception{
- try {
- Socket s = new Socket("ntp1.arnes.si", 37);
- InputStream vhod = s.getInputStream();
- byte podatek[] = new byte[8];
- int dejanskoPrebranih = vhod.read(podatek, 4, 4);
- ByteBuffer buf = ByteBuffer.wrap(podatek);
- long stevilka = buf.getLong() - 2208988800L;
- Date d = new Date(stevilka*1000);
- System.out.println(d);
- } catch(Exception e) {
- System.out.println("Nedosegljiv streznik.");
- }
- }
-} \ No newline at end of file
diff --git a/kpov_judge/tasks/custom_rdate/TejoLicen/rServe.zip b/kpov_judge/tasks/custom_rdate/TejoLicen/rServe.zip
deleted file mode 100644
index 9061692..0000000
--- a/kpov_judge/tasks/custom_rdate/TejoLicen/rServe.zip
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/en/index.html b/kpov_judge/tasks/custom_rdate/howtos/en/index.html
deleted file mode 100644
index 18ebfc1..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/en/index.html
+++ /dev/null
@@ -1,65 +0,0 @@
-<!doctype html>
-<html>
-<head>
- <meta charset="utf-8">
- <style>
- img{
- margin:10px 0px 10px 0px;
- }
- </style>
-</head>
-
-<body>
- <h1>Custom rdate</h1>
- <h2>Short preview:</h2>
- Set time on server using rdate. Write a program that converts 32-bit numbers into a readable time format.</p>
- <h2>Instructions:</h2>
- 1. Downlaod Student.vdi (client) and SimpleArbiter.vdi (server) from the virtual machine images folder<br>
- 2. Use VirtualBox (or similar) to create two virtual machines, select the virtual disk images from the previous step as hard drives<br>
- 3. Run both virtual machines.<br>
- 4. Login on client user:<strong> root</strong> pass:<strong> kaboom </strong> and server user:<strong> tester</strong> pass:<strong> tester</strong></p>
- <img src="../images/bu15.png">
- <img src="../images/bu1.png">
- <h3>First part: update time using rdate.</h3>
- <p>
- 1. Find and remember your server IP address. (ifconfig)<br><img src="../images/bu2.png"><br><img src="../images/bu3.png"><br>
- 2. Install rdate with <strong>sudo apt-get install</strong> rdate<br>
- 3. On Student client use rdate to update the machine time <strong>rdate SERVER_IP</strong><br><img src="../images/bu4.png"><br>
- Note: It's NOT an error if the updated time does not match the correct time.<br>
- </p>
- <h3>Second part: write a program that converts 32bit numbers into a readable time format.</h3>
- <p>
- You can write a program in Java or Python using your favourite text editor.
- </p>
- <h4>Java</h4>
- <p>
- 1. We use <strong>nano guliver.java</strong> to create a new blank file<br>
- 2. Write a program that converts 32bit numbers into a readable time format.<br>
- <img src="../images/bu6.png"><br><img src="../images/bu7.png"><br>
- 3. Press Ctrl+X, then Y and Enter to save the program<br>
- 4. In case you don't have java installed use <strong>sudo apt-get install openjdk-6-jdk</strong><br>
- <img src="../images/predvaja_clip_image003.gif"><br>
- 5. To compile use <strong>javac bintodec3.java</strong><br>
- 6. Run the created program with <strong>java guliver</strong> and input the server IP or name...<br>
- <img src="../images/bu9.png"><br>
- </p>
- <h4>Python</h4>
- 1. Use nano guliver.py to create a new empty python file.<br>
- 2. Write a program that converts 32bit numbers into a readable time format.<br>
- <img src="../images/bu5.png"><br>
- 3. Press Ctrl+X, then Y and Enter to save our program<br>
- 4. Run the created program with <strong>python guliver.py</strong><br><img src="../images/bu8.png"><br>
- </p>
- <h3>Testing</h3>
- <p>
- 1. Use command ./run_test.py to run the tester<br>
- <img src="../images/s1.png"><br>
- 2. Your username and password are the same as on ucilnica (npr.: "pz1234@student.uni-lj.si" in "geslo123").<br>
- <img src="../images/s2.png"> <img src="../images/s3.png"> <br>
- 3. Name of the task should look like 09.predvaja.<br>
- 4. When prompted for file path insert your program path (example: if bintodec3.py is in the same folder as program run_test.py run with ./bintodec3.py).<br>
- 5. Then input your server IP address (SimpleArbiterRDate).<br>
- 6. If all goes well the program should give you an OK that means you've completed your task successfully.
- </p>
-</body>
-</html>
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu1.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu1.png
deleted file mode 100644
index c6eeac8..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/bu1.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu15.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu15.png
deleted file mode 100644
index c2ac808..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/bu15.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu2.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu2.png
deleted file mode 100644
index 85fcfa8..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/bu2.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu3.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu3.png
deleted file mode 100644
index 831e764..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/bu3.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu4.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu4.png
deleted file mode 100644
index 495351a..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/bu4.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu5.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu5.png
deleted file mode 100644
index 103e0e6..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/bu5.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu6.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu6.png
deleted file mode 100644
index b032223..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/bu6.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu7.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu7.png
deleted file mode 100644
index bd50500..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/bu7.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu8.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu8.png
deleted file mode 100644
index 98f7812..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/bu8.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/bu9.png b/kpov_judge/tasks/custom_rdate/howtos/images/bu9.png
deleted file mode 100644
index 9ed78ce..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/bu9.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/predvaja_clip_image003.gif b/kpov_judge/tasks/custom_rdate/howtos/images/predvaja_clip_image003.gif
deleted file mode 100644
index 02be389..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/predvaja_clip_image003.gif
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/s1.png b/kpov_judge/tasks/custom_rdate/howtos/images/s1.png
deleted file mode 100644
index 52b6ee5..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/s1.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/s2.png b/kpov_judge/tasks/custom_rdate/howtos/images/s2.png
deleted file mode 100644
index 78a65ce..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/s2.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/images/s3.png b/kpov_judge/tasks/custom_rdate/howtos/images/s3.png
deleted file mode 100644
index c32eae1..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/images/s3.png
+++ /dev/null
Binary files differ
diff --git a/kpov_judge/tasks/custom_rdate/howtos/si/index.html b/kpov_judge/tasks/custom_rdate/howtos/si/index.html
deleted file mode 100644
index e68221c..0000000
--- a/kpov_judge/tasks/custom_rdate/howtos/si/index.html
+++ /dev/null
@@ -1,67 +0,0 @@
-<!doctype html>
-<html>
-<head>
- <meta charset="utf-8">
- <style>
- img{
- margin:10px 0px 10px 0px;
- }
- </style>
-</head>
-
-<body>
- <h1>Custom rdate</h1>
- <h2>Naloga na hitro:</h2>
- <p>
- Nastavi uro na strežniku s pomočjo rdate. Napiši program, ki pretvori 32-bitna števila v čas.
- </p>
- <h2>Navodila:</h2>
- <p>
- 1. Z imenika s slikami virtualnih računalnikov povlecite sliki Student.vdi(klient) in SimpleArbiterRDate.vdi(strežnik).<br>
- 2. Z VirtualBoxom (ali podobnim) ustvarite dva virtualna računalnika in jim kot disk za shranjevanje podajte Student.vdi ter SimpleArbiterRDate.vdi.<br>
- 3. Zaženite oba navidezna računalnika.<br>
- 4. Na Student se prijavite z uporabnikom <strong>root</strong> in geslom <strong>kaboom</strong>
- na SimpleArbiterRDate pa z uporabnikom <strong>tester</strong> in geslom <strong>tester</strong>.
- </p>
- <img src="../images/bu15.png"> <img src="../images/bu1.png">
- <h3>Prvi del naloge: posodobi uro računalnika s pomočjo rdate.</h3>
- <p>
- 1. Preverite in si zapišite IP naslov na SimpleArbiterRDate. (ifconfig)<br><img src="../images/bu2.png"><br><img src="../images/bu3.png"><br>
- 2. Z ukazom <strong>sudo apt-get install</strong> rdate namestimo program rdate.<br>
- 3. Na Student z pomočjo rdate posodobi uro računalnika. <strong>rdate IP_SIMPLE_ARBITER</strong><br><img src="../images/bu4.png"><br>
- Opozorilo: NI napaka, če se posodobljen čas ne ujema s pravilnim časom. <br>
- </p>
- <h3>Drugi del naloge: napiši program, ki pretvori binarni zapis 32-bitnega števila v časovni format.</h3>
- <p>
- Nalogo lahko rešite v Javi ali v Pythonu. Prav tako pa lahko kodo pišete v poljubnem tekstovnem urejevalniku.</p>
- <p>
- <h4>Java</h4>
- <p>
- 1. Z ukazom nano guliver.java ustvarimo in odpremo prazen program s tekstovnim urejevalnikom nano<br>
- 2. Napišemo program za pretvarjanje 32-bitnega števila v čas<br>
- 3. Pritisnemo Ctrl+X, nato Y in Enter, da program zapremo in shranimo.<br>
- 4. Če je še nimamo, naložimo Javo <strong>sudo apt-get install openjdk-6-jdk</strong><br><im src="../images/predvaja_clip_image003.gif"><br>
- 5. Prevedemo program <strong>javac bintodec3.java</strong><br>
- 6. Lahko ga še zaženemo ter preizkusimo <strong>java guliver</strong>.Na standardni vhod vnasemo IP naslov ali ime strežnika NTP strežnikom, ki nam pošlje 32 bitno število in pretvori v čas<br><br>
- </p>
- <h4>Python</h4>
- <p>
- 1. Z ukazom nano guliver.py ustvarimo in odpremo prazen program s tekstovnim urejevalnikom nano<br>
- 2. Napišemo program za pretvarjanje 32-bitnega števila v čas<br>
- 3. Pritisnemo Ctrl+X, nato Y in Enter, da program zapremo in shranimo.<br>
- 4. Program zaženemo z ukazom <strong>python guliver.py</strong><br><img src="../images/bu8.png"><br>
- </p>
-
- <h3>Testiranje</h3>
- <p>
- 1. Lahko poženemo tester; z ukazom ./run_test.py<br>
- <img src="../images/s1.png"><br>
- 2. Kot "Upor. Ime" in "Geslo" napišite vaše podatke učilnice. (npr.: "pz1234@student.uni-lj.si" in "geslo123")<br>
- <img src="../images/s2.png"> <img src="../images/s3.png"> <br>
- 3. Kot ime naloge vpišite 09.predvaja.<br>
- 4. Ko vas program vpraša po poti programa vnesite vašo pot do programa za pretvarjanje. (npr.: če imate program bintodec3.py v isti mapi kot program run_test.py, vnesete: ./bintodec3.py)<br>
- 5. Povpraša tudi po IP naslovu SimpleArbiterjaRDate, vnesite.<br>
- 6. Če je šlo vse po sreči, program vrne OK vi pa ste opravili nalogo.
- </p>
-</body>
-</html>
diff --git a/kpov_judge/tasks/custom_rdate/rDate.java b/kpov_judge/tasks/custom_rdate/rDate.java
deleted file mode 100644
index 8c8bae7..0000000
--- a/kpov_judge/tasks/custom_rdate/rDate.java
+++ /dev/null
@@ -1,34 +0,0 @@
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.net.Socket;
-import java.net.SocketException;
-import java.nio.ByteBuffer;
-import java.uti.Date;
-import java.util.Scanner;
-
-public class rDate{
-
- public static void main(String[] args) throw IOException{
- Scanner sc=new Scanner(System.in);
- String niz=sc.next();
-
- try{
- Socket s=new Socket(niz,37);
- OutputStreamWriter izhod=new OutputStreamWriter(s.getOutputStream());
- InputStream vhod=s.getInputStream();
- byte[] podatek=new byte[4];
- ByteBuffer buf=ByteBuffer.wrap(podatek);
- int stevilka=buf.getInt();
- long dolga=stevilka
- long maska=-1;
- maska =~(maska <<32);
- dolga = dolga & maska;
- Date d=new Date(dolga *1000 - 2208988800000L);
- System.out.print(d);
- izhod.write(d.toString());
- }catch(SocketException e){
- System.out.println("Strežnik ne obstaja");
- }
- }
-}
diff --git a/kpov_judge/tasks/custom_rdate/rDate.py b/kpov_judge/tasks/custom_rdate/rDate.py
deleted file mode 100644
index 97885b0..0000000
--- a/kpov_judge/tasks/custom_rdate/rDate.py
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#!/usr/bin/env python
-#-*- coding utf-8 -*-
-
-import socket
-import struct
-import time
-
-niz=input("Vnesi IP ali ime strežnika:")
-s = socket.socket(
- socket.AF_Inet, socket.SOCK_STREAm)
-s.connect((niz,37))
-podatek = s.recv(4)
-stevilka = struct.unpack("!I", podatek)
-st= stevilka[0]-220898800
-date = time.localtime(st)
-print((time.strftime('%Y-%m-%d %H:%M:%S'), date))
-s.send(date)
diff --git a/kpov_judge/tasks/custom_rdate/task.py b/kpov_judge/tasks/custom_rdate/task.py
deleted file mode 100644
index 4c5ff9f..0000000
--- a/kpov_judge/tasks/custom_rdate/task.py
+++ /dev/null
@@ -1,146 +0,0 @@
-# kpov_util should be imported by add_assignment.py
-
-# TODO: finish this!
-instructions = {
- 'si': '''\
-<p>
-Postavite dva navidezna računalnika: <em>SimpleArbiterDhcpRdate</em> in <em>rdateClient</em>.
-
-<p>
-Nastavite čas na <em>rdateClient</em> tako, da kot rdate strežnik uporabite <em>SimpleArbiterDhcpRdate</em>.
-
-<p>
-Na <em>rdateClient</em> ustvarite uporabnika <code>test</code> z geslom <code>test</code>. V domačem imeniku uporabnika <code>test</code> ustvarite program z imenom <code>{{PROGRAM_FILENAME}}</code>. Program naj prebere štiri bajte podatkov s standardnega vhoda in jih pretvori v predznačeno celo število, pri čemer naj uporablja zapis z debelim koncem (angl. <em lang="en">big endian</em>). Število naj program izpiše na standardni izhod v obliki niza.
-''',
- 'en': '''\
-<p>
-Set up two virtual machines: <em>SimpleArbiterDhcpRdate</em> and <em>rdateClient</em>.
-
-<p>
-Set the time on <em>rdateClient</em> using rdate with <em>SimpleArbiterDhcpRdate</em> as
-the server.
-
-<p>
-On <em>rdateClient</em> create a user with the username <code>test</code> and password <code>test</code>. Then, write a program called <code>{{PROGRAM_FILENAME}}</code> and put it in user <code>test</code>’s home directory. The program should read four bytes of data from standard input, convert them into a signed integer using big endian byte ordering and output the resulting integer (as a string) to standard output.
-''',
-}
-
-computers = {
- 'rdateClient': {
- 'disks': [
- { 'name': 'student-rdate',
- },
- ],
- 'network_interfaces': [{'network': 'net1'}],
- 'flavor': 'm1.tiny',
- 'config_drive': False
-
- },
- 'SimpleArbiter': {
- 'disks': [
- { 'name': 'simpleArbiterDhcpGWRdate',
- },
- ],
- 'network_interfaces': [{'network': 'net1'}, {'network': 'test-net'}],
- 'flavor': 'm1.tiny',
- 'config_drive': False
- }
-}
-
-networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
-
-# Tu sem dolocil parametre
-params_meta = {
- 'RDATE_OFFSET':{'descriptions': {'si': 'Napaka v času pri rdate', 'en': 'Timekeeping error for rdate'}, 'w': False, 'public': False, 'type': 'integer', 'generated': True},
- 'PROGRAM_FILENAME':{'descriptions': {'si': 'Ime programa', 'en': 'program filename'}, 'w': False, 'public': True, 'type': 'integer', 'generated': True},
- 'IP_RDATECLIENT':{'descriptions': {'si': 'IP rdateClient', "en": "rdateClient's IP"}, 'w': True, 'public': True, 'type': 'IP', 'generated': False},
-}
-
-def task(IP_RDATECLIENT, PROGRAM_FILENAME):
- import collections
- import base64
- import random
- import struct
- import pexpect
-
- r = random.Random(PROGRAM_FILENAME)
- results = collections.defaultdict(str)
- tests = []
- for i in range(10):
- data = struct.pack("!I", r.randint(0, 2**32))
- results['in_'+str(i)] = data_ascii = base64.encodestring(data)
- tests += [('out_'+str(i), 'echo "{}" | base64 -d | ~/{}'.format(data_ascii.decode().strip(), PROGRAM_FILENAME))]
- tests += [('date', 'date -u +"%s"')]
-
- results.update(
- kpov_util.ssh_test(IP_RDATECLIENT, 'test', 'test', tests))
- results['ldate'] = pexpect.run('date -u +"%s"')
-
- return results
-
-#Dolocil sem tri parametre in sicer jih lahko vidite v prams_meta,
-#zato prosim da jih upostevate v naslednih nalogah.
-
-def gen_params(user_id, params_meta):
- import socket
- import struct
- import datetime
- params = dict()
- r = random.Random(user_id)
- params['PROGRAM_FILENAME'] = kpov_util.fname_gen(r, False)
- params['RDATE_OFFSET'] = str(r.randint(-2**24, 2**24))
- return params
-
-def task_check(results, params):
- import random
- import struct
- import base64
-
- r = random.Random(params['PROGRAM_FILENAME'])
- score = 0.0
- hints = []
- for i in range(10):
- data = base64.decodestring(results['in_' + str(i)])
- x = struct.pack("!I", r.randint(0, 2**32))
- if data != x:
- hints += ["data: " + str((data,)) + " != " + str((x,))]
- break
- res = results['out_' + str(i)]
- if str(struct.unpack("!i", data)[0]) == res.strip():
- score += 0.5
- else:
- hints += ["wrong convert"]
-
- if abs(int(results['ldate']) + \
- int(params['RDATE_OFFSET']) - int(results['date'])) < 3:
- score += 5
- else:
- hints += ["wrong offset"]
- return score, hints
-
-def prepare_disks(templates, task_params, global_params):
- d = templates['simpleArbiterDhcpGWRdate']
- s1 = """service "time_tcp" {{
- enabled yes;
- protocol tcp;
- port "time";
- user "nobody";
- exec "/usr/local/bin/kpovrdate {RDATE_OFFSET}";
- server "/usr/sbin/tcpd";
- wait no;
-}}
-""".format(**task_params)
- d.write('/etc/rlinetd.d/time', s1)
- s2 = """#!/usr/bin/python
-
-import struct
-import time
-import sys
-
-offset = int(sys.argv[1])
-t = time.time() + offset # used to have + 2208988800
-sys.stdout.write(struct.pack("!I", int(t)))
-"""
- d.write('/usr/local/bin/kpovrdate', s2)
- d.chmod(0o775, '/usr/local/bin/kpovrdate')
- write_default_config(templates['simpleArbiterDhcpGWRdate'], global_params)