7363fb09df
- Merge patches for FATE#314506 + Add mokutil-support-delete-keys.patch to delete specific keys + Add mokutil-support-new-pw-hash.patch to support the new password format + Add mokutil-allow-password-from-pipe.patch to allow the password to be generated in a script and be sent through pipeline - Install COPYING OBS-URL: https://build.opensuse.org/request/show/148683 OBS-URL: https://build.opensuse.org/package/show/Base:System/mokutil?expand=0&rev=2
51 lines
1.2 KiB
Diff
51 lines
1.2 KiB
Diff
commit adce7208ddcb65daac83ea3429aa8586d9cc4ea5
|
|
Author: Gary Ching-Pang Lin <glin@suse.com>
|
|
Date: Wed Jan 2 17:30:07 2013 +0800
|
|
|
|
Only change terminal settings
|
|
|
|
tcgetattr() will fail if we send password through a pipeline instead
|
|
of a TTY.
|
|
|
|
diff --git a/src/mokutil.c b/src/mokutil.c
|
|
index a99e355..ea8481a 100644
|
|
--- a/src/mokutil.c
|
|
+++ b/src/mokutil.c
|
|
@@ -278,22 +278,27 @@ read_hidden_line (char **line, size_t *n)
|
|
{
|
|
struct termios old, new;
|
|
int nread;
|
|
+ int isTTY = isatty(fileno (stdin));
|
|
|
|
- /* Turn echoing off and fail if we can't. */
|
|
- if (tcgetattr (fileno (stdin), &old) != 0)
|
|
- return -1;
|
|
+ if (isTTY) {
|
|
+ /* Turn echoing off and fail if we can't. */
|
|
+ if (tcgetattr (fileno (stdin), &old) != 0)
|
|
+ return -1;
|
|
|
|
- new = old;
|
|
- new.c_lflag &= ~ECHO;
|
|
+ new = old;
|
|
+ new.c_lflag &= ~ECHO;
|
|
|
|
- if (tcsetattr (fileno (stdin), TCSAFLUSH, &new) != 0)
|
|
- return -1;
|
|
+ if (tcsetattr (fileno (stdin), TCSAFLUSH, &new) != 0)
|
|
+ return -1;
|
|
+ }
|
|
|
|
/* Read the password. */
|
|
nread = getline (line, n, stdin);
|
|
|
|
- /* Restore terminal. */
|
|
- (void) tcsetattr (fileno (stdin), TCSAFLUSH, &old);
|
|
+ if (isTTY) {
|
|
+ /* Restore terminal. */
|
|
+ (void) tcsetattr (fileno (stdin), TCSAFLUSH, &old);
|
|
+ }
|
|
|
|
/* Remove the newline */
|
|
(*line)[nread-1] = '\0';
|