summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2010-05-05 14:43:54 +0200
committerJiri Moskovcak <jmoskovc@redhat.com>2010-05-05 14:43:54 +0200
commit8aa4ea81a4328abc30e270aafd9f94637e38f322 (patch)
tree29ca0474cadedd73da6e2e2c053ca36fb8d0e758 /src
parentfc4a8200a01a2a1aa371d90dd3f5c76e78f760b4 (diff)
parent40ab6c1093012099afe89fbe5944bbcf9184d3a5 (diff)
downloadabrt-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.cpp28
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);
}
}