From 9de3d39e6c389703091a5bc91c5ef5f7f185f892 Mon Sep 17 00:00:00 2001 From: Franklyn Tackitt Date: Wed, 1 Jul 2020 11:15:46 -0700 Subject: [PATCH 01/12] Use syslog.LOG_INFO and LOG_NOTICE instead of LOG_EMERG Fixes #374 --- src/pam.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pam.py b/src/pam.py index fda74a9..57b619f 100644 --- a/src/pam.py +++ b/src/pam.py @@ -35,7 +35,7 @@ def doAuth(pamh): if config.getboolean("core", "detection_notice"): pamh.conversation(pamh.Message(pamh.PAM_TEXT_INFO, "Attempting face detection")) - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Attempting facial authentication for user " + pamh.get_user()) + syslog.syslog(syslog.LOG_INFO | syslog.LOG_AUTH, "[HOWDY] Attempting facial authentication for user " + pamh.get_user()) # Run compare as python3 subprocess to circumvent python version and import issues status = subprocess.call(["/usr/bin/python3", os.path.dirname(os.path.abspath(__file__)) + "/compare.py", pamh.get_user()]) @@ -45,23 +45,23 @@ def doAuth(pamh): if not config.getboolean("core", "suppress_unknown"): pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "No face model known")) - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Failure, no face model known") + syslog.syslog(syslog.LOG_NOTICE | syslog.LOG_AUTH, "[HOWDY] Failure, no face model known") return pamh.PAM_USER_UNKNOWN # Status 11 means we exceded the maximum retry count elif status == 11: pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Face detection timeout reached")) - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Failure, timeout reached") + syslog.syslog(syslog.LOG_INFO | syslog.LOG_AUTH, "[HOWDY] Failure, timeout reached") return pamh.PAM_AUTH_ERR # Status 12 means we aborted elif status == 12: - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Failure, general abort") + syslog.syslog(syslog.LOG_INFO | syslog.LOG_AUTH, "[HOWDY] Failure, general abort") return pamh.PAM_AUTH_ERR # Status 13 means the image was too dark elif status == 13: - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Failure, image too dark") + syslog.syslog(syslog.LOG_INFO | syslog.LOG_AUTH, "[HOWDY] Failure, image too dark") pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Face detection image too dark")) return pamh.PAM_AUTH_ERR # Status 0 is a successful exit @@ -70,12 +70,12 @@ def doAuth(pamh): if not config.getboolean("core", "no_confirmation"): pamh.conversation(pamh.Message(pamh.PAM_TEXT_INFO, "Identified face as " + pamh.get_user())) - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Login approved") + syslog.syslog(syslog.LOG_INFO | syslog.LOG_AUTH, "[HOWDY] Login approved") return pamh.PAM_SUCCESS # Otherwise, we can't discribe what happend but it wasn't successful pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Unknown error: " + str(status))) - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Failure, unknown error" + str(status)) + syslog.syslog(syslog.LOG_INFO | syslog.LOG_AUTH, "[HOWDY] Failure, unknown error" + str(status)) return pamh.PAM_SYSTEM_ERR From 9a0da43955ef1c843eded86f13e6ebc36713d9f3 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 3 Jul 2020 00:15:44 +0200 Subject: [PATCH 02/12] Fixed typo that caused an error --- src/compare.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compare.py b/src/compare.py index 658f94f..5966b8d 100644 --- a/src/compare.py +++ b/src/compare.py @@ -291,5 +291,5 @@ while True: # are captured and even after a delay it does not # always work. Setting exposure at every frame is # reliable though. - video_capture.intenal.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual - video_capture.intenal.set(cv2.CAP_PROP_EXPOSURE, float(exposure)) + video_capture.internal.set(cv2.CAP_PROP_AUTO_EXPOSURE, 1.0) # 1 = Manual + video_capture.internal.set(cv2.CAP_PROP_EXPOSURE, float(exposure)) From aa11042839ea7e850f665f0d4b908ce85bc8067a Mon Sep 17 00:00:00 2001 From: William Charlton <38622599+willwill2will54@users.noreply.github.com> Date: Sat, 25 Jul 2020 21:03:19 +0100 Subject: [PATCH 03/12] Fixes error with slow mode on low FPS When frame_time exceeds 0.5 this change caps the sleep time to be at least zero, as trying to sleep a negative duration crashes the program. --- src/cli/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/test.py b/src/cli/test.py index 21cb2db..dbcd06d 100644 --- a/src/cli/test.py +++ b/src/cli/test.py @@ -183,7 +183,7 @@ try: # Delay the frame if slowmode is on if slow_mode: - time.sleep(.5 - frame_time) + time.sleep(max([.5 - frame_time, 0.0])) if exposure != -1: # For a strange reason on some cameras (e.g. Lenoxo X1E) From d4623b6031c7dac214d8977c70829019d7ec19e4 Mon Sep 17 00:00:00 2001 From: Peter Onyisi Date: Wed, 29 Jul 2020 16:18:53 -0500 Subject: [PATCH 04/12] Ensure not all syslog messages are EMERG level --- src/pam.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pam.py b/src/pam.py index fda74a9..edb4412 100644 --- a/src/pam.py +++ b/src/pam.py @@ -31,11 +31,14 @@ def doAuth(pamh): if any("closed" in open(f).read() for f in glob.glob("/proc/acpi/button/lid/*/state")): return pamh.PAM_AUTHINFO_UNAVAIL + # Set up syslog + syslog.openlog("[HOWDY]", 0, syslog.LOG_AUTH) + # Alert the user that we are doing face detection if config.getboolean("core", "detection_notice"): pamh.conversation(pamh.Message(pamh.PAM_TEXT_INFO, "Attempting face detection")) - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Attempting facial authentication for user " + pamh.get_user()) + syslog.syslog(syslog.LOG_INFO, "Attempting facial authentication for user " + pamh.get_user()) # Run compare as python3 subprocess to circumvent python version and import issues status = subprocess.call(["/usr/bin/python3", os.path.dirname(os.path.abspath(__file__)) + "/compare.py", pamh.get_user()]) @@ -45,23 +48,23 @@ def doAuth(pamh): if not config.getboolean("core", "suppress_unknown"): pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "No face model known")) - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Failure, no face model known") + syslog.syslog(syslog.LOG_ERROR, "Failure, no face model known") return pamh.PAM_USER_UNKNOWN # Status 11 means we exceded the maximum retry count elif status == 11: pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Face detection timeout reached")) - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Failure, timeout reached") + syslog.syslog(syslog.LOG_WARNING, "Failure, timeout reached") return pamh.PAM_AUTH_ERR # Status 12 means we aborted elif status == 12: - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Failure, general abort") + syslog.syslog(syslog.LOG_ERROR, "Failure, general abort") return pamh.PAM_AUTH_ERR # Status 13 means the image was too dark elif status == 13: - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Failure, image too dark") + syslog.syslog(syslog.LOG_WARNING, "Failure, image too dark") pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Face detection image too dark")) return pamh.PAM_AUTH_ERR # Status 0 is a successful exit @@ -70,12 +73,12 @@ def doAuth(pamh): if not config.getboolean("core", "no_confirmation"): pamh.conversation(pamh.Message(pamh.PAM_TEXT_INFO, "Identified face as " + pamh.get_user())) - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Login approved") + syslog.syslog(syslog.LOG_INFO, "Login approved") return pamh.PAM_SUCCESS # Otherwise, we can't discribe what happend but it wasn't successful pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Unknown error: " + str(status))) - syslog.syslog(syslog.LOG_AUTH, "[HOWDY] Failure, unknown error" + str(status)) + syslog.syslog(syslog.LOG_ERROR, "Failure, unknown error" + str(status)) return pamh.PAM_SYSTEM_ERR From a5df47312d981842f6d4cba9c80e58ef1af87ab4 Mon Sep 17 00:00:00 2001 From: Peter Onyisi Date: Wed, 29 Jul 2020 16:20:43 -0500 Subject: [PATCH 05/12] Replace spaces with tabs --- src/pam.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pam.py b/src/pam.py index edb4412..d24456f 100644 --- a/src/pam.py +++ b/src/pam.py @@ -31,8 +31,8 @@ def doAuth(pamh): if any("closed" in open(f).read() for f in glob.glob("/proc/acpi/button/lid/*/state")): return pamh.PAM_AUTHINFO_UNAVAIL - # Set up syslog - syslog.openlog("[HOWDY]", 0, syslog.LOG_AUTH) + # Set up syslog + syslog.openlog("[HOWDY]", 0, syslog.LOG_AUTH) # Alert the user that we are doing face detection if config.getboolean("core", "detection_notice"): From d6b36795492e634b3cc40e65b79157ed6bdb1053 Mon Sep 17 00:00:00 2001 From: Peter Onyisi Date: Wed, 29 Jul 2020 16:37:30 -0500 Subject: [PATCH 06/12] Fix name typo, reset syslog when done --- src/pam.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pam.py b/src/pam.py index d24456f..f3ef340 100644 --- a/src/pam.py +++ b/src/pam.py @@ -48,23 +48,27 @@ def doAuth(pamh): if not config.getboolean("core", "suppress_unknown"): pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "No face model known")) - syslog.syslog(syslog.LOG_ERROR, "Failure, no face model known") + syslog.syslog(syslog.LOG_ERR, "Failure, no face model known") + syslog.closelog() return pamh.PAM_USER_UNKNOWN # Status 11 means we exceded the maximum retry count elif status == 11: pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Face detection timeout reached")) syslog.syslog(syslog.LOG_WARNING, "Failure, timeout reached") + syslog.closelog() return pamh.PAM_AUTH_ERR # Status 12 means we aborted elif status == 12: - syslog.syslog(syslog.LOG_ERROR, "Failure, general abort") + syslog.syslog(syslog.LOG_ERR, "Failure, general abort") + syslog.closelog() return pamh.PAM_AUTH_ERR # Status 13 means the image was too dark elif status == 13: syslog.syslog(syslog.LOG_WARNING, "Failure, image too dark") + syslog.closelog() pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Face detection image too dark")) return pamh.PAM_AUTH_ERR # Status 0 is a successful exit @@ -74,11 +78,13 @@ def doAuth(pamh): pamh.conversation(pamh.Message(pamh.PAM_TEXT_INFO, "Identified face as " + pamh.get_user())) syslog.syslog(syslog.LOG_INFO, "Login approved") + syslog.closelog() return pamh.PAM_SUCCESS # Otherwise, we can't discribe what happend but it wasn't successful pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Unknown error: " + str(status))) - syslog.syslog(syslog.LOG_ERROR, "Failure, unknown error" + str(status)) + syslog.syslog(syslog.LOG_ERR, "Failure, unknown error" + str(status)) + syslog.closelog() return pamh.PAM_SYSTEM_ERR From 8abe3c3eeb0c499c6c0a6a57bd1198c6ced548de Mon Sep 17 00:00:00 2001 From: boltgolt Date: Fri, 7 Aug 2020 14:56:39 +0200 Subject: [PATCH 07/12] Add missing howdy options to tab autocomplete --- autocomplete/howdy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autocomplete/howdy b/autocomplete/howdy index e3bde07..d633f22 100755 --- a/autocomplete/howdy +++ b/autocomplete/howdy @@ -14,7 +14,7 @@ _howdy() { case "${prev}" in # After the main command, show the commands "howdy") - opts="add clear config disable list remove clear test" + opts="add clear config disable list remove clear snapshot test version" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0 ;; From 534689028735681f80012f385fe1e9ccf1402fb9 Mon Sep 17 00:00:00 2001 From: boltgolt Date: Fri, 7 Aug 2020 14:58:50 +0200 Subject: [PATCH 08/12] Fix devision by zero, fixes #413 --- src/compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compare.py b/src/compare.py index 5966b8d..7dc640f 100644 --- a/src/compare.py +++ b/src/compare.py @@ -176,7 +176,7 @@ while True: if dark_tries == valid_frames: print("All frames were too dark, please check dark_threshold in config") - print("Average darkness: " + str(dark_running_total / valid_frames) + ", Threshold: " + str(dark_threshold)) + print("Average darkness: " + str(dark_running_total / max(1, valid_frames)) + ", Threshold: " + str(dark_threshold)) sys.exit(13) else: sys.exit(11) From 1b0a92d36fab1aa550411d90f19ed57d638f04b3 Mon Sep 17 00:00:00 2001 From: Divy Jain Date: Tue, 1 Sep 2020 20:21:50 +0530 Subject: [PATCH 09/12] fix typo --- debian/postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/postinst b/debian/postinst index 40fc93e..7ed436f 100755 --- a/debian/postinst +++ b/debian/postinst @@ -110,7 +110,7 @@ log("Upgrading pip to the latest version") handleStatus(sc(["pip3", "install", "--upgrade", "pip"])) -log("Upgrading numpy to the lateset version") +log("Upgrading numpy to the latest version") # Update numpy handleStatus(subprocess.call(["pip3", "install", "--upgrade", "numpy"])) From 60042d43934cf1bd549dcea341ba5e825ec19343 Mon Sep 17 00:00:00 2001 From: boltgolt Date: Wed, 2 Sep 2020 16:50:51 +0200 Subject: [PATCH 10/12] Updated issue template --- .github/ISSUE_TEMPLATE/bug_report.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 4f37de5..3abb498 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,8 @@ about: Report something that's not working --- -_Please describe the issue in as much detail as possible, including any errors and traces_ +_Please describe the issue in as much detail as possible, including any errors and traces._ +_If your issue is a camera issue, be sure to also post the image generated by running `sudo howdy snapshot`._ @@ -15,4 +16,4 @@ I've searched for similar issues already, and my issue has not been reported yet Linux distribution (if applicable): -Howdy version: +Howdy version (`sudo howdy version`): From 756626db7b37375dec72834716de38f26ec6419b Mon Sep 17 00:00:00 2001 From: boltgolt Date: Wed, 2 Sep 2020 17:04:40 +0200 Subject: [PATCH 11/12] Fixed preinst certainty question --- debian/preinst | 4 ++-- src/cli.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/preinst b/debian/preinst index 9bb5aad..dbc699a 100755 --- a/debian/preinst +++ b/debian/preinst @@ -135,11 +135,11 @@ print("\nYou can always change this setting in the config.") prof = input("What profile would you like to use? [f/b/s]: ") if prof.lower().strip() == "f" or prof.lower().strip() == "fast": - cert = 1.5 + cert = 4.2 elif prof.lower().strip() == "b" or prof.lower().strip() == "balanced": cert = 2.8 elif prof.lower().strip() == "s" or prof.lower().strip() == "secure": - cert = 4 + cert = 2 # Write the result to disk so postinst can have a look at it with open("/tmp/howdy_picked_device", "w") as out_file: diff --git a/src/cli.py b/src/cli.py index 863ac25..b7c66fa 100755 --- a/src/cli.py +++ b/src/cli.py @@ -108,4 +108,4 @@ elif args.command == "snapshot": elif args.command == "test": import cli.test else: - print("Howdy 2.6.0") + print("Howdy 2.6.1") From 9fca6ab837657429a31f7e4c83416bdcedd91385 Mon Sep 17 00:00:00 2001 From: boltgolt Date: Wed, 2 Sep 2020 17:14:05 +0200 Subject: [PATCH 12/12] Moved cv2 import after dlib import --- src/cli/add.py | 4 +++- src/cli/test.py | 2 +- src/compare.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cli/add.py b/src/cli/add.py index 27b1364..112eacd 100644 --- a/src/cli/add.py +++ b/src/cli/add.py @@ -7,7 +7,6 @@ import sys import json import configparser import builtins -import cv2 import numpy as np from recorders.video_capture import VideoCapture @@ -22,6 +21,9 @@ except ImportError as err: print("pip3 show dlib") sys.exit(1) +# OpenCV needs to be imported after dlib +import cv2 + # Get the absolute path to the current directory path = os.path.abspath(__file__ + "/..") diff --git a/src/cli/test.py b/src/cli/test.py index dbcd06d..c62fcef 100644 --- a/src/cli/test.py +++ b/src/cli/test.py @@ -5,8 +5,8 @@ import configparser import os import sys import time -import cv2 import dlib +import cv2 from recorders.video_capture import VideoCapture # Get the absolute path to the current file diff --git a/src/compare.py b/src/compare.py index 7dc640f..d0ea5ea 100644 --- a/src/compare.py +++ b/src/compare.py @@ -14,8 +14,8 @@ import sys import os import json import configparser -import cv2 import dlib +import cv2 import datetime import snapshot import numpy as np