From 6e48590a4b26fad71d6a0b3320f59d696dbcdeb5 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 1 Feb 2021 17:41:31 +0100 Subject: Add customisation instructions to config.mk, rename ERROR_SLEEP to RETRY_SLEEP, and remove sleep instruction if RETRY_SLEEP is nonpositive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- asroot.c | 8 +++++--- config.mk | 13 +++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/asroot.c b/asroot.c index f53c0c4..7db8eac 100644 --- a/asroot.c +++ b/asroot.c @@ -20,8 +20,8 @@ #define EXIT_EXEC 126 #define EXIT_NOENT 127 -#ifndef ERROR_SLEEP -# define ERROR_SLEEP 1 +#ifndef RETRY_SLEEP +# define RETRY_SLEEP 1 #endif #ifndef PROMPT @@ -342,7 +342,9 @@ again: if (strcmp(got, expected)) { fprintf(stderr, "%s: incorrect password, please try again\n", argv0); tcsetattr(fd, TCSAFLUSH, &stty_sleep); - sleep(ERROR_SLEEP); +#if RETRY_SLEEP > 0 + sleep(RETRY_SLEEP); +#endif tcsetattr(fd, TCSAFLUSH, &stty_enter); goto again; } diff --git a/config.mk b/config.mk index 47b82f7..90c3672 100644 --- a/config.mk +++ b/config.mk @@ -5,4 +5,17 @@ CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE CFLAGS = -std=c99 -Wall -O2 $(CPPFLAGS) LDFLAGS = -s -lcrypt + # To use libpassphrase, add -DWITH_LIBPASSPHRASE to CPPFLAGS and -lpassphrase to LDFLAGS + +# To customise the sleep time between authentication attempts, add -DRETRY_SLEEP=### +# to CPPFLAGS, where ### is the number of seconds (integers only) to sleep, the +# default ### is 1 (= 1 second) + +# To customise the password prompt, add -DPROMPT=### to CPPFLAGS, where ### is the +# format string and arguments for fprintf(3), do not forget quotes to escape spaces, +# the default ### is (with the surrounding quotes) +# '"%s (%s@%s) password: ", argv0, pwd->pw_name, hostname' +# argv0 is the name of the process, +# pwd->pw_name is the user name, and +# hostname is the machine name -- cgit v1.2.3-70-g09d2