Browse Source

Added example config; add syslog/console logging option

master 0.1
Johann Schmitz 6 years ago
parent
commit
10535cbccb
Signed by: ercpe GPG Key ID: A084064277C501ED
  1. 11
      doc/example.cfg
  2. 7
      doc/test.cfg
  3. 10
      src/permwatcher/main.py

11
doc/example.cfg

@ -0,0 +1,11 @@
[DEFAULT]
logging = syslog
[webroots]
directories = /var/www
#exclude = /var/www/foobar.com/*
#remove_file_masks = S_IXUSR S_IXGRP S_IWOTH S_IXOTH
#remove_dir_masks = S_IWOTH
#keep_setgid = true
#keep_setuid = true

7
doc/test.cfg

@ -1,7 +0,0 @@
[webroots]
directories = /var/www /tmp /tmp/blubb
exclude = /tmp/a/**
remove_dir_masks = S_IWOTH
keep_setgid = true
keep_setuid = true

10
src/permwatcher/main.py

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from argparse import ArgumentParser
import logging
from logging.handlers import SysLogHandler
import os
from config import Config
from watcher import Watcher
@ -13,13 +14,18 @@ if __name__ == "__main__":
args = parser.parse_args()
logging.basicConfig(level=logging.FATAL - (10 * args.verbose), format='%(asctime)s %(levelname)-7s %(message)s')
if not os.path.exists(args.config):
logging.error("Configuration file %s does not exist" % args.config)
config = Config()
config.read(args.config)
logtarget = config.get('DEFAULT', 'logging', fallback='console')
if logtarget == 'syslog':
logging.basicConfig(level=logging.FATAL - (10 * args.verbose), format='permwatcher: [%(levelname)s] %(message)s', \
handlers=(SysLogHandler('/dev/log', facility=SysLogHandler.LOG_DAEMON), ))
else:
logging.basicConfig(level=logging.FATAL - (10 * args.verbose), format='%(asctime)s %(levelname)-7s %(message)s')
watcher = Watcher(config)
watcher.start()