From b534442b9d2b671d4d8cc7d9da9e14ba5c86e315 Mon Sep 17 00:00:00 2001 From: boltgolt Date: Fri, 13 Apr 2018 14:54:06 +0200 Subject: [PATCH] Reworking command line --- .travis.yml | 11 ++++++----- README.md | 5 ++--- debian/prerm | 1 + src/cli.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index d27dc7f..774d48c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,17 @@ language: python sudo: required -before_install: +install: - sudo apt install devscripts dh-make -y - - debuild -i -us -uc -b - -install: sudo apt install ../*.deb -y script: + - debuild -i -us -uc -b + - sudo apt install ../*.deb -y - sudo howdy help - sudo howdy list - sudo apt purge howdy -y notifications: - email: true + email: + on_success: never + on_failure: always diff --git a/README.md b/README.md index 720f89d..02ab96c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Howdy for Ubuntu [![](https://travis-ci.org/Boltgolt/howdy.svg?branch=dev)](https://travis-ci.org/Boltgolt/howdy) ![](https://img.shields.io/github/release/Boltgolt/howdy.svg?colorB=4c1) [![](https://img.shields.io/github/issues-raw/Boltgolt/howdy/enhancement.svg?label=feature+requests&colorB=4c1)](https://github.com/Boltgolt/howdy/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) +# Howdy for Ubuntu [![](https://img.shields.io/travis/Boltgolt/howdy/dev.svg)](https://travis-ci.org/Boltgolt/howdy) [![](https://img.shields.io/github/release/Boltgolt/howdy.svg?colorB=4c1)](https://github.com/Boltgolt/howdy/releases) [![](https://img.shields.io/github/issues-raw/Boltgolt/howdy/enhancement.svg?label=feature+requests&colorB=4c1)](https://github.com/Boltgolt/howdy/issues?q=is%3Aissue+is%3Aopen+label%3Aenhancement) Windows Helloâ„¢ style authentication for Ubuntu. Use your built-in IR emitters and camera in combination with face recognition to prove who you are. @@ -35,7 +35,6 @@ howdy [user] [argument] | `clear` | Remove all face models for the given user | Yes | | `config` | Open the config file in nano | No | | `disable` | Disable or enable howdy | No | -| `help` | Show a help page | No | | `list` | List all saved face models for the given user | Yes | | `remove` | Remove a specific model for the given user | Yes | | `test` | Test the camera and recognition methods | No | @@ -50,6 +49,6 @@ If you encounter an error that hasn't been reported yet, don't be afraid to open This script is in no way as secure as a password and will never be. Although it's harder to fool than normal face recognition, a person who looks similar to you or well-printed photo of you could be enough to do it. -To minimize the chance of this script being compromised, it's recommend to leave this repo in /lib/security and to keep it read only. +To minimize the chance of this program being compromised, it's recommend to leave Howdy in /lib/security and to keep it read only. DO NOT USE HOWDY AS THE SOLE AUTHENTICATION METHOD FOR YOUR SYSTEM. diff --git a/debian/prerm b/debian/prerm index 8c32076..62f4552 100755 --- a/debian/prerm +++ b/debian/prerm @@ -11,6 +11,7 @@ def col(id): # Import required modules import subprocess +import sys # Only run when we actually want to remove if "remove" not in sys.argv and "purge" not in sys.argv: diff --git a/src/cli.py b/src/cli.py index bdbf064..203a455 100755 --- a/src/cli.py +++ b/src/cli.py @@ -4,6 +4,58 @@ # Import required modules import sys import os +import subprocess +import getpass +import argparse + +user = subprocess.check_output("echo $(logname 2>/dev/null || echo $SUDO_USER)", shell=True).decode("ascii").strip() + +if user == "root" or user == "": + env_user = getpass.getuser().strip() + + if env_user == "root" or env_user == "": + print("Could not determine user, please use the --user flag") + sys.exit(1) + else: + user = env_user + +parser = argparse.ArgumentParser(description="Command line interface for Howdy face authentication.", + formatter_class=argparse.RawDescriptionHelpFormatter, + add_help=False, + prog="howdy", + epilog="For support please visit\nhttps://github.com/Boltgolt/howdy") + + +parser.add_argument("command", + help="The command option to execute, can be one of the following: add, clear, config, disable, list, remove or test.", + metavar="command", + choices=["add", "clear", "config", "disable", "list", "remove", "test"]) + +parser.add_argument("argument", + help="Either 0 or 1 for the disable command, or the model ID for the remove command.", + nargs="?") + +parser.add_argument("-U", "--user", + default=user, + help="Set the user account to use.") + +parser.add_argument("-y", + help="Skip all questions.", + action="store_true") + +parser.add_argument("-h", "--help", + action="help", + default=argparse.SUPPRESS, + help="Show this help message and exit.") + +if len(sys.argv) < 2: + parser.print_help() + sys.exit(0) + +args = parser.parse_args() + +print(args) +sys.exit(1) # Check if if a command has been given and print help otherwise if (len(sys.argv) < 2):