]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blob - cups/patches/cups-getpass.patch
Change file layout of the makefiles.
[people/arne_f/ipfire-3.x.git] / cups / patches / cups-getpass.patch
1 diff -up cups-1.4.4/cups/usersys.c.getpass cups-1.4.4/cups/usersys.c
2 --- cups-1.4.4/cups/usersys.c.getpass 2010-03-30 23:07:33.000000000 +0100
3 +++ cups-1.4.4/cups/usersys.c 2010-06-18 09:38:08.368096897 +0100
4 @@ -41,6 +41,8 @@
5 #include "globals.h"
6 #include <stdlib.h>
7 #include <sys/stat.h>
8 +#include <termios.h>
9 +#include <signal.h>
10 #ifdef WIN32
11 # include <windows.h>
12 #else
13 @@ -406,7 +408,29 @@ _cupsGetPassword(const char *prompt) /*
14 * Use the standard getpass function to get a password from the console.
15 */
16
17 - return (getpass(prompt));
18 + static char password[100];
19 + struct termios oldtio, newtio;
20 + sigset_t oldset, newset;
21 + int nread;
22 + sigprocmask (SIG_BLOCK, NULL, &newset);
23 + sigaddset (&newset, SIGINT);
24 + sigaddset (&newset, SIGTSTP);
25 + sigprocmask (SIG_BLOCK, &newset, &oldset);
26 + tcgetattr (STDIN_FILENO, &oldtio);
27 + newtio = oldtio;
28 + newtio.c_lflag &= ~ECHO;
29 + tcsetattr (STDIN_FILENO, TCSAFLUSH, &newtio);
30 + fputs (prompt, stdout);
31 + fflush (stdout);
32 + nread = read (STDIN_FILENO, password, sizeof (password));
33 + tcsetattr (STDIN_FILENO, TCSAFLUSH, &oldtio);
34 + fputc ('\n', stdout);
35 + sigprocmask (SIG_SETMASK, &oldset, NULL);
36 + if (nread > 0)
37 + password[nread - 1] = '\0';
38 + else
39 + password[0] ='\0';
40 + return password;
41 #endif /* WIN32 */
42 }
43