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
=== modified file 'client/get_password.cc'
--- client/get_password.cc 2010-06-19 16:36:52 +0000
+++ client/get_password.cc 2010-10-13 12:21:46 +0000
@@ -73,8 +73,8 @@
73 {73 {
74 if (echo)74 if (echo)
75 {75 {
76 fputs("\b \b",stdout);76 fputs("\b \b",stderr);
77 fflush(stdout);77 fflush(stderr);
78 }78 }
79 pos--;79 pos--;
80 continue;80 continue;
@@ -84,11 +84,6 @@
84 break;84 break;
85 if (iscntrl(tmp) || pos == end)85 if (iscntrl(tmp) || pos == end)
86 continue;86 continue;
87 if (echo)
88 {
89 fputc('*',stdout);
90 fflush(stdout);
91 }
92 *(pos++) = tmp;87 *(pos++) = tmp;
93 }88 }
94 while (pos != to && isspace(pos[-1]) == ' ')89 while (pos != to && isspace(pos[-1]) == ' ')
@@ -103,10 +98,10 @@
103 TERMIO org,tmp;98 TERMIO org,tmp;
104 char buff[80];99 char buff[80];
105100
106 if (isatty(fileno(stdout)))101 if (isatty(fileno(stderr)))
107 {102 {
108 fputs(opt_message ? opt_message : "Enter password: ",stdout);103 fputs(opt_message ? opt_message : "Enter password: ",stderr);
109 fflush(stdout);104 fflush(stderr);
110 }105 }
111# if defined(HAVE_TERMIOS_H)106# if defined(HAVE_TERMIOS_H)
112 tcgetattr(fileno(stdin), &org);107 tcgetattr(fileno(stdin), &org);
@@ -115,7 +110,7 @@
115 tmp.c_cc[VMIN] = 1;110 tmp.c_cc[VMIN] = 1;
116 tmp.c_cc[VTIME] = 0;111 tmp.c_cc[VTIME] = 0;
117 tcsetattr(fileno(stdin), TCSADRAIN, &tmp);112 tcsetattr(fileno(stdin), TCSADRAIN, &tmp);
118 get_password(buff, sizeof(buff)-1, fileno(stdin), isatty(fileno(stdout)));113 get_password(buff, sizeof(buff)-1, fileno(stdin), isatty(fileno(stderr)));
119 tcsetattr(fileno(stdin), TCSADRAIN, &org);114 tcsetattr(fileno(stdin), TCSADRAIN, &org);
120# elif defined(HAVE_TERMIO_H)115# elif defined(HAVE_TERMIO_H)
121 ioctl(fileno(stdin), (int) TCGETA, &org);116 ioctl(fileno(stdin), (int) TCGETA, &org);
@@ -124,7 +119,7 @@
124 tmp.c_cc[VMIN] = 1;119 tmp.c_cc[VMIN] = 1;
125 tmp.c_cc[VTIME]= 0;120 tmp.c_cc[VTIME]= 0;
126 ioctl(fileno(stdin),(int) TCSETA, &tmp);121 ioctl(fileno(stdin),(int) TCSETA, &tmp);
127 get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout)));122 get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stderr)));
128 ioctl(fileno(stdin),(int) TCSETA, &org);123 ioctl(fileno(stdin),(int) TCSETA, &org);
129# else124# else
130 gtty(fileno(stdin), &org);125 gtty(fileno(stdin), &org);
@@ -132,11 +127,11 @@
132 tmp.sg_flags &= ~ECHO;127 tmp.sg_flags &= ~ECHO;
133 tmp.sg_flags |= RAW;128 tmp.sg_flags |= RAW;
134 stty(fileno(stdin), &tmp);129 stty(fileno(stdin), &tmp);
135 get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout)));130 get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stderr)));
136 stty(fileno(stdin), &org);131 stty(fileno(stdin), &org);
137# endif132# endif
138 if (isatty(fileno(stdout)))133 if (isatty(fileno(stderr)))
139 fputc('\n',stdout);134 fputc('\n',stderr);
140135
141 return strdup(buff);136 return strdup(buff);
142}137}