26static char * quiet_fgets (
char *buf,
int length, FILE *input)
31 memset (buf, 0, length);
33 if (!isatty(fileno(input))) {
34 return fgets(buf,length,input);
40#if defined (_WIN32_WCE)
51 else if (--length > 0)
54 if (!c || c ==
'\n' || c ==
'\r')
66 char phrase[200] = {
'\0'};
67 int isInputTerminal = isatty(fileno(stdin));
69 (void) arg; (void) prompt;
72 if (isInputTerminal) {
75 fprintf(stderr,
"Error opening input terminal for read\n");
81 if (isInputTerminal) {
82 fprintf(stdout,
"Please enter your password:\n");
88 if (isInputTerminal) {
89 fprintf(stdout,
"\n");
93 if (isInputTerminal) {
99 if (phrase[PORT_Strlen(phrase)-1] ==
'\n' ||
100 phrase[PORT_Strlen(phrase)-1] ==
'\r') {
101 phrase[PORT_Strlen(phrase)-1] = 0;
103 return (
char*) PORT_Strdup(phrase);
109 char* phrases, *phrase;
114 const long maxPwdFileSize = 4096;
115 char* tokenName =
NULL;
125 phrases = PORT_ZAlloc(maxPwdFileSize + 1);
131 fd = PR_Open(pwFile, PR_RDONLY, 0);
133 fprintf(stderr,
"No password file \"%s\" exists.\n", pwFile);
138 nb = PR_Read(fd, phrases, maxPwdFileSize);
143 fprintf(stderr,
"password file contains no data\n");
149 tokenName = PK11_GetTokenName(slot);
151 tokenLen = PORT_Strlen(tokenName);
161 while (
i < nb && phrases[
i] !=
'\r' && phrases[
i] !=
'\n')
i++;
165 while ( (
i<nb) && (phrases[
i] ==
'\r' || phrases[
i] ==
'\n')) {
169 phrase = &phrases[startphrase];
172 if (PORT_Strncmp(phrase, tokenName, tokenLen))
continue;
173 phraseLen = PORT_Strlen(phrase);
174 if (phraseLen < (tokenLen+1))
continue;
175 if (phrase[tokenLen] !=
':')
continue;
176 phrase = &phrase[tokenLen+1];
181 phrase = PORT_Strdup((
char*)phrase);
192 secuPWData pwxtrn = { PW_EXTERNAL,
"external" };
198 if (PK11_ProtectedAuthenticationPath(slot)) {
201 if (retry && pwdata->
source != PW_NONE) {
202 PR_fprintf(PR_STDERR,
"Incorrect password/PIN entered.\n");
208 sprintf(prompt,
"Enter Password or Pin for \"%s\":",
209 PK11_GetTokenName(slot));
216 pwdata->
source = PW_PLAINTEXT;
217 pwdata->
data = strdup(pw);
222 "Press Enter, then enter PIN for \"%s\" on external device.\n",
223 PK11_GetTokenName(slot));
226 memset(pw, 0, PORT_Strlen(pw));
231 return strdup(pwdata->
data);
236 PR_fprintf(PR_STDERR,
"Password check failed: No password found.\n");
int sprintf(char(&s)[N], char const *format, T &&... arguments)
char * SECU_FilePasswd(PK11SlotInfo *slot, PRBool retry, void *arg)
static char consoleName[]
char * SECU_GetModulePassword(PK11SlotInfo *slot, PRBool retry, void *arg)
char * GetPasswordString(void *arg, char *prompt)
enum secuPWData::@0 source