From 517948d07aaa3eeac2b5fac03516dccc75a98bb6 Mon Sep 17 00:00:00 2001 From: boltgolt Date: Fri, 9 Nov 2018 11:49:03 +0100 Subject: [PATCH] Changes to compare and cli config command, proposed in #89 and #90 --- src/cli/config.py | 16 ++++++++++++---- src/pam.py | 8 ++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/cli/config.py b/src/cli/config.py index 9606f24..aaa5518 100644 --- a/src/cli/config.py +++ b/src/cli/config.py @@ -1,12 +1,20 @@ -# Open the config file in gedit +# Open the config file in an editor # Import required modules import os -import time import subprocess # Let the user know what we're doing print("Opening config.ini in the default editor") -# Open gedit as a subprocess and fork it -subprocess.call(["/etc/alternatives/editor", os.path.dirname(os.path.realpath(__file__)) + "/../config.ini"]) +# Default to the nano editor +editor = "/bin/nano" + +# Use the user preferred editor if available +if os.path.isfile("/etc/alternatives/editor"): + editor = "/etc/alternatives/editor" +elif "EDITOR" in os.environ: + editor = os.environ["EDITOR"] + +# Open the editor as a subprocess and fork it +subprocess.call([editor, os.path.dirname(os.path.realpath(__file__)) + "/../config.ini"]) diff --git a/src/pam.py b/src/pam.py index 5fd462e..42ee919 100644 --- a/src/pam.py +++ b/src/pam.py @@ -13,7 +13,7 @@ config = ConfigParser.ConfigParser() config.read(os.path.dirname(os.path.abspath(__file__)) + "/config.ini") def doAuth(pamh): - """Start authentication in a seperate process""" + """Starts authentication in a seperate process""" # Abort is Howdy is disabled if config.get("core", "disabled") == "true": @@ -25,7 +25,7 @@ def doAuth(pamh): sys.exit(0) # Run compare as python3 subprocess to circumvent python version and import issues - status = subprocess.call(["python3", os.path.dirname(os.path.abspath(__file__)) + "/compare.py", pamh.get_user()]) + status = subprocess.call(["/usr/bin/python3", os.path.dirname(os.path.abspath(__file__)) + "/compare.py", pamh.get_user()]) # Status 10 means we couldn't find any face models if status == 10: @@ -62,9 +62,9 @@ def pam_sm_open_session(pamh, flags, args): return doAuth(pamh) def pam_sm_close_session(pamh, flags, argv): - """We don't need to clean anyting up at the end of a session, so return true""" + """We don't need to clean anyting up at the end of a session, so returns true""" return pamh.PAM_SUCCESS def pam_sm_setcred(pamh, flags, argv): - """We don't need set any credentials, so return true""" + """We don't need set any credentials, so returns true""" return pamh.PAM_SUCCESS