Exemplo n.º 1
0
def restore(config, debug):
    """
    Restores all the ownerships and permissions on all files
    """
    filenames = collect(config)
    for item in filenames[0]:
        prepare(item, 'RESTORE', True, config, debug)
    for item in filenames[1]:
        prepare(item, 'RESTORE', False, config, debug)
Exemplo n.º 2
0
def main():
    if not os.geteuid() == 0:
        print >> sys.stderr, ("You need to run experms with root privileges." "\nAborting.")
        sys.exit(1)

    set_procname("experms")

    args = parse_arguments()

    try:
        if os.environ["SYSTEMD_LOG_LEVEL"] == "debug":
            args.debug = True
    except KeyError:
        pass

    if args.version:
        print "Experms v" + version
        sys.exit(0)

    if args.restore:
        if args.debug:
            debug_message()
        config = configfile.main.Check(args.config, args.debug)
        restore(config, args.debug)
        sys.exit(0)

    if args.total:
        if args.debug:
            debug_message()
        config = configfile.main.Check(args.config, args.debug)
        print ("Directories configured for watching:\n%s" % len(collect(config)[0]))
        with open("/proc/sys/fs/inotify/max_user_watches", "r") as inotifyconf:
            inotifyconfig = inotifyconf.read().strip()
        print ("Directories allowed to watch with inotify:\n%s" % inotifyconfig)
        sys.exit(0)

    if args.debug:
        debug_message()

    config = configfile.main.Check(args.config, args.debug)

    if config.restore:
        if args.debug:
            print >> sys.stderr, ("[debug] Starting restore")
        restore(config, args.debug)

    start_pyinotify(config, args.debug)

    sys.exit(0)