diff --git a/howdy/debian/postinst b/howdy/debian/postinst index 579081e..b8090e1 100755 --- a/howdy/debian/postinst +++ b/howdy/debian/postinst @@ -88,6 +88,10 @@ if "upgrade" in sys.argv: key = "abort_if_ssh" if key == "ignore_closed_lid": key = "abort_if_lid_closed" + if key == "capture_failed": + key = "save_failed" + if key == "capture_successful": + key = "save_successful" try: newConf.set(section, key, value) diff --git a/howdy/src/compare.py b/howdy/src/compare.py index 9d07dd7..7efa64a 100644 --- a/howdy/src/compare.py +++ b/howdy/src/compare.py @@ -146,8 +146,8 @@ timeout = config.getint("video", "timeout", fallback=5) dark_threshold = config.getfloat("video", "dark_threshold", fallback=50.0) video_certainty = config.getfloat("video", "certainty", fallback=3.5) / 10 end_report = config.getboolean("debug", "end_report", fallback=False) -capture_failed = config.getboolean("snapshots", "capture_failed", fallback=False) -capture_successful = config.getboolean("snapshots", "capture_successful", fallback=False) +save_failed = config.getboolean("snapshots", "save_failed", fallback=False) +save_successful = config.getboolean("snapshots", "save_successful", fallback=False) gtk_stdout = config.getboolean("debug", "gtk_stdout", fallback=False) rotate = config.getint("video", "rotate", fallback=0) @@ -232,7 +232,7 @@ while True: # Stop if we've exceded the time limit if time.time() - timings["fr"] > timeout: # Create a timeout snapshot if enabled - if capture_failed: + if save_failed: make_snapshot(_("FAILED")) if dark_tries == valid_frames: @@ -247,7 +247,7 @@ while True: gsframe = clahe.apply(gsframe) # If snapshots have been turned on - if capture_failed or capture_successful: + if save_failed or save_successful: # Start capturing frames for the snapshot if len(snapframes) < 3: snapframes.append(frame) @@ -354,7 +354,7 @@ while True: print(_("Winning model: %d (\"%s\")") % (match_index, models[match_index]["label"])) # Make snapshot if enabled - if capture_successful: + if save_successful: make_snapshot(_("SUCCESSFUL")) # Run rubberstamps if enabled diff --git a/howdy/src/pam.py b/howdy/src/pam.py index 262b24c..14aa9e1 100644 --- a/howdy/src/pam.py +++ b/howdy/src/pam.py @@ -4,13 +4,17 @@ import subprocess import os import glob +import sys import syslog -# pam-python is running python 2, so we use the old module here -import ConfigParser +if sys.version_info.major < 3: + import ConfigParser + config = ConfigParser.ConfigParser() +else: + import configparser + config = configparser.ConfigParser() # Read config from disk -config = ConfigParser.ConfigParser() config.read(os.path.dirname(os.path.abspath(__file__)) + "/config.ini") @@ -19,22 +23,22 @@ def doAuth(pamh): # Abort if Howdy is disabled if config.getboolean("core", "disabled"): + pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Howdy is disabled.")) return pamh.PAM_AUTHINFO_UNAVAIL - # Abort if we're in a remote SSH env - if config.getboolean("core", "ignore_ssh"): + if config.getboolean("core", "abort_if_ssh"): if "SSH_CONNECTION" in os.environ or "SSH_CLIENT" in os.environ or "SSHD_OPTS" in os.environ: + pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Howdy is disabled in ssh.")) return pamh.PAM_AUTHINFO_UNAVAIL - # Abort if lid is closed - if config.getboolean("core", "ignore_closed_lid"): + if config.getboolean("core", "abort_if_lid_closed"): if any("closed" in open(f).read() for f in glob.glob("/proc/acpi/button/lid/*/state")): + pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "LID is closed.")) 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.") + pamh.conversation(pamh.Message(pamh.PAM_ERROR_MSG, "Camera path is not configured correctly, please edit the 'device_path' config value.")) return pamh.PAM_AUTHINFO_UNAVAIL # Set up syslog diff --git a/howdy/src/pam/main.cc b/howdy/src/pam/main.cc index 530d5c8..135ea03 100644 --- a/howdy/src/pam/main.cc +++ b/howdy/src/pam/main.cc @@ -141,7 +141,7 @@ auto check_enabled(const INIReader &config) -> int { } // Stop if we're in a remote shell and configured to exit - if (config.GetBoolean("core", "ignore_ssh", true)) { + if (config.GetBoolean("core", "abort_if_ssh", true)) { if (getenv("SSH_CONNECTION") != nullptr || getenv("SSH_CLIENT") != nullptr || getenv("SSHD_OPTS") != nullptr) { syslog(LOG_INFO, "Skipped authentication, SSH session detected"); @@ -150,7 +150,7 @@ auto check_enabled(const INIReader &config) -> int { } // Try to detect the laptop lid state and stop if it's closed - if (config.GetBoolean("core", "ignore_closed_lid", true)) { + if (config.GetBoolean("core", "abort_if_lid_closed", true)) { glob_t glob_result; // Get any files containing lid state