1 |
douglas |
587 |
#!/usr/bin/env python |
2 |
|
|
# CCS Computer Science |
3 |
douglas |
592 |
# Change Full Name |
4 |
douglas |
587 |
# |
5 |
|
|
# Douglas Thrift |
6 |
|
|
# |
7 |
|
|
# $Id$ |
8 |
|
|
|
9 |
douglas |
593 |
from __future__ import with_statement |
10 |
douglas |
591 |
import admin |
11 |
douglas |
590 |
import common |
12 |
douglas |
593 |
import ldap |
13 |
|
|
import os |
14 |
douglas |
587 |
import re |
15 |
douglas |
593 |
import sys |
16 |
douglas |
587 |
|
17 |
douglas |
593 |
if sys.hexversion >= 0x2060000: |
18 |
|
|
import warnings |
19 |
|
|
|
20 |
|
|
with warnings.catch_warnings(): |
21 |
|
|
warnings.filterwarnings('ignore', 'the sets module is deprecated', DeprecationWarning) |
22 |
|
|
|
23 |
|
|
import MySQLdb |
24 |
|
|
else: |
25 |
|
|
import MySQLdb |
26 |
|
|
|
27 |
douglas |
587 |
if __name__ == '__main__': |
28 |
douglas |
591 |
user = common.user() |
29 |
|
|
|
30 |
douglas |
587 |
try: |
31 |
douglas |
593 |
old_password = os.environ.get('OLD_PASSWORD') |
32 |
douglas |
587 |
|
33 |
douglas |
593 |
if old_password: |
34 |
|
|
with open(old_password, 'rb') as file: |
35 |
douglas |
597 |
if not old_password.startswith('/dev/fd/'): |
36 |
|
|
os.unlink(old_password) |
37 |
|
|
|
38 |
douglas |
593 |
old_password = file.read() |
39 |
douglas |
587 |
|
40 |
douglas |
593 |
new_password = common.new_password() |
41 |
|
|
|
42 |
douglas |
591 |
if admin.master(): |
43 |
douglas |
593 |
admin.passwd(user, old_password, new_password) |
44 |
douglas |
592 |
|
45 |
douglas |
593 |
admin.run(common.change_all(user, old_password, new_password) if old_password else common.reset_all(user, new_password)) |
46 |
|
|
except (common.PasswordError, ldap.LDAPError, MySQLdb.MySQLError), error: |
47 |
|
|
admin.error(error) |
48 |
douglas |
587 |
except (EOFError, KeyboardInterrupt): |
49 |
douglas |
592 |
admin.eof() |