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

« back to all changes in this revision

Viewing changes to ivle/makeuser.py

  • Committer: William Grant
  • Date: 2009-12-02 02:20:57 UTC
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20091202022057-m3w3rzrzp47y89to
Refuse to traverse through an object to which the user has no permissions. This stops information leakage in breadcrumbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
        os.mkdir(tempdir)
259
259
    userdir = os.path.join(jail_src_base, user.login)
260
260
    homedir = os.path.join(userdir, 'home')
 
261
    tmpdir = os.path.join(userdir, 'tmp')
261
262
    userhomedir = os.path.join(homedir, user.login)   # Return value
262
263
 
263
264
    if os.path.exists(userdir):
275
276
        # NOTE that shutil.move changed in Python 2.6, it now moves a
276
277
        # directory INTO the target (like `mv`), which it didn't use to do.
277
278
        # This code works regardless.
278
 
        shutil.move(homedir, homebackup)
 
279
        shutil.move(userhomedir, homebackup)
279
280
        shutil.rmtree(userdir)
280
 
        os.makedirs(userdir)
281
 
        shutil.move(homebackup, homedir)
 
281
        os.makedirs(homedir)
 
282
        shutil.move(homebackup, userhomedir)
282
283
        # Change the ownership of all the files to the right unixid
283
284
        logging.debug("chown %s's home directory files to uid %d"
284
285
            %(user.login, user.unixid))
296
297
    make_ivle_conf(user.login, userdir, user.svn_pass, config)
297
298
    make_etc_passwd(user.login, userdir, config['paths']['jails']['template'],
298
299
                    user.unixid)
 
300
    os.makedirs(tmpdir)
 
301
    os.chmod(tmpdir, 01777)
299
302
 
300
303
    return userhomedir
301
304
 
310
313
    @param svn_pass: User's SVN password.
311
314
    @param sys_config: An ivle.config.Config object (the system-wide config).
312
315
    """
313
 
    conf_path = os.path.join(user_jail_dir, "etc/ivle/ivle.conf")
314
 
    os.makedirs(os.path.dirname(conf_path))
 
316
    conf_path = os.path.join(user_jail_dir, "home/.ivle.conf")
 
317
    if not os.path.exists(os.path.dirname(conf_path)):
 
318
        os.makedirs(os.path.dirname(conf_path))
315
319
 
316
320
    # In the "in-jail" version of conf, we don't need MOST of the details
317
321
    # (it would be a security risk to have them here).
336
340
    Creates /etc/passwd in the given user's jail. This will be identical to
337
341
    that in the template jail, except for the added entry for this user.
338
342
    """
339
 
    template_passwd_path = os.path.join(template_dir, "etc/passwd")
340
 
    passwd_path = os.path.join(user_jail_dir, "etc/passwd")
 
343
    template_passwd_path = os.path.join(template_dir, "home/.passwd")
 
344
    passwd_path = os.path.join(user_jail_dir, "home/.passwd")
341
345
    passwd_dir = os.path.dirname(passwd_path)
342
346
    if not os.path.exists(passwd_dir):
343
347
        os.makedirs(passwd_dir)