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

« back to all changes in this revision

Viewing changes to bin/ivle-config

Move trampoline UID configuration out of config.

conf.h is now generated during the build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
Either prompts the administrator for these details or accepts them as
23
23
command-line args.
24
24
 
25
 
Creates ivle/conf/conf.py and bin/trampoline/trampoline/conf.h.
 
25
Creates etc/ivle.conf
26
26
'''
27
27
 
28
28
import optparse
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],
116
 
    """UID of the web server process which will run IVLE.
117
 
Only this user may execute the trampoline. May specify multiple users as
118
 
a comma-separated list.
119
 
    (eg. "1002,78")""",
120
 
    """
121
 
# The User-ID of the web server process which will run IVLE, and any other
122
 
# users who are allowed to run the trampoline. This is stores as a string of
123
 
# comma-separated integers, simply because it is not used within Python, only
124
 
# used by the setup program to write to conf.h (see setup.py config).""",
125
 
    ask=False))
126
 
 
127
115
config_options.append(ConfigOption("database/host", "localhost",
128
116
    """PostgreSQL Database config
129
117
==========================
284
272
 
285
273
    # the files that will be created/overwritten
286
274
    conffile = os.path.join(cwd, "etc/ivle.conf")
287
 
    conf_hfile = os.path.join(cwd, "bin/trampoline/conf.h")
288
275
    phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php")
289
276
 
290
277
    # Get command-line arguments to avoid asking questions.
304
291
        print """This tool will create the following files:
305
292
    %s
306
293
    %s
307
 
    %s
308
294
prompting you for details about your configuration. The file will be
309
295
overwritten if it already exists. It will *not* install or deploy IVLE.
310
296
 
311
297
Please hit Ctrl+C now if you do not wish to do this.
312
 
""" % (conffile, conf_hfile, phpBBconffile)
 
298
""" % (conffile, phpBBconffile)
313
299
 
314
300
        # Get information from the administrator
315
301
        # If EOF is encountered at any time during the questioning, just exit
328
314
                                 opts['--' + opt.option_name])
329
315
 
330
316
    # Error handling on input values
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,
336
 
                                conf['os']['allowed_uids'].split(','))
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
343
317
    try:
344
318
        conf['database']['port'] = int(conf['database']['port'])
345
319
        if (conf['database']['port'] < 0
384
358
 
385
359
    print "Successfully wrote %s" % conffile
386
360
 
387
 
    # Write bin/trampoline/conf.h
388
 
 
389
 
    conf_h = open(conf_hfile, "w")
390
 
 
391
 
    conf_h.write("""/* IVLE Configuration File
392
 
 * conf.h
393
 
 * Administrator settings required by trampoline.
394
 
 * Note: trampoline will have to be rebuilt in order for changes to this file
395
 
 * to take effect.
396
 
 */
397
 
 
398
 
#define IVLE_AUFS_JAILS
399
 
 
400
 
/* Which user IDs are allowed to run the trampoline.
401
 
 * This list should be limited to the web server user.
402
 
 * (Note that root is an implicit member of this list).
403
 
 */
404
 
static const int allowed_uids[] = { %s };
405
 
""" % (repr(allowed_uids_list)[1:-1]))
406
 
 
407
 
    conf_h.close()
408
 
 
409
 
    print "Successfully wrote %s" % conf_hfile
410
 
 
411
361
    # Write www/php/phpBB3/config.php
412
362
 
413
363
    conf_php = open(phpBBconffile, "w")
445
395
    print
446
396
    print "You may modify the configuration at any time by editing"
447
397
    print conffile
448
 
    print conf_hfile
449
398
    print phpBBconffile
450
399
    print
451
400