Skip to content
This repository was archived by the owner on Jun 24, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions focus.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,14 @@ def drop_privileges(uid, gid):
manually find and kill any existing focus.py process")
exit(1)

with open(pid_file, "w") as f:
# Drop ownership of the pidfile
os.fchown(f.fileno(), get_unprivileged_uid(), -1)
f.write(str(os.getpid()))
try:
with open(pid_file, "w") as f:
# Drop ownership of the pidfile
os.fchown(f.fileno(), get_unprivileged_uid(), -1)
f.write(str(os.getpid()))
except IOError:
log.warning("Couldn't create a pidfile. Please run this script as root.")
exit(1)
atexit.register(clean_up_pid)

config.update(load_config(config_file))
Expand Down Expand Up @@ -463,7 +467,7 @@ def drop_privileges(uid, gid):


# a request for an ip for a domain
if qtype is request_types["A"]:
if qtype is request_types["A"] or qtype is request_types["AAAA"]:
# if we can visit it now, it might be either A) not on the blacklist
# or B) on the blacklist, but not blacklisted at this time (due to
# the schedule permitting access). in both cases, we should
Expand Down