fixing use_sudo argument

This commit is contained in:
Stefan Midjich 2017-11-19 00:45:24 +01:00
parent c56ecc0d01
commit e6ad0f676f
2 changed files with 8 additions and 7 deletions

View File

@ -3,7 +3,7 @@ import subprocess
import shlex import shlex
def run_ipset(command, *args, **kw): def run_ipset(command, *args, **kw):
use_sudo = kw.get('use_sudo', True) use_sudo = kw.get('use_sudo', False)
timeout = kw.get('timeout', 2) timeout = kw.get('timeout', 2)
if use_sudo: if use_sudo:

View File

@ -97,12 +97,12 @@ config.readfp(args.config)
sr = StoragePostgres(config=config) sr = StoragePostgres(config=config)
if args.refresh: if getuid() == 0:
if getuid() == 0: use_sudo = False
use_sudo = False else:
else: use_sudo = True
use_sudo = True
if args.refresh:
# Sync clients and packet counters from ipset into storage. # Sync clients and packet counters from ipset into storage.
proc = run_ipset( proc = run_ipset(
'list', 'list',
@ -201,7 +201,8 @@ for src_ip in args.src_ip:
client = Client( client = Client(
storage=sr, storage=sr,
ip_address=src_ip, ip_address=src_ip,
ipset_name=config.get('ipset', 'ipset_name') ipset_name=config.get('ipset', 'ipset_name'),
use_sudo=use_sudo
) )
if args.delete: if args.delete: