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

« back to all changes in this revision

Viewing changes to ivle/makeuser.py

  • Committer: William Grant
  • Date: 2010-02-17 12:00:09 UTC
  • Revision ID: grantw@unimelb.edu.au-20100217120009-o48s4r1junx8oq8n
Tags: 1.0beta2
Drop version number to 1.0beta2. We are going in for another one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
                    User.login,
103
103
                    User.id == Enrolment.user_id,
104
104
                    Enrolment.offering_id == offeringid,
105
 
                    Enrolment.role.is_in((u'tutor', u'lecturer'))
 
105
                    Enrolment.role.is_in((u'tutor', u'lecturer')),
 
106
                    Enrolment.active == True,
106
107
                )
107
108
            )
108
109
 
185
186
                    User.login,
186
187
                    User.id == Enrolment.user_id,
187
188
                    Enrolment.offering_id == offeringid,
188
 
                    Enrolment.role.is_in((u'tutor', u'lecturer'))
 
189
                    Enrolment.role.is_in((u'tutor', u'lecturer')),
 
190
                    Enrolment.active == True,
189
191
                )
190
192
            )
191
193
 
211
213
    """
212
214
    # filename is, eg, /var/lib/ivle/svn/ivle.auth
213
215
    filename = config['paths']['svn']['auth_ivle']
214
 
    passwd = hashlib.md5(uuid.uuid4().bytes).hexdigest()
215
216
    if os.path.exists(filename):
216
217
        create = ""
217
218
    else:
218
219
        create = "c"
219
220
 
220
221
    user = User.get_by_login(store, login)
221
 
    user.svn_pass = unicode(passwd)
 
222
 
 
223
    if user.svn_pass is None:
 
224
        passwd = hashlib.md5(uuid.uuid4().bytes).hexdigest()
 
225
        user.svn_pass = unicode(passwd)
222
226
 
223
227
    res = subprocess.call(['htpasswd', '-%smb' % create,
224
 
                           filename, login, passwd])
 
228
                           filename, login, user.svn_pass])
225
229
    if res != 0 and throw_on_error:
226
230
        raise Exception("Unable to create ivle-auth for %s" % login)
227
231
 
229
233
    if create == "c":
230
234
        chown_to_webserver(filename)
231
235
 
232
 
    return passwd
 
236
    return user.svn_pass
233
237
 
234
238
def make_jail(user, config, force=True):
235
239
    """Create or update a user's jail.
267
271
        # User jail already exists. Blow it away but preserve their home
268
272
        # directory. It should be all that is there anyway, but you never
269
273
        # know!
270
 
        # Ignore warnings about the use of tmpnam
 
274
        # Ignore warnings about the use of tempnam
271
275
        warnings.simplefilter('ignore')
272
276
        homebackup = os.tempnam(tempdir)
273
277
        warnings.resetwarnings()