Merge lp:~linuxjedi/drizzle/elliott-password-bugs into lp:~drizzle-trunk/drizzle/development

Proposed by Andrew Hutchings
Status: Merged
Approved by: Brian Aker
Approved revision: 1840
Merged at revision: 1849
Proposed branch: lp:~linuxjedi/drizzle/elliott-password-bugs
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 73 lines (+10/-15)
1 file modified
client/get_password.cc (+10/-15)
To merge this branch: bzr merge lp:~linuxjedi/drizzle/elliott-password-bugs
Reviewer Review Type Date Requested Status
Drizzle Merge Team Pending
Review via email: mp+38318@code.launchpad.net

Description of the change

Output client password prompt on stderr not stdout
Don't show '*' for password output as this indicates length

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client/get_password.cc'
2--- client/get_password.cc 2010-06-19 16:36:52 +0000
3+++ client/get_password.cc 2010-10-13 12:21:46 +0000
4@@ -73,8 +73,8 @@
5 {
6 if (echo)
7 {
8- fputs("\b \b",stdout);
9- fflush(stdout);
10+ fputs("\b \b",stderr);
11+ fflush(stderr);
12 }
13 pos--;
14 continue;
15@@ -84,11 +84,6 @@
16 break;
17 if (iscntrl(tmp) || pos == end)
18 continue;
19- if (echo)
20- {
21- fputc('*',stdout);
22- fflush(stdout);
23- }
24 *(pos++) = tmp;
25 }
26 while (pos != to && isspace(pos[-1]) == ' ')
27@@ -103,10 +98,10 @@
28 TERMIO org,tmp;
29 char buff[80];
30
31- if (isatty(fileno(stdout)))
32+ if (isatty(fileno(stderr)))
33 {
34- fputs(opt_message ? opt_message : "Enter password: ",stdout);
35- fflush(stdout);
36+ fputs(opt_message ? opt_message : "Enter password: ",stderr);
37+ fflush(stderr);
38 }
39 # if defined(HAVE_TERMIOS_H)
40 tcgetattr(fileno(stdin), &org);
41@@ -115,7 +110,7 @@
42 tmp.c_cc[VMIN] = 1;
43 tmp.c_cc[VTIME] = 0;
44 tcsetattr(fileno(stdin), TCSADRAIN, &tmp);
45- get_password(buff, sizeof(buff)-1, fileno(stdin), isatty(fileno(stdout)));
46+ get_password(buff, sizeof(buff)-1, fileno(stdin), isatty(fileno(stderr)));
47 tcsetattr(fileno(stdin), TCSADRAIN, &org);
48 # elif defined(HAVE_TERMIO_H)
49 ioctl(fileno(stdin), (int) TCGETA, &org);
50@@ -124,7 +119,7 @@
51 tmp.c_cc[VMIN] = 1;
52 tmp.c_cc[VTIME]= 0;
53 ioctl(fileno(stdin),(int) TCSETA, &tmp);
54- get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout)));
55+ get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stderr)));
56 ioctl(fileno(stdin),(int) TCSETA, &org);
57 # else
58 gtty(fileno(stdin), &org);
59@@ -132,11 +127,11 @@
60 tmp.sg_flags &= ~ECHO;
61 tmp.sg_flags |= RAW;
62 stty(fileno(stdin), &tmp);
63- get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout)));
64+ get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stderr)));
65 stty(fileno(stdin), &org);
66 # endif
67- if (isatty(fileno(stdout)))
68- fputc('\n',stdout);
69+ if (isatty(fileno(stderr)))
70+ fputc('\n',stderr);
71
72 return strdup(buff);
73 }