summaryrefslogtreecommitdiffstats
path: root/cups-getpass.patch
diff options
context:
space:
mode:
Diffstat (limited to 'cups-getpass.patch')
-rw-r--r--cups-getpass.patch50
1 files changed, 50 insertions, 0 deletions
diff --git a/cups-getpass.patch b/cups-getpass.patch
new file mode 100644
index 0000000..7b089a7
--- /dev/null
+++ b/cups-getpass.patch
@@ -0,0 +1,50 @@
+diff -up cups-1.5b1/cups/usersys.c.getpass cups-1.5b1/cups/usersys.c
+--- cups-1.5b1/cups/usersys.c.getpass 2011-05-20 05:49:49.000000000 +0200
++++ cups-1.5b1/cups/usersys.c 2011-05-24 15:41:33.000000000 +0200
+@@ -43,6 +43,8 @@
+ #include "cups-private.h"
+ #include <stdlib.h>
+ #include <sys/stat.h>
++#include <termios.h>
++#include <signal.h>
+ #ifdef WIN32
+ # include <windows.h>
+ #else
+@@ -501,13 +503,31 @@ _cupsGetPassword(const char *prompt) /*
+ * empty password is treated as canceling the authentication request.
+ */
+
+- const char *password = getpass(prompt);
+- /* Password string */
+-
+- if (!password || !password[0])
+- return (NULL);
+- else
++ static char password[100];
++ struct termios oldtio, newtio;
++ sigset_t oldset, newset;
++ int nread;
++ sigprocmask (SIG_BLOCK, NULL, &newset);
++ sigaddset (&newset, SIGINT);
++ sigaddset (&newset, SIGTSTP);
++ sigprocmask (SIG_BLOCK, &newset, &oldset);
++ tcgetattr (STDIN_FILENO, &oldtio);
++ newtio = oldtio;
++ newtio.c_lflag &= ~ECHO;
++ tcsetattr (STDIN_FILENO, TCSAFLUSH, &newtio);
++ fputs (prompt, stdout);
++ fflush (stdout);
++ nread = read (STDIN_FILENO, password, sizeof (password));
++ tcsetattr (STDIN_FILENO, TCSAFLUSH, &oldtio);
++ fputc ('\n', stdout);
++ sigprocmask (SIG_SETMASK, &oldset, NULL);
++ if (nread > 0)
++ {
++ password[nread - 1] = '\0';
+ return (password);
++ }
++ else
++ return (NULL);
+ #endif /* WIN32 */
+ }
+