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

« back to all changes in this revision

Viewing changes to lib/common/makeuser.py

  • Committer: William Grant
  • Date: 2008-07-07 05:42:59 UTC
  • Revision ID: wgrant@ugrad.unimelb.edu.au-20080707054259-urcxosg7hsfvp3wo
lib/common/makeuser.py: Create a jail-specific /etc/passwd. This makes
    SVN somewhat happier. It might actually work now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
235
235
        # Chmod to rwxr-xr-x (755)
236
236
        os.chmod(userhomedir, 0755)
237
237
 
238
 
    # There is 1 special file which needs to be generated specific to this
239
 
    # user: /opt/ivle/lib/conf/conf.py.
 
238
    # There are 2 special files which need to be generated specific to this
 
239
    # user: /opt/ivle/lib/conf/conf.py and /etc/passwd.
240
240
    # "__" username "__" users are exempt (special)
241
241
    if not (username.startswith("__") and username.endswith("__")):
242
242
        make_conf_py(username, userdir, conf.jail_system, svn_pass)
 
243
        make_etc_passwd(username, userdir, conf.jail_system, uid)
243
244
 
244
245
    return userhomedir
245
246
 
290
291
    os.chmod(conf_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP
291
292
                        | stat.S_IROTH)
292
293
 
 
294
def make_etc_passwd(username, user_jail_dir, template_dir, unixid):
 
295
    """
 
296
    Creates /etc/passwd in the given user's jail. This will be identical to
 
297
    that in the template jail, except for the added entry for this user.
 
298
    """
 
299
    template_passwd_path = os.path.join(template_dir, "etc/passwd")
 
300
    passwd_path = os.path.join(user_jail_dir, "etc/passwd")
 
301
    passwd_dir = os.path.dirname(passwd_path)
 
302
    if not os.path.exists(passwd_dir):
 
303
        os.makedirs(passwd_dir)
 
304
    shutil.copy(template_passwd_path, passwd_path)
 
305
    passwd_file = open(passwd_path, 'a')
 
306
    passwd_file.write('%s:x:%d:%d::/home/%s:/bin/bash'
 
307
                      % (username, unixid, unixid, username))
 
308
    passwd_file.close()
 
309
 
293
310
def linktree(src, dst):
294
311
    """Recursively hard-link a directory tree using os.link().
295
312