From 495785d561070d4bab7d21c22551cccb6587f53d Mon Sep 17 00:00:00 2001 From: Thomas L Date: Sun, 30 Dec 2018 01:14:23 +0100 Subject: [PATCH] Initial commit --- LICENSE | 13 +++++++++++++ Makefile | 10 ++++++++++ login_-sober | 29 +++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 LICENSE create mode 100644 Makefile create mode 100755 login_-sober diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a2407c8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2018, Thomas L + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..24af096 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +.PHONY: all install + +PREFIX ?= /usr +LIBEXECDIR ?= ${PREFIX}/libexec + +all: + +install: + install -o root -g wheel -m 750 -d "$(DESTDIR)$(LIBEXECDIR)/auth" + install -o root -g auth -m 555 login_-sober "$(DESTDIR)$(LIBEXECDIR)/auth/login_-sober" diff --git a/login_-sober b/login_-sober new file mode 100755 index 0000000..ac92854 --- /dev/null +++ b/login_-sober @@ -0,0 +1,29 @@ +#!/bin/ksh + +while getopts 'v:s:' opt; do + case "$opt" in + v) + ;; + s) + if [ 'login' != "$OPTARG" ]; then + exit 1 + fi + ;; + *) + exit 1 + ;; + esac +done + +test_sentence="Please, type _exactly_ this sentence as fast as you can." +temp_file=$(mktemp) +echo "$test_sentence" +{ time -p read user_sentence; } 2> "$temp_file" +user_time=$(sed -ne 's/real *\([^.]*\).*/\1/p' < "$temp_file") +rm -f "$temp_file" + +if [ "$test_sentence" == "$user_sentence" -a "$user_time" -le 15 ]; then + exec /usr/libexec/auth/login_passwd "$@" +fi +echo "Too slow or inaccurate typing." +echo reject >&3