|
30 |
import sys |
30 |
import sys |
31 |
import univention.password |
31 |
import univention.password |
32 |
|
32 |
|
33 |
params = {} |
|
|
34 |
end = False |
35 |
while not end: |
36 |
line = sys.stdin.readline() |
37 |
line = line[:-1] |
38 |
if line == 'end': |
39 |
end = True |
40 |
continue |
41 |
|
33 |
|
42 |
try: |
34 |
def main(): |
43 |
key, val = line.split(': ', 1) |
35 |
params = {} |
44 |
except: |
36 |
end = False |
45 |
print 'key value pair is not correct: %s' % line |
37 |
while not end: |
|
|
38 |
line = sys.stdin.readline() |
39 |
line = line[:-1] |
40 |
if line == 'end': |
41 |
end = True |
42 |
continue |
43 |
|
44 |
try: |
45 |
key, val = line.split(': ', 1) |
46 |
except: |
47 |
print 'key value pair is not correct: %s' % line |
48 |
sys.exit(1) |
49 |
params[key] = val |
50 |
|
51 |
if 'new-password' not in params: |
52 |
print 'missing password' |
46 |
sys.exit(1) |
53 |
sys.exit(1) |
47 |
params[key] = val |
|
|
48 |
|
54 |
|
49 |
if 'new-password' not in params: |
55 |
if 'principal' in params: |
50 |
print 'missing password' |
56 |
pwdCheck = univention.password.Check(None, params['principal']) |
51 |
sys.exit(1) |
57 |
try: |
|
|
58 |
pwdCheck.check(params['new-password']) |
59 |
print 'APPROVED' |
60 |
except ValueError as e: |
61 |
print str(e) |
52 |
|
62 |
|
53 |
if 'principal' in params: |
63 |
|
54 |
pwdCheck = univention.password.Check(None, params['principal']) |
64 |
try: |
55 |
try: |
65 |
main() |
56 |
pwdCheck.check(params['new-password']) |
66 |
except: |
57 |
print 'APPROVED' |
67 |
import traceback |
58 |
except ValueError as e: |
68 |
print traceback.format_exc().replace('\n', ' ') # heimdal-kdc / kpasswd only displays the first line as error message. |
59 |
print str(e) |
69 |
sys.exit(1) |