diff options
Diffstat (limited to 'nlplug-findfs.c')
-rw-r--r-- | nlplug-findfs.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/nlplug-findfs.c b/nlplug-findfs.c index 7104d40..3f6680d 100644 --- a/nlplug-findfs.c +++ b/nlplug-findfs.c @@ -516,11 +516,15 @@ static int read_pass(char *pass, size_t pass_size) new_flags.c_lflag &= ~ECHO; new_flags.c_lflag |= ECHONL; - r = tcsetattr(STDIN_FILENO, TCSANOW, &new_flags); - if (r < 0) { - warn("tcsetattr"); - return r; - } + if (isatty(STDIN_FILENO)) { + r = tcsetattr(STDIN_FILENO, TCSANOW, &new_flags); + if (r < 0) { + warn("tcsetattr"); + return r; + } + }// else { + // fprintf(stderr, "The program isn't executed in a TTY, the echo-disabling has been skipped.\n"); + //} if (fgets(pass, pass_size, stdin) == NULL) { warn("fgets"); @@ -528,10 +532,14 @@ static int read_pass(char *pass, size_t pass_size) } pass[strlen(pass) - 1] = '\0'; - if (tcsetattr(STDIN_FILENO, TCSANOW, &old_flags) < 0) { - warn("tcsetattr"); - return r; - } + if (isatty(STDIN_FILENO)) { + if (tcsetattr(STDIN_FILENO, TCSANOW, &old_flags) < 0) { + warn("tcsetattr"); + return r; + } + }// else { + // fprintf(stderr, "The program isn't executed in a TTY, the echo-reenabling has been skipped.\n"); + //} return 0; } |