summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks
diff options
context:
space:
mode:
authorzg4121@student.uni-lj.si <zg4121@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2017-09-19 10:59:00 +0000
committerzg4121@student.uni-lj.si <zg4121@student.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2017-09-19 10:59:00 +0000
commit750e2dcf8a893b991fe248f08793e244d67875c7 (patch)
tree768f2cb1084377d2db031079a8e610f8087c8959 /kpov_judge/tasks
parent74231387438c0faeb12763afaf53c87482408696 (diff)
popravil sem nalogo dhcp_dns_predefined_ip zan gostic
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@420 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks')
-rw-r--r--kpov_judge/tasks/dhcp_dns_predefined_ip/task.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
index 890c7d0..e46e6b8 100644
--- a/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
+++ b/kpov_judge/tasks/dhcp_dns_predefined_ip/task.py
@@ -76,14 +76,10 @@ def task(IP_server, IP_client, MAC_client, HOSTNAME_X):
sA.login(IP_server, peer_user, peer_passwd)
#prijavimo se na klienta (IP_static je IP naslov klienta)
sB.login(IP_client, peer_user, peer_passwd)
- # tukaj dobimo podatke iz streznika ce je res klientu dodelil pravi naslov
- # mogoce tail -5 ni potreben ampak sem razmisljal da bi bilo hitreje, ce bi preverjali samo
- # zadnjih 5 DHCPACK vnosov
- sA.sendline('sudo grep DHCPACK /var/log/syslog | tail -5')
- # in ker gre za sudo ukaz posljemo se geslo uporabnika v tem primeru gre za uporabnika student
+ sA.sendline('sudo ps -A')
sA.sendline(peer_passwd)
sA.prompt()
- results['client_IP'] = sA.before
+ results['dhcp_proces'] = sA.before
# tukaj dobimo podatke, ce je na IP_NM naslovu res postavljen DHCP streznik
sB.sendline('sudo dhcping -s {} -h {} -c {}'.format(IP_server, MAC_client, IP_client))
sB.sendline(peer_passwd)
@@ -93,6 +89,9 @@ def task(IP_server, IP_client, MAC_client, HOSTNAME_X):
sB.sendline('nslookup {}'.format(HOSTNAME_X))
sB.prompt()
results['dns_hostname'] = sB.before
+ sB.sendline('/sbin/ifconfig')
+ sB.prompt()
+ results['client_IP'] = sB.before
sA.logout()
sB.logout()
return results
@@ -111,21 +110,26 @@ def task_check(results, params):
import re
score = 0
hints = []
- # ker je v results[dhcp] shranjen ukaz za dobivanje teh podatkov, kot tudi odgovor streznika
- # mora biti stevilo pojavitev streznikovega IP naslova (IP_NM) enako ali vecje od 2
- # enkrat se zagotovo pojavi v ukazu in nato se mora vsaj se enkrat pojaviti tudi v odgovoru
- if results['dhcp'].count(params['IP_server']) >= 2:
+ if results['dhcp'].find("Got answer from: {}".format(params['IP_server'])) > -1:
+ score += 2
+ else:
+ hints += ["dhcp server IP wrong"]
+ if results['dhcp_proces'].find("dhcpd") > -1:
score += 2
else:
hints += ["dhcp wrong"]
- if results['client_IP'].find("DHCPACK on " + params['IP_client'] + " to " + params['MAC_client']) >= 0:
- score += 3
+ if results['dns_hostname'].find("Address: {}".format(params['IP_X'])) >= 0:
+ score += 2
else:
- hints += ["client IP wrong"]
- if results['dns_hostname'].find(params['IP_X']) >= 0:
- score += 5
+ hints += ['dns hostname IP wrong']
+ if results['dns_hostname'].find("Server:\t\t{}".format(params['IP_server'])) > -1:
+ score += 2
+ else:
+ hints += ['dns server IP wrong']
+ if results['client_IP'].find('inet {}'.format(params['IP_client'])) > -1:
+ score += 2
else:
- hints += ['dns wrong']
+ hints += ['client IP wrong']
return score, hints