diff options
author | Mattias Andrée <maandree@kth.se> | 2021-02-01 17:43:16 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-02-01 17:43:16 +0100 |
commit | 453fc14702f09299dd9745d31afff4007d0f76ae (patch) | |
tree | f3ffde3f816a8ea33a9355ca3d780d28330c1f86 /asroot.c | |
parent | Add customisation instructions to config.mk, rename ERROR_SLEEP to RETRY_SLEEP, and remove sleep instruction if RETRY_SLEEP is nonpositive (diff) | |
download | asroot-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 'asroot.c')
-rw-r--r-- | asroot.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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; } |