diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2010-05-05 14:43:54 +0200 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2010-05-05 14:43:54 +0200 |
commit | 8aa4ea81a4328abc30e270aafd9f94637e38f322 (patch) | |
tree | 29ca0474cadedd73da6e2e2c053ca36fb8d0e758 /src | |
parent | fc4a8200a01a2a1aa371d90dd3f5c76e78f760b4 (diff) | |
parent | 40ab6c1093012099afe89fbe5944bbcf9184d3a5 (diff) | |
download | abrt-8aa4ea81a4328abc30e270aafd9f94637e38f322.tar.gz abrt-8aa4ea81a4328abc30e270aafd9f94637e38f322.tar.xz abrt-8aa4ea81a4328abc30e270aafd9f94637e38f322.zip |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src')
-rw-r--r-- | src/CLI/report.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/CLI/report.cpp b/src/CLI/report.cpp index bff6a9a0..3946e6bb 100644 --- a/src/CLI/report.cpp +++ b/src/CLI/report.cpp @@ -24,6 +24,7 @@ #include "Plugin.h" // LoadPluginSettings #include <cassert> #include <algorithm> +#include <termios.h> #if HAVE_CONFIG_H # include <config.h> #endif @@ -529,6 +530,28 @@ static bool ask_yesno(const char *question) return ((answer[0] | 0x20) == 'y'); } +static void set_echo(bool enabled) +{ + if (isatty(STDIN_FILENO) == 0) + { + /* Clean errno, which is set by isatty. */ + errno = 0; + return; + } + + struct termios t; + if (tcgetattr(STDIN_FILENO, &t) < 0) + perror_msg_and_die("tcgetattr failed"); + + if (enabled) + t.c_lflag |= ECHO; + else + t.c_lflag &= ~ECHO; + + if (tcsetattr(STDIN_FILENO, TCSANOW, &t) < 0) + perror_msg_and_die("tcsetattr failed"); +} + /** * Gets reporter plugin settings. * @param reporters @@ -604,8 +627,11 @@ static void get_reporter_plugin_settings(const vector_string_t& reporters, } if (passwordMissing) { -// TODO: echo off, see http://fixunix.com/unix/84474-echo-off.html + set_echo(false); read_from_stdin(_("Enter your password: "), result, 64); + set_echo(true); + // Newline was not added by pressing Enter because ECHO was disabled, so add it now. + puts(""); single_plugin_settings["Password"] = std::string(result); } } |