| 184 | |
| 185 | #ifndef SILENT |
| 186 | bool GetConsolePassword(UIPASSWORD_TYPE Type,const wchar *FileName,SecPassword *Password) |
| 187 | { |
| 188 | if (!StdinRedirected) |
| 189 | uiAlarm(UIALARM_QUESTION); |
| 190 | |
| 191 | while (true) |
| 192 | { |
| 193 | if (!StdinRedirected) |
| 194 | if (Type==UIPASSWORD_GLOBAL) |
| 195 | eprintf(L"\n%s: ",St(MAskPsw)); |
| 196 | else |
| 197 | eprintf(St(MAskPswFor),FileName); |
| 198 | |
| 199 | wchar PlainPsw[MAXPASSWORD]; |
| 200 | GetPasswordText(PlainPsw,ASIZE(PlainPsw)); |
| 201 | if (*PlainPsw==0 && Type==UIPASSWORD_GLOBAL) |
| 202 | return false; |
| 203 | if (!StdinRedirected && Type==UIPASSWORD_GLOBAL) |
| 204 | { |
| 205 | eprintf(St(MReAskPsw)); |
| 206 | wchar CmpStr[MAXPASSWORD]; |
| 207 | GetPasswordText(CmpStr,ASIZE(CmpStr)); |
| 208 | if (*CmpStr==0 || wcscmp(PlainPsw,CmpStr)!=0) |
| 209 | { |
| 210 | eprintf(St(MNotMatchPsw)); |
| 211 | cleandata(PlainPsw,sizeof(PlainPsw)); |
| 212 | cleandata(CmpStr,sizeof(CmpStr)); |
| 213 | continue; |
| 214 | } |
| 215 | cleandata(CmpStr,sizeof(CmpStr)); |
| 216 | } |
| 217 | Password->Set(PlainPsw); |
| 218 | cleandata(PlainPsw,sizeof(PlainPsw)); |
| 219 | break; |
| 220 | } |
| 221 | return true; |
| 222 | } |
| 223 | #endif |
| 224 | |
| 225 |
no test coverage detected