|
|
4743e10 |
diff -up cups-1.5b1/cups/usersys.c.getpass cups-1.5b1/cups/usersys.c
|
|
|
4743e10 |
--- cups-1.5b1/cups/usersys.c.getpass 2011-05-20 05:49:49.000000000 +0200
|
|
|
4743e10 |
+++ cups-1.5b1/cups/usersys.c 2011-05-24 15:41:33.000000000 +0200
|
|
|
4743e10 |
@@ -43,6 +43,8 @@
|
|
|
4743e10 |
#include "cups-private.h"
|
|
|
cf5e76c |
#include <stdlib.h>
|
|
|
cf5e76c |
#include <sys/stat.h>
|
|
|
cf5e76c |
+#include <termios.h>
|
|
|
7b0f973 |
+#include <signal.h>
|
|
|
cf5e76c |
#ifdef WIN32
|
|
|
cf5e76c |
# include <windows.h>
|
|
|
d509400 |
#else
|
|
|
4743e10 |
@@ -501,13 +503,31 @@ _cupsGetPassword(const char *prompt) /*
|
|
|
4743e10 |
* empty password is treated as canceling the authentication request.
|
|
|
d509400 |
*/
|
|
|
d509400 |
|
|
|
4743e10 |
- const char *password = getpass(prompt);
|
|
|
4743e10 |
- /* Password string */
|
|
|
4743e10 |
-
|
|
|
4743e10 |
- if (!password || !password[0])
|
|
|
4743e10 |
- return (NULL);
|
|
|
4743e10 |
- else
|
|
|
cf5e76c |
+ static char password[100];
|
|
|
7b0f973 |
+ struct termios oldtio, newtio;
|
|
|
7b0f973 |
+ sigset_t oldset, newset;
|
|
|
cf5e76c |
+ int nread;
|
|
|
7b0f973 |
+ sigprocmask (SIG_BLOCK, NULL, &newset);
|
|
|
7b0f973 |
+ sigaddset (&newset, SIGINT);
|
|
|
7b0f973 |
+ sigaddset (&newset, SIGTSTP);
|
|
|
7b0f973 |
+ sigprocmask (SIG_BLOCK, &newset, &oldset);
|
|
|
7b0f973 |
+ tcgetattr (STDIN_FILENO, &oldtio);
|
|
|
7b0f973 |
+ newtio = oldtio;
|
|
|
7b0f973 |
+ newtio.c_lflag &= ~ECHO;
|
|
|
7b0f973 |
+ tcsetattr (STDIN_FILENO, TCSAFLUSH, &newtio);
|
|
|
cf5e76c |
+ fputs (prompt, stdout);
|
|
|
cf5e76c |
+ fflush (stdout);
|
|
|
cf5e76c |
+ nread = read (STDIN_FILENO, password, sizeof (password));
|
|
|
7b0f973 |
+ tcsetattr (STDIN_FILENO, TCSAFLUSH, &oldtio);
|
|
|
cf5e76c |
+ fputc ('\n', stdout);
|
|
|
7b0f973 |
+ sigprocmask (SIG_SETMASK, &oldset, NULL);
|
|
|
cf5e76c |
+ if (nread > 0)
|
|
|
4743e10 |
+ {
|
|
|
cf5e76c |
+ password[nread - 1] = '\0';
|
|
|
4743e10 |
return (password);
|
|
|
4743e10 |
+ }
|
|
|
cf5e76c |
+ else
|
|
|
4743e10 |
+ return (NULL);
|
|
|
cf5e76c |
#endif /* WIN32 */
|
|
|
d509400 |
}
|
|
|
cf5e76c |
|