Browse Source

Added example config; add syslog/console logging option

tags/0.1
Johann Schmitz 5 years ago
parent
commit
10535cbccb
Signed by: ercpe <johann@j-schmitz.net> GPG Key ID: A084064277C501ED
3 changed files with 19 additions and 9 deletions
  1. +11
    -0
      doc/example.cfg
  2. +0
    -7
      doc/test.cfg
  3. +8
    -2
      src/permwatcher/main.py

+ 11
- 0
doc/example.cfg View File

@@ -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


+ 0
- 7
doc/test.cfg View File

@@ -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

+ 8
- 2
src/permwatcher/main.py View File

@@ -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()

Loading…
Cancel
Save