~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to makeuser.py

  • Committer: mattgiuca
  • Date: 2008-02-19 06:10:53 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:503
user.py: Added acct_expired and pass_expired methods.
login.py: Removed has_expired function (now we put it inside the class)
    and called those methods instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
import sys
31
31
import os
 
32
import os.path
 
33
import pwd
32
34
import getopt
33
 
import common.makeuser
 
35
# Import modules from the website is tricky since they're in the www
 
36
# directory.
 
37
sys.path.append(os.path.join(os.getcwd(), 'www'))
 
38
import conf
 
39
import common.makeuser, common.db
34
40
 
35
41
# Requireds and optionals will be used to display the usage message
36
42
# AND do argument processing
78
84
    user['nick'] = user['fullname']
79
85
 
80
86
try:
 
87
    # Resolve the user's username into a UID
 
88
    # Create the user if it does not exist
 
89
    try:
 
90
        (_,_,uid,_,_,_,_) = pwd.getpwnam(login)
 
91
    except KeyError:
 
92
        if os.system("useradd '%s'" % login) != 0:
 
93
            raise Exception("Failed to add Unix user account")
 
94
        try:
 
95
            (_,_,uid,_,_,_,_) = pwd.getpwnam(login)
 
96
        except KeyError:
 
97
            raise Exception("Failed to add Unix user account")
 
98
    user['unixid'] = uid
 
99
    # Make the user's jail
 
100
    common.makeuser.make_jail(login, uid)
81
101
    # Make the user's database entry
82
102
    common.makeuser.make_user_db(**user)
83
103
except Exception, message: