diff -rupN httpd-2.4.1/modules/aaa/mod_auth_digest.c httpd-2.4.1-edited/modules/aaa/mod_auth_digest.c --- httpd-2.4.1/modules/aaa/mod_auth_digest.c 2011-12-04 18:08:01.000000000 -0600 +++ httpd-2.4.1-edited/modules/aaa/mod_auth_digest.c 2012-04-02 12:30:19.000000000 -0500 @@ -470,6 +470,38 @@ static void *create_digest_dir_config(ap return conf; } +static void *merge_digest_dir_config(apr_pool_t *a, void *basev, void *newv) +{ + digest_config_rec *base = (digest_config_rec *)basev; + digest_config_rec *new = (digest_config_rec *)newv; + digest_config_rec *conf = + (digest_config_rec *)apr_pcalloc(a, sizeof(digest_config_rec)); + + /* Always take the new value */ + conf->qop_list = new->qop_list; + conf->nonce_lifetime = new->nonce_lifetime; + conf->dir_name = new->dir_name; + conf->algorithm = new->algorithm; + conf->providers = new->providers; + conf->nonce_format = new->nonce_format; + conf->check_nc = new->check_nc; + conf->uri_list = new->uri_list; + conf->ha1 = new->ha1; + + /* Except for the realm name, match mod_authn_core's merge rules here */ + /* Also pass forward the precalculated nonce_ctx */ + if (new->realm) { + conf->realm = new->realm; + conf->nonce_ctx = new->nonce_ctx; + } else { + conf->realm = base->realm; + conf->nonce_ctx = base->nonce_ctx; + } + + return (void*)conf; +} + + static const char *set_realm(cmd_parms *cmd, void *config, const char *realm) { digest_config_rec *conf = (digest_config_rec *) config; @@ -1843,7 +1875,7 @@ static int authenticate_digest_user(requ return HTTP_UNAUTHORIZED; } - if (strcmp(resp->realm, conf->realm)) { + if (resp->realm == NULL || conf->realm == NULL || strcmp(resp->realm, conf->realm)) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01788) "realm mismatch - got `%s' but expected `%s'", resp->realm, conf->realm); @@ -2084,7 +2116,7 @@ AP_DECLARE_MODULE(auth_digest) = { STANDARD20_MODULE_STUFF, create_digest_dir_config, /* dir config creater */ - NULL, /* dir merger --- default is to override */ + merge_digest_dir_config, /* dir merger --- default is to override */ NULL, /* server config */ NULL, /* merge server config */ digest_cmds, /* command table */