Reintroduce sudo feature to lock users out. Remove AW watcher because the dependency is annoying.
This commit is contained in:
20
antidrift.py
20
antidrift.py
@@ -3,6 +3,7 @@ import shutil
|
||||
import sys
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
import antidrift.client as client
|
||||
from antidrift.config import Config
|
||||
@@ -40,17 +41,30 @@ def check_for_xdotool():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def main_daemon(config):
|
||||
init_logging(config.daemon_log_file)
|
||||
add = AntiDriftDaemon(config)
|
||||
add.run()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
""" Main routine that dispatches to client or daemon """
|
||||
config = Config.load(os.path.expanduser("~/.config/antidrift.yaml"))
|
||||
check_for_xdotool()
|
||||
|
||||
if client.antidrift_daemon_is_running():
|
||||
init_logging(config.client_log_file)
|
||||
client.client_mode(config)
|
||||
elif len(sys.argv) == 1:
|
||||
init_logging(config.daemon_log_file)
|
||||
add = AntiDriftDaemon(config)
|
||||
add.run()
|
||||
if os.geteuid() == 0:
|
||||
newpid = os.fork()
|
||||
if newpid == 0:
|
||||
main_daemon(config)
|
||||
else:
|
||||
cmd = ["sudo", "/home/felixm/dot/bin/antidrift"]
|
||||
subprocess.Popen(cmd)
|
||||
elif len(sys.argv) == 2 and sys.argv[1] == '--daemon_user':
|
||||
main_daemon(config)
|
||||
else:
|
||||
print("ad not running")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user