summaryrefslogtreecommitdiff
path: root/kpov_judge/tasks/radius_mysql_pam
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-01-20 06:51:53 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-01-20 06:51:53 +0000
commitccddccc70d213c797cc5bd89fece64ecf196819c (patch)
tree0d9efd2f234c1bd275a5c10adf2d1a0234f517c7 /kpov_judge/tasks/radius_mysql_pam
parent9a4a0fc127db7d81aacf297c3e2cfbdb1fbc2817 (diff)
fixed indent in radius_mysql_pam/task.py
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@214 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge/tasks/radius_mysql_pam')
-rw-r--r--kpov_judge/tasks/radius_mysql_pam/task.py48
1 files changed, 21 insertions, 27 deletions
diff --git a/kpov_judge/tasks/radius_mysql_pam/task.py b/kpov_judge/tasks/radius_mysql_pam/task.py
index 70b1180..2e330cf 100644
--- a/kpov_judge/tasks/radius_mysql_pam/task.py
+++ b/kpov_judge/tasks/radius_mysql_pam/task.py
@@ -58,15 +58,15 @@ computers = {
networks = { 'net1': {'public': False}, 'test-net': {'public': True} }
params_meta = {
- 'IP_RS': {'descriptions': {'si': 'Naslov RadiusServer'}, 'w': False, 'public':True, 'type': 'IP', 'generated': True},
+ 'IP_RS': {'descriptions': {'si': 'Naslov RadiusServer'}, 'w': False, 'public':True, 'type': 'IP', 'generated': True},
'RADIUS_SECRET':{'descriptions': {'si': 'Skrivnost RADIUS'}, 'w': False, 'public':True, 'type': 'passwd', 'generated': True},
'RADIUS_USERNAME': {'descriptions': {'si': 'Username v RADIUS'}, 'w': True, 'public':True, 'type': 'username', 'generated': False},
'RADIUS_PASSWORD': {'descriptions': {'si': 'Geslo v RADIUS'}, 'w': False, 'public':True, 'type': '', 'generated': True},
- 'MYSQL_DB_NAME': {'descriptions': {'si': 'Ime baze v mysql'}, 'w': True, 'public':True, 'type': '', 'generated': False},
+ 'MYSQL_DB_NAME': {'descriptions': {'si': 'Ime baze v mysql'}, 'w': True, 'public':True, 'type': '', 'generated': False},
'MYSQL_ADMIN_USER':{'descriptions': {'si': 'Username za dostop do MySQL'}, 'w': True, 'public':True, 'type': 'username', 'generated': False},
'MYSQL_ADMIN_PASSWORD': {'descriptions': {'si': 'Geslo za dostop do MySQL'}, 'w': True, 'public':True, 'type': 'passwd', 'generated': True},
- 'MYSQL_TEST_USER':{'descriptions': {'si': 'Username za testiranje PA;M'}, 'w': False, 'public':False, 'type': 'username', 'generated': True},
- 'MYSQL_TEST_PASSWORD': {'descriptions': {'si': 'Geslo za testiranje PAM'}, 'w': False, 'public':False, 'type': 'passwd', 'generated': True},
+ 'MYSQL_TEST_USER':{'descriptions': {'si': 'Username za testiranje PA;M'}, 'w': False, 'public':False, 'type': 'username', 'generated': True},
+ 'MYSQL_TEST_PASSWORD': {'descriptions': {'si': 'Geslo za testiranje PAM'}, 'w': False, 'public':False, 'type': 'passwd', 'generated': True},
'MYSQL_PAM_USERNAME': {'descriptions': {'si': 'Username v MySQL'}, 'w': True, 'public': True, 'type': 'IP', 'generated': False},
'MYSQL_PAM_PASSWORD': {'descriptions': {'si': 'Geslo za uporabnika v MySQL'}, 'w': True, 'public': True, 'type': 'passwd', 'generated': False},
}
@@ -79,39 +79,33 @@ def task(IP_RS, RADIUS_SECRET, RADIUS_USERNAME, RADIUS_PASSWORD, MYSQL_ADMIN_USE
sR = pxssh.pxssh()
sR.login(IP_RS, peer_user, peer_passwd)
-
- # Testiranje radius strtežnika
+
+ # Testiranje radius strtežnika
results['Test_RadiusServer'] = sR.run('radtest {0} {1} {3} 1812 {4}'.format(
RADIUS_USERNAME, RADIUS_USERNAME,
RADIUS_PASSWORD, IP_RS, RADIUS_SECRET))
- # Testiranje podatkovne base mysql
- results['mysql_login'] = sR.run('mysql -u {MYSQL_ADMIN_USER} -p {MYSQL_ADMIN_PASSWORD}'.format(**locals()))
- results['database_connect'] = sR.run('USE {MYSQL_DB_NAME}'.format(**locals()))
- results['select_from_users'] = sR.run('SELECT username, password FROM users;')
- sR.run('INSERT INTO users (username, password) VALUES ({MYSQL_TEST_USER}, {MYSQL_TEST_PASSWORD});')
- sR.run('\q');
- # Testiranje PAM s testnim uporabnikom
- sT.login(IP_RS, MYSQL_TEST_USER, MYSQL_TEST_PASSWORD)
-
+ # Testiranje podatkovne base mysql
+ results['mysql_login'] = sR.run('mysql -u {MYSQL_ADMIN_USER} -p {MYSQL_ADMIN_PASSWORD}'.format(**locals()))
+ results['database_connect'] = sR.run('USE {MYSQL_DB_NAME}'.format(**locals()))
+ results['select_from_users'] = sR.run('SELECT username, password FROM users;')
+ sR.run('INSERT INTO users (username, password) VALUES ({MYSQL_TEST_USER}, {MYSQL_TEST_PASSWORD});')
+ sR.run('\q');
+ # Testiranje PAM s testnim uporabnikom
+ sT.login(IP_RS, MYSQL_TEST_USER, MYSQL_TEST_PASSWORD)
+
return results
def gen_params(user_id, params_meta):
params = dict()
r = random.Random(user_id)
- secrets = ['skupna', 'secret', 'skrivnost', 'mystery', 'tajna', 'skupnaskrivnost', 'nekadruga', 'spetnekaskrivnost']
- crke = list(string.ascii_lowercase)
for name, meta in param_meta.iteritems():
params[name] = default_generators[meta.get('type', None)](r)
- params['RADIUS_SECRET'] = r.choice(secrets)
- password = SQLpassword = ""
- for i in range(4):
- passowrd+=crke[randint(0,25)]
- SQLpassword+=crke[randint(0,25)]
- params['RADIUS_PASSWORD'] = password
- params['MYSQL_ADMIN_PASSWORD'] = SQLpassword
-
- ip_radius_server = ['10.0.2.7', '192.168.11.21', '192.168.0.47', '10.0.16.134', '10.0.16.17', '172.19.7.16']
- params['IP_RS'] = r.choice(ip_radius_server);
+ params['RADIUS_SECRET'] = alnum_gen(r, 8)
+ params['RADIUS_PASSWORD'] = alnum_gen(r, 4)
+ params['MYSQL_ADMIN_PASSWORD'] = alnum_gen(r, 4)
+ net = IPv4_subnet_gen(r)
+ ip_radius_server = IPv4_addr_gen(r, net, 1)[0]
+ params['IP_RS'] = ip_radius_server
return params
def task_check(results, params):