aboutsummaryrefslogtreecommitdiffstats
path: root/asroot.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-02-01 17:43:16 +0100
committerMattias Andrée <maandree@kth.se>2021-02-01 17:43:16 +0100
commit453fc14702f09299dd9745d31afff4007d0f76ae (patch)
treef3ffde3f816a8ea33a9355ca3d780d28330c1f86 /asroot.c
parentAdd customisation instructions to config.mk, rename ERROR_SLEEP to RETRY_SLEEP, and remove sleep instruction if RETRY_SLEEP is nonpositive (diff)
downloadasroot-453fc14702f09299dd9745d31afff4007d0f76ae.tar.gz
asroot-453fc14702f09299dd9745d31afff4007d0f76ae.tar.bz2
asroot-453fc14702f09299dd9745d31afff4007d0f76ae.tar.xz
Eliminiate unncessary code if RETRY_SLEEP is nonpositive
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--asroot.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/asroot.c b/asroot.c
index 7db8eac..65bc16f 100644
--- a/asroot.c
+++ b/asroot.c
@@ -229,7 +229,10 @@ check_password(void)
#ifndef WITH_LIBPASSPHRASE
struct termios stty_original;
#endif
- struct termios stty_enter, stty_sleep;
+ struct termios stty_enter;
+#if RETRY_SLEEP > 0
+ struct termios stty_sleep;
+#endif
int fd;
errno = 0;
@@ -307,8 +310,10 @@ check_password(void)
tcsetattr(fd, TCSAFLUSH, &stty_enter);
#endif
+#if RETRY_SLEEP > 0
memcpy(&stty_sleep, &stty_enter, sizeof(stty_enter));
stty_sleep.c_lflag = 0;
+#endif
again:
fprintf(stderr, PROMPT);
@@ -341,11 +346,11 @@ again:
if (strcmp(got, expected)) {
fprintf(stderr, "%s: incorrect password, please try again\n", argv0);
- tcsetattr(fd, TCSAFLUSH, &stty_sleep);
#if RETRY_SLEEP > 0
+ tcsetattr(fd, TCSAFLUSH, &stty_sleep);
sleep(RETRY_SLEEP);
-#endif
tcsetattr(fd, TCSAFLUSH, &stty_enter);
+#endif
goto again;
}