diff --git a/src/config.ini b/src/config.ini index 4b694bf..b9c2d06 100644 --- a/src/config.ini +++ b/src/config.ini @@ -40,6 +40,9 @@ timeout = 4 # Should be set automatically by an installer if your distro has one device_path = none +# Print a warning if the the video device is not found +warn_no_device = true + # Scale down the video feed to this maximum height # Speeds up face recognition but can make it less precise max_height = 320 diff --git a/src/pam.py b/src/pam.py index 08cccef..36af375 100644 --- a/src/pam.py +++ b/src/pam.py @@ -31,6 +31,12 @@ 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 + # Abort if the video device does not exist + if not os.path.exists(config.get("video", "device_path")): + if config.getboolean("video", "warn_no_device"): + print("Camera path is not configured correctly, please edit the 'device_path' config value.") + return pamh.PAM_AUTHINFO_UNAVAIL + # Set up syslog syslog.openlog("[HOWDY]", 0, syslog.LOG_AUTH)