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

« back to all changes in this revision

Viewing changes to scripts/usrmgt-server

  • Committer: drtomc
  • Date: 2008-02-15 05:26:00 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:473
usrmgt: progress the skeleton a bit further.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
import sys
4
4
 
 
5
import common.db
5
6
import common.chat
6
7
import common.makeuser
7
8
 
55
56
       Return Value: the uid associated with the user. INT
56
57
    """
57
58
 
 
59
    # FIXME: the IVLE server must check that an admin is doing this!
 
60
 
58
61
    if 'uid' not in props or props['uid'] is None:
59
62
        raise NotImplementedError, "No algorithm for creating uids yet!"
60
63
        # uid = invent-uid
82
85
 
83
86
    return uid
84
87
 
85
 
def create_jail(props):
86
 
    """Create the jail for a user.
 
88
def activate_user(props):
 
89
    """Create the on-disk stuff for the given user.
 
90
       Sets the state of the user in the db from pending to enabled.
87
91
       Expected properties:
88
 
        username    - the username for the jail
 
92
        login       - the user name for the jail
89
93
                      STRING REQUIRED
90
 
        uid         - the unix uid to make the owner of the home directory
91
 
                      in the jail.
92
 
                      INT REQUIRED
93
 
        gid         - the unix group id to make the group of the home directory
94
 
                      in the jail. If not supplied (or None), then the uid is
95
 
                      also used.
96
 
                      INT OPTIONAL
97
94
       Return Value: None
98
95
    """
99
96
 
100
 
    if 'gid' not in props or props['gid'] is None:
101
 
        gid = props['uid']
102
 
 
103
 
    common.makeuser.make_jail(props['username'], props['uid'], gid)
104
 
 
105
 
    return None
 
97
    login = props['login']
 
98
 
 
99
    db = common.db.DB()
 
100
 
 
101
    try:
 
102
 
 
103
        # FIXME: check we're pending
 
104
 
 
105
        details = db.get_user(login)
 
106
 
 
107
        # FIXME: make svn config/auth
 
108
 
 
109
        # FIXME: etc, etc.
 
110
 
 
111
        common.makeuser.make_jail(login, details['unixid'])
 
112
 
 
113
        db.update_user(login, state='enabled')
 
114
 
 
115
        return None
 
116
 
 
117
    finally:
 
118
        db.close()
106
119
 
107
120
actions = {
108
121
        'create-user':create_user,
109
 
        'init-jail':create_jail
 
122
        'activate-user':activate_user
110
123
    }
111
124
 
112
125
def dispatch(props):