From b1b0d75831b3d81c41549358dde122b9fba0c054 Mon Sep 17 00:00:00 2001 From: "gasperfele@fri1.uni-lj.si" Date: Thu, 23 Mar 2017 07:40:07 +0000 Subject: the edit_find_grep_compile_convert task now works git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@407 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/tasks/ldap_search/task.py | 51 ++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'kpov_judge/tasks/ldap_search/task.py') diff --git a/kpov_judge/tasks/ldap_search/task.py b/kpov_judge/tasks/ldap_search/task.py index 6889b13..0e906ae 100644 --- a/kpov_judge/tasks/ldap_search/task.py +++ b/kpov_judge/tasks/ldap_search/task.py @@ -15,25 +15,22 @@ Na LDAPServer namesti strežnik LDAP. Strežnik naj skrbi za domeno DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si V imeniku ustvari uporabnika -CN={LDAP_USERNAME},ou=Users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si +CN={LDAP_USERNAME},ou=users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si z geslom {LDAP_PASSWORD} in uporabnika -CN={BIND_USERNAME},ou=Users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si +CN={BIND_USERNAME},ou=users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si z geslom {BIND_PASSWORD} Poskrbi, da se bo lahko klient s simpleArbiterDhcp povezal na LDAP strežnik na LDAPServer. V primeru, da se klient poveže kot {BIND_USERNAME} z geslom {BIND_PASSWORD}, naj strežnik omogoči spreminjanje podatkov za objekt -CN={LDAP_USERNAME},ou=Users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si +CN={LDAP_USERNAME},ou=users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si ter ustvarjanje novih objektov v DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si CN = Common Name +O = Organization OU = Organizational Unit DC = Domain Component - -Na SimpleArbiter ustvari program, ki bo s pomočjo ldapsearch izpisal seznam lastnosti (otrok), -ki jih ima poljuben objekt v domeni {DOMAIN}.kpov.lusy.fri.uni-lj.si. -Ime objekta (CN) naj program sprejme kot prvi argument. """, 'en': u""" Create two virtual machines - SimpleArbiter using the disk simpleArbiterDhcp @@ -43,10 +40,10 @@ Set up an LDAP server on LDAPServer. Make it responsible for DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si Create a user -CN={LDAP_USERNAME},ou=Users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si +CN={LDAP_USERNAME},ou=users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si with the password {LDAP_PASSWORD} and a user -CN={BIND_USERNAME},ou=Users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si +CN={BIND_USERNAME},ou=users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si with the password {LDAP_PASSWORD} . @@ -54,16 +51,14 @@ Make sure that a client from simpleArbiterDhcp can connect to the LDAP server on LDAPServer. If the client identifies themself as {BIND_USERNAME} with the password {BIND_PASSWORD}, allow it to change data for the object -CN={LDAP_USERNAME},ou=Users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si +CN={LDAP_USERNAME},ou=users,DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si and to create objects in DC={DOMAIN},DC=kpov,DC=lusy,DC=fri,DC=uni-lj,DC=si CN = Common Name +O = Organization OU = Organizational Unit DC = Domain Component -Create a program on SimpleArbiter which will use ldapsearch to output the list of properties -(children) of an arbitrary object under {DOMAIN}.kpov.lusy.fri.uni-lj.si. -The program will be given the CN of the object as it's first argument. """ } @@ -115,7 +110,7 @@ def task(LDAP_IP, DOMAIN, LDAP_USERNAME, LDAP_PASSWORD, BIND_USERNAME, BIND_PASS results = dict() FULLDOMAIN = "dc={DOMAIN},dc=kpov,dc=lusy,dc=fri,dc=uni-lj,dc=si".format( **locals()) - BIND_DN = "uid={BIND_USERNAME},ou=Users,{FULLDOMAIN}".format(**locals()) + BIND_DN = "cn={BIND_USERNAME},ou=Users,{FULLDOMAIN}".format(**locals()) s = "ldapsearch -D {BIND_DN} -b {FULLDOMAIN} -w {BIND_PASSWORD}\ -h {LDAP_IP}".format( **locals()) @@ -123,10 +118,10 @@ def task(LDAP_IP, DOMAIN, LDAP_USERNAME, LDAP_PASSWORD, BIND_USERNAME, BIND_PASS s = "ldapmodify -D {BIND_DN} -w {BIND_PASSWORD} -h {LDAP_IP}".format( **locals()) modify = pexpect.spawn(s) - FORTUNE = kpov_random_helpers.fortune(random.Random(), 20) - results['FORTUNE'] = FORTUNE + FORTUNE = kpov_random_helpers.hostname_gen(random.Random(str(LDAP_USERNAME))) + results['fortune'] = FORTUNE s1 = """ -dn: uid={LDAP_USERNAME},ou=Users,{FULLDOMAIN} +dn: cn={LDAP_USERNAME},ou=Users,{FULLDOMAIN} changetype: modify replace: description description: {FORTUNE} @@ -154,38 +149,38 @@ def task_check(results, params): import re score = 0 hints = [] - s = """.*dn: dc={DOMAIN},dc=kpov,dc=lusy,dc=fri,dc=uni-lj,dc=si\r + s = """.*dn: dc={DOMAIN},dc=kpov,dc=lusy,dc=fri,dc=uni-lj,dc=si\r[^#]* objectClass: top\r objectClass: dcObject\r objectClass: organization\r .*""".format(**params) #dc: {DOMAIN}\r - fortune = results['FORTUNE'] if re.match(s, results['ldapsearch_before'], re.DOTALL): score += 2 else: - hints += [s + str(results['ldapsearch_before'])] - s = ".*uid: {}.*".format(re.escape(params['LDAP_USERNAME'])) + hints += ["domain missing in ldapsearch result"] + s = ".*cn: {}.*".format(re.escape(params['LDAP_USERNAME'])) if re.search(s, results['ldapsearch_before']): score += 2 else: - hints += [s + str(results['ldapsearch_before'])] - s = ".*uid: {0}.*description: {1}.*".format( - re.escape(params['LDAP_USERNAME']), re.escape(fortune[:40])) + hints += ["LDAP_USERNAME missing in: " + s + str(results['ldapsearch_before'])] + fortune = kpov_random_helpers.hostname_gen(random.Random(str(params['LDAP_USERNAME']))) + s = ".*cn: {0}.*description: {1}.*".format( + re.escape(params['LDAP_USERNAME']), re.escape(fortune)) if re.match(s, results['ldapsearch_after'], re.DOTALL): score += 2 else: - hints += [s + str(results['ldapsearch_after'])] + hints += ["description missing after update:" + fortune + "\n" + s + str(results['modify']) + str(results['ldapsearch_after'])] if results['ldapsearch_before'][:100] == results['ldapsearch_after'][:100]: score += 2 else: - hints += ["ldapsearch wrong"] - s = '.*\r\nmodifying entry "uid={LDAP_USERNAME},ou=Users,dc={DOMAIN},dc=kpov,dc=lusy,dc=fri,dc=uni-lj,dc=si".*'.format( + hints += ["ldapsearch before equals after. This should not happen."] + s = '.*\r\nmodifying entry "cn={LDAP_USERNAME},ou=Users,dc={DOMAIN},dc=kpov,dc=lusy,dc=fri,dc=uni-lj,dc=si".*'.format( **params) if re.match(s, results['modify'], re.DOTALL): score += 2 else: - hints += [s + str(results['modify'])] + hints += ['Modify error' + s + str(results['modify'])] return score, hints def prepare_disks(templates, task_params, global_params): -- cgit v1.2.1