ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/ccs/admin/passwd.py
Revision: 593
Committed: 2009-10-14T01:23:17-07:00 (15 years, 8 months ago) by douglas
Content type: text/x-python
File size: 1002 byte(s)
Log Message:
passwd!

File Contents

# User Rev Content
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     old_password = file.read()
36 douglas 587
37 douglas 593 new_password = common.new_password()
38    
39 douglas 591 if admin.master():
40 douglas 593 admin.passwd(user, old_password, new_password)
41 douglas 592
42 douglas 593 admin.run(common.change_all(user, old_password, new_password) if old_password else common.reset_all(user, new_password))
43     except (common.PasswordError, ldap.LDAPError, MySQLdb.MySQLError), error:
44     admin.error(error)
45 douglas 587 except (EOFError, KeyboardInterrupt):
46 douglas 592 admin.eof()

Properties

Name Value
svn:executable *
svn:keywords Id