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

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     try:
29 douglas 598 user = common.user()
30 douglas 593 old_password = os.environ.get('OLD_PASSWORD')
31 douglas 587
32 douglas 593 if old_password:
33     with open(old_password, 'rb') as file:
34 douglas 597 if not old_password.startswith('/dev/fd/'):
35     os.unlink(old_password)
36    
37 douglas 593 old_password = file.read()
38 douglas 587
39 douglas 593 new_password = common.new_password()
40    
41 douglas 591 if admin.master():
42 douglas 593 admin.passwd(user, old_password, new_password)
43 douglas 598
44 douglas 593 admin.run(common.change_all(user, old_password, new_password) if old_password else common.reset_all(user, new_password))
45     except (common.PasswordError, ldap.LDAPError, MySQLdb.MySQLError), error:
46     admin.error(error)
47 douglas 587 except (EOFError, KeyboardInterrupt):
48 douglas 592 admin.eof()

Properties

Name Value
svn:executable *
svn:keywords Id