diff --git a/focus.py b/focus.py index f3f155e..b3343e3 100644 --- a/focus.py +++ b/focus.py @@ -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)) @@ -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