summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrelyea%netscape.com <devnull@localhost>2000-06-20 17:43:34 +0000
committerrelyea%netscape.com <devnull@localhost>2000-06-20 17:43:34 +0000
commit6f744f6a66a62cddb74e5852b26f1a111fde76d2 (patch)
treebff8e2c2a07f7f04a66f8302cbe9093aad64171a
parentd8fd84dc6997210b849a8fd7659db48ff02c85c5 (diff)
downloadnss-hg-6f744f6a66a62cddb74e5852b26f1a111fde76d2.tar.gz
Fix NT bugs with reading the password from a file.
-rw-r--r--security/nss/cmd/lib/secpwd.c4
-rw-r--r--security/nss/cmd/lib/secutil.c18
2 files changed, 19 insertions, 3 deletions
diff --git a/security/nss/cmd/lib/secpwd.c b/security/nss/cmd/lib/secpwd.c
index c235c3ffa..7f01b7c1a 100644
--- a/security/nss/cmd/lib/secpwd.c
+++ b/security/nss/cmd/lib/secpwd.c
@@ -155,6 +155,10 @@ static int quiet_fgets (char *buf, int length, FILE *input)
/* fflush (input); */
memset (buf, 0, length);
+ if (input != stdin) {
+ return fgets(buf,length,input);
+ }
+
while (1)
{
c = getch();
diff --git a/security/nss/cmd/lib/secutil.c b/security/nss/cmd/lib/secutil.c
index 27ae30436..bd2c5feca 100644
--- a/security/nss/cmd/lib/secutil.c
+++ b/security/nss/cmd/lib/secutil.c
@@ -256,6 +256,7 @@ SECU_FilePasswd(PK11SlotInfo *slot, PRBool retry, void *arg)
PR_Close(fd);
if (phrase[nb-1] == '\n') {
+ if ( nb > 2 && phrase[nb-2] == '\r' ) nb--;
phrase[nb-1] = '\0';
if (nb == 0) {
fprintf(stderr,"password file contains no data\n");
@@ -309,7 +310,11 @@ secu_InitSlotPassword(PK11SlotInfo *slot, PRBool retry, void *arg)
if (pwdata->source == PW_NONE) {
/* open terminal */
+#ifdef _WINDOWS
+ input = stdin;
+#else
input = fopen(consoleName, "r");
+#endif
if (input == NULL) {
PR_fprintf(PR_STDERR, "Error opening input terminal for read\n");
return NULL;
@@ -393,9 +398,16 @@ SECU_ChangePW(PK11SlotInfo *slot, char *passwd, char *pwFile)
for (;;) {
oldpw = SECU_GetModulePassword(slot, PR_FALSE, &pwdata);
- if (PK11_CheckUserPassword(slot, oldpw) != SECSuccess)
- PR_fprintf(PR_STDERR, "Invalid password. Try again.\n");
- else
+ if (PK11_CheckUserPassword(slot, oldpw) != SECSuccess) {
+ if (pwdata.source == PW_NONE) {
+ PR_fprintf(PR_STDERR, "Invalid password. Try again.\n");
+ } else {
+ PR_fprintf(PR_STDERR, "Invalid password.\n");
+ PORT_Memset(oldpw, 0, PL_strlen(oldpw));
+ PORT_Free(oldpw);
+ return SECFailure;
+ }
+ } else
break;
PORT_Free(oldpw);