51 lines
1.4 KiB
Diff
51 lines
1.4 KiB
Diff
|
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 */
|
||
|
}
|
||
|
|