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

« back to all changes in this revision

Viewing changes to bin/ivle-config

Move ivle-config into bin/, and trim the unneeded stuff from conf.h.

Also hopefully fix the allowed UIDs list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
# Private mode (normal mode) requires login, and only serves files relevant to
113
113
# the logged-in user."""))
114
114
 
115
 
config_options.append(ConfigOption("os/allowed_uids", "33",
 
115
config_options.append(ConfigOption("os/allowed_uids", [33],
116
116
    """UID of the web server process which will run IVLE.
117
117
Only this user may execute the trampoline. May specify multiple users as
118
118
a comma-separated list.
328
328
                                 opts['--' + opt.option_name])
329
329
 
330
330
    # Error handling on input values
331
 
    try:
332
 
        allowed_uids_list = map(int,
 
331
    if type(conf['os']['allowed_uids']) == list:
 
332
        allowed_uids_list = conf['os']['allowed_uids']
 
333
    else:
 
334
        try:
 
335
            allowed_uids_list = map(int,
333
336
                                conf['os']['allowed_uids'].split(','))
334
 
    except ValueError:
335
 
        print >>sys.stderr, (
336
 
        "Invalid UID list (%s).\n"
337
 
        "Must be a comma-separated list of integers." %
338
 
            conf['os']['allowed_uids'])
339
 
        return 1
 
337
        except ValueError:
 
338
            print >>sys.stderr, (
 
339
            "Invalid UID list (%s).\n"
 
340
            "Must be a comma-separated list of integers." %
 
341
                conf['os']['allowed_uids'])
 
342
            return 1
340
343
    try:
341
344
        conf['database']['port'] = int(conf['database']['port'])
342
345
        if (conf['database']['port'] < 0
385
388
 
386
389
    conf_h = open(conf_hfile, "w")
387
390
 
388
 
    # XXX Compute jail_base, jail_src_base and jail_system. These will
389
 
    # ALSO be done by the boilerplate code, but we need them here in order
390
 
    # to write to the C file.
391
 
    jail_base = os.path.join(conf['paths']['data'], 'jailmounts')
392
 
    jail_src_base = os.path.join(conf['paths']['data'], 'jails')
393
 
    jail_system = os.path.join(jail_src_base, '__base__')
394
 
 
395
391
    conf_h.write("""/* IVLE Configuration File
396
392
 * conf.h
397
393
 * Administrator settings required by trampoline.
401
397
 
402
398
#define IVLE_AUFS_JAILS
403
399
 
404
 
/* In the local file system, where are the jails located.
405
 
 * The trampoline does not allow the creation of a jail anywhere besides
406
 
 * jail_base or a subdirectory of jail_base.
407
 
 */
408
 
static const char* jail_base = "%s";
409
 
static const char* jail_src_base = "%s";
410
 
static const char* jail_system = "%s";
411
 
 
412
400
/* Which user IDs are allowed to run the trampoline.
413
401
 * This list should be limited to the web server user.
414
402
 * (Note that root is an implicit member of this list).
415
403
 */
416
404
static const int allowed_uids[] = { %s };
417
 
""" % (repr(jail_base)[1:-1], repr(jail_src_base)[1:-1],
418
 
       repr(jail_system)[1:-1], repr(allowed_uids_list)[1:-1]))
419
 
    # Note: The above uses PYTHON reprs, not C reprs
420
 
    # However they should be the same with the exception of the outer
421
 
    # characters, which are stripped off and replaced
 
405
""" % (repr(allowed_uids_list)[1:-1]))
422
406
 
423
407
    conf_h.close()
424
408