From a56963f14c21ca318dd7d278b4fd9adf4b4378eb Mon Sep 17 00:00:00 2001 From: Jackson Cooper Date: Wed, 25 Sep 2013 16:13:06 +0800 Subject: [PATCH 1/2] Fixed the blocking of IPv6/AAAA records --- focus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/focus.py b/focus.py index f3f155e..9ae8322 100644 --- a/focus.py +++ b/focus.py @@ -463,7 +463,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 From 9fe2008183cd8029adeb0280880a5c8ed7438f29 Mon Sep 17 00:00:00 2001 From: Jackson Cooper Date: Wed, 25 Sep 2013 16:14:00 +0800 Subject: [PATCH 2/2] Added permission check for creating pid file --- focus.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/focus.py b/focus.py index 9ae8322..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))