summaryrefslogtreecommitdiffstats
path: root/nss_engine_pphrase.c
diff options
context:
space:
mode:
authorrcritten <>2006-08-25 20:19:48 +0000
committerrcritten <>2006-08-25 20:19:48 +0000
commit555efa7bf2c4901a06297848f4b569c102cb7af1 (patch)
treecd269c3cd606b6a02ae708965573b1813dcd12ef /nss_engine_pphrase.c
parent09e567625d7ed4fcd9de834c6c41e86967e0adce (diff)
downloadmod_nss-555efa7bf2c4901a06297848f4b569c102cb7af1.tar.gz
mod_nss-555efa7bf2c4901a06297848f4b569c102cb7af1.tar.xz
mod_nss-555efa7bf2c4901a06297848f4b569c102cb7af1.zip
204138
Add new NSSPassPhraseDialog method, defer, where only the tokens that are found in the file pointed to by this directive are initialized. Otherwise every token that NSS finds it attempts to authenticate. Syntax is: NSSPassPhraseDialog defer:/path/to/password.conf
Diffstat (limited to 'nss_engine_pphrase.c')
-rw-r--r--nss_engine_pphrase.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/nss_engine_pphrase.c b/nss_engine_pphrase.c
index c835d03..8ba489a 100644
--- a/nss_engine_pphrase.c
+++ b/nss_engine_pphrase.c
@@ -74,6 +74,15 @@ SECStatus nss_Init_Tokens(server_rec *s)
continue;
}
+ if (parg->mc->pphrase_dialog_type == SSL_PPTYPE_DEFER) {
+ char * passwd = nss_get_password(stdin, stdout, slot, nss_check_password, parg);
+ if (passwd == NULL) {
+ PK11_FreeSlot(slot);
+ continue;
+ }
+ free(passwd);
+ }
+
ret = PK11_Authenticate(slot, PR_TRUE, parg);
if (SECSuccess != ret) {
status = SECFailure;
@@ -209,7 +218,8 @@ static char *nss_get_password(FILE *input, FILE *output,
token_name = PK11_GetTokenName(slot);
- if (parg->mc->pphrase_dialog_type == SSL_PPTYPE_FILE) {
+ if (parg->mc->pphrase_dialog_type == SSL_PPTYPE_FILE ||
+ parg->mc->pphrase_dialog_type == SSL_PPTYPE_DEFER) {
/* Try to get the passwords from the password file if it exists.
* THIS IS UNSAFE and is provided for convenience only. Without this
* capability the server would have to be started in foreground mode.
@@ -235,6 +245,14 @@ static char *nss_get_password(FILE *input, FILE *output,
}
}
+ /* For SSL_PPTYPE_DEFER we only want to authenticate passwords found
+ * in the password file.
+ */
+ if ((parg->mc->pphrase_dialog_type == SSL_PPTYPE_DEFER) &&
+ (pwdstr == NULL)) {
+ return NULL;
+ }
+
/* This purposely comes after the file check because that is more
* authoritative.
*/