|
83 | 83 | /* struct to hold the configuration info */ |
84 | 84 |
|
85 | 85 | typedef struct digest_config_struct { |
86 | | - const char *dir_name; |
87 | 86 | authn_provider_list *providers; |
88 | 87 | apr_time_t nonce_lifetime; |
89 | 88 | int check_nc; |
@@ -462,52 +461,14 @@ static void initialize_child(apr_pool_t *p, server_rec *s) |
462 | 461 |
|
463 | 462 | static void *create_digest_dir_config(apr_pool_t *p, char *dir) |
464 | 463 | { |
465 | | - digest_config_rec *conf; |
466 | | - |
467 | | - if (dir == NULL) { |
468 | | - return NULL; |
469 | | - } |
| 464 | + digest_config_rec *conf = apr_pcalloc(p, sizeof *conf); |
470 | 465 |
|
471 | | - conf = (digest_config_rec *) apr_pcalloc(p, sizeof(digest_config_rec)); |
472 | | - if (conf) { |
473 | | - conf->nonce_lifetime = DFLT_NONCE_LIFE; |
474 | | - conf->dir_name = apr_pstrdup(p, dir); |
475 | | - conf->algorithm = DFLT_ALGORITHM; |
476 | | - } |
| 466 | + conf->nonce_lifetime = DFLT_NONCE_LIFE; |
| 467 | + conf->algorithm = DFLT_ALGORITHM; |
477 | 468 |
|
478 | 469 | return conf; |
479 | 470 | } |
480 | 471 |
|
481 | | - |
482 | | -/* |
483 | | - * The realm is no longer precomputed because it may be an expression, which |
484 | | - * makes this hooking of AuthName quite weird. |
485 | | - */ |
486 | | -static const char *set_realm(cmd_parms *cmd, void *config, const char *realm) |
487 | | -{ |
488 | | - digest_config_rec *conf = (digest_config_rec *) config; |
489 | | -#ifdef AP_DEBUG |
490 | | - int i; |
491 | | - |
492 | | - /* check that we got random numbers */ |
493 | | - for (i = 0; i < SECRET_LEN; i++) { |
494 | | - if (secret[i] != 0) |
495 | | - break; |
496 | | - } |
497 | | - ap_assert(i < SECRET_LEN); |
498 | | -#endif |
499 | | - |
500 | | - /* we precompute the part of the nonce hash that is constant (well, |
501 | | - * the host:port would be too, but that varies for .htaccess files |
502 | | - * and directives outside a virtual host section) |
503 | | - */ |
504 | | - apr_sha1_init(&conf->nonce_ctx); |
505 | | - apr_sha1_update_binary(&conf->nonce_ctx, secret, SECRET_LEN); |
506 | | - |
507 | | - |
508 | | - return DECLINE_CMD; |
509 | | -} |
510 | | - |
511 | 472 | static const char *add_authn_provider(cmd_parms *cmd, void *config, |
512 | 473 | const char *arg) |
513 | 474 | { |
@@ -663,8 +624,6 @@ static const char *set_shmem_size(cmd_parms *cmd, void *config, |
663 | 624 |
|
664 | 625 | static const command_rec digest_cmds[] = |
665 | 626 | { |
666 | | - AP_INIT_TAKE1("AuthName", set_realm, NULL, OR_AUTHCFG, |
667 | | - "The authentication realm (e.g. \"Members Only\")"), |
668 | 627 | AP_INIT_ITERATE("AuthDigestProvider", add_authn_provider, NULL, OR_AUTHCFG, |
669 | 628 | "specify the auth providers for a directory or location"), |
670 | 629 | AP_INIT_ITERATE("AuthDigestQop", set_qop, NULL, OR_AUTHCFG, |
@@ -1060,14 +1019,8 @@ static void gen_nonce_hash(char hash[NONCE_HASH_LEN+1], const char *timestr, con |
1060 | 1019 | unsigned char sha1[APR_SHA1_DIGESTSIZE]; |
1061 | 1020 | apr_sha1_ctx_t ctx; |
1062 | 1021 |
|
1063 | | - memcpy(&ctx, &conf->nonce_ctx, sizeof(ctx)); |
1064 | | - /* |
1065 | | - apr_sha1_update_binary(&ctx, (const unsigned char *) server->server_hostname, |
1066 | | - strlen(server->server_hostname)); |
1067 | | - apr_sha1_update_binary(&ctx, (const unsigned char *) &server->port, |
1068 | | - sizeof(server->port)); |
1069 | | - */ |
1070 | | - |
| 1022 | + apr_sha1_init(&ctx); |
| 1023 | + apr_sha1_update_binary(&ctx, secret, SECRET_LEN); |
1071 | 1024 | apr_sha1_update_binary(&ctx, (const unsigned char *) realm, strlen(realm)); |
1072 | 1025 |
|
1073 | 1026 | apr_sha1_update_binary(&ctx, (const unsigned char *) timestr, strlen(timestr)); |
|
0 commit comments