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

« back to all changes in this revision

Viewing changes to ivle/makeuser.py

  • Committer: Matt Giuca
  • Date: 2009-04-22 05:14:58 UTC
  • Revision ID: matt.giuca@gmail.com-20090422051458-vh65hoaa3a54knxq
Stopped clobbering conf.py within the jail, using a proper ivle.conf instead.
Now works with Python 2.6 (and can have another version, possible 2.6, inside
the jail).

ivle/config/ivle-spec.conf: Added user_info section with in-jail variables.
ivle/makeuser: Writes a conf file (ivle.conf) instead of conf.py.
ivle/conf/conf.py: Added emulation layer bindings for the in-jail variables.
ivle-buildjail: No longer REMOVES the conf.py file (since it's just a normal
    source file now).

(--author Will)

Show diffs side-by-side

added added

removed removed

Lines of Context:
236
236
        # Chmod to rwxr-xr-x (755)
237
237
        os.chmod(userhomedir, 0755)
238
238
 
239
 
    make_conf_py(user.login, userdir, user.svn_pass)
 
239
    make_ivle_conf(user.login, userdir, user.svn_pass)
240
240
    make_etc_passwd(user.login, userdir, ivle.conf.jail_system, user.unixid)
241
241
 
242
242
    return userhomedir
243
243
 
244
 
def make_conf_py(username, user_jail_dir, svn_pass):
 
244
def make_ivle_conf(username, user_jail_dir, svn_pass):
245
245
    """
246
246
    Creates (overwriting any existing file, and creating directories) a
247
 
    file ${python_site_packages}/ivle/conf/conf.py in a given user's jail.
 
247
    file /etc/ivle/ivle.conf in a given user's jail.
248
248
    username: Username.
249
249
    user_jail_dir: User's jail dir, ie. ivle.conf.jail_base + username
250
250
    svn_pass: User's SVN password.
251
251
    """
252
 
    conf_path = os.path.join(user_jail_dir,
253
 
            ivle.conf.python_site_packages[1:], "ivle/conf/conf.py")
 
252
    conf_path = os.path.join(user_jail_dir, "etc/ivle/ivle.conf")
254
253
    os.makedirs(os.path.dirname(conf_path))
255
254
 
256
255
    # In the "in-jail" version of conf, we don't need MOST of the details
257
256
    # (it would be a security risk to have them here).
258
 
    # So we just write root_dir, and jail_base is "/".
259
 
    # (jail_base being "/" means "jail-relative" paths are relative to "/"
260
 
    # when inside the jail.)
261
 
 
262
 
    # XXX: jail_base is wrong and shouldn't be here. Unfortunately, jail code
263
 
    #      uses ivle.studpath.url_to_{local,jailpaths}, both of which use
264
 
    #      jail_base. Note that they don't use the bits of the return value
265
 
    #      that depend on jail_base, so it can be any string.
266
 
    conf_file = open(conf_path, "w")
267
 
    conf_file.write("""# IVLE jail configuration
268
 
 
269
 
# In URL space, where in the site is IVLE located. (All URLs will be prefixed
270
 
# with this).
271
 
# eg. "/" or "/ivle".
272
 
root_dir = %(root_dir)r
273
 
 
274
 
# This value is not relevant inside the jail, but must remain for now. See
275
 
# the XXX in ivle.makeuser.make_conf_py.
276
 
jail_base = '/'
277
 
 
278
 
# The hostname for serving publicly accessible pages
279
 
public_host = %(public_host)r
280
 
 
281
 
# The URL under which the Subversion repositories are located.
282
 
svn_addr = %(svn_addr)r
283
 
 
284
 
# The login name for the owner of the jail
285
 
login = %(username)r
286
 
 
287
 
# The subversion-only password for the owner of the jail
288
 
svn_pass = %(svn_pass)r
289
 
""" % {'root_dir': ivle.conf.root_dir,
290
 
       'public_host': ivle.conf.public_host,
291
 
       'svn_addr': ivle.conf.svn_addr,
292
 
       'username': username,
293
 
       'svn_pass': svn_pass,
294
 
      })
295
 
    conf_file.close()
 
257
    # So we just write root_dir.
 
258
    conf_obj = ivle.config.Config(blank=True)
 
259
    conf_obj.filename = conf_path
 
260
    conf_obj['urls']['root'] = ivle.conf.root_dir
 
261
    conf_obj['urls']['public_host'] = ivle.conf.public_host
 
262
    conf_obj['urls']['svn_addr'] = ivle.conf.svn_addr
 
263
    conf_obj['user_info']['login'] = username
 
264
    conf_obj['user_info']['svn_pass'] = svn_pass
 
265
    conf_obj.write()
296
266
 
297
267
    # Make this file world-readable
298
268
    # (chmod 644 conf_path)