Lines 91-97
Link Here
|
91 |
const char *dir_name; |
91 |
const char *dir_name; |
92 |
authn_provider_list *providers; |
92 |
authn_provider_list *providers; |
93 |
const char *realm; |
93 |
const char *realm; |
94 |
char **qop_list; |
94 |
apr_array_header_t *qop_list; |
95 |
apr_sha1_ctx_t nonce_ctx; |
95 |
apr_sha1_ctx_t nonce_ctx; |
96 |
apr_time_t nonce_lifetime; |
96 |
apr_time_t nonce_lifetime; |
97 |
const char *nonce_format; |
97 |
const char *nonce_format; |
Lines 451-458
Link Here
|
451 |
|
451 |
|
452 |
conf = (digest_config_rec *) apr_pcalloc(p, sizeof(digest_config_rec)); |
452 |
conf = (digest_config_rec *) apr_pcalloc(p, sizeof(digest_config_rec)); |
453 |
if (conf) { |
453 |
if (conf) { |
454 |
conf->qop_list = apr_palloc(p, sizeof(char*)); |
454 |
conf->qop_list = apr_array_make(p, 10, sizeof(char *)); |
455 |
conf->qop_list[0] = NULL; |
|
|
456 |
conf->nonce_lifetime = DFLT_NONCE_LIFE; |
455 |
conf->nonce_lifetime = DFLT_NONCE_LIFE; |
457 |
conf->dir_name = apr_pstrdup(p, dir); |
456 |
conf->dir_name = apr_pstrdup(p, dir); |
458 |
conf->algorithm = DFLT_ALGORITHM; |
457 |
conf->algorithm = DFLT_ALGORITHM; |
Lines 532-546
Link Here
|
532 |
static const char *set_qop(cmd_parms *cmd, void *config, const char *op) |
531 |
static const char *set_qop(cmd_parms *cmd, void *config, const char *op) |
533 |
{ |
532 |
{ |
534 |
digest_config_rec *conf = (digest_config_rec *) config; |
533 |
digest_config_rec *conf = (digest_config_rec *) config; |
535 |
char **tmp; |
|
|
536 |
int cnt; |
537 |
|
534 |
|
538 |
if (!strcasecmp(op, "none")) { |
535 |
if (!strcasecmp(op, "none")) { |
539 |
if (conf->qop_list[0] == NULL) { |
536 |
apr_array_clear(conf->qop_list); |
540 |
conf->qop_list = apr_palloc(cmd->pool, 2 * sizeof(char*)); |
537 |
*(const char **)apr_array_push(conf->qop_list) = "none"; |
541 |
conf->qop_list[1] = NULL; |
|
|
542 |
} |
543 |
conf->qop_list[0] = "none"; |
544 |
return NULL; |
538 |
return NULL; |
545 |
} |
539 |
} |
546 |
|
540 |
|
Lines 551-565
Link Here
|
551 |
return apr_pstrcat(cmd->pool, "Unrecognized qop: ", op, NULL); |
545 |
return apr_pstrcat(cmd->pool, "Unrecognized qop: ", op, NULL); |
552 |
} |
546 |
} |
553 |
|
547 |
|
554 |
for (cnt = 0; conf->qop_list[cnt] != NULL; cnt++) |
548 |
*(const char **)apr_array_push(conf->qop_list) = apr_pstrdup(cmd->pool, op); |
555 |
; |
|
|
556 |
|
549 |
|
557 |
tmp = apr_palloc(cmd->pool, (cnt + 2) * sizeof(char*)); |
|
|
558 |
memcpy(tmp, conf->qop_list, cnt*sizeof(char*)); |
559 |
tmp[cnt] = apr_pstrdup(cmd->pool, op); |
560 |
tmp[cnt+1] = NULL; |
561 |
conf->qop_list = tmp; |
562 |
|
563 |
return NULL; |
550 |
return NULL; |
564 |
} |
551 |
} |
565 |
|
552 |
|
Lines 1251-1269
Link Here
|
1251 |
const char *qop, *opaque, *opaque_param, *domain, *nonce; |
1238 |
const char *qop, *opaque, *opaque_param, *domain, *nonce; |
1252 |
|
1239 |
|
1253 |
/* Setup qop */ |
1240 |
/* Setup qop */ |
1254 |
if (conf->qop_list[0] == NULL) { |
1241 |
if (apr_is_empty_array(conf->qop_list)) { |
1255 |
qop = ", qop=\"auth\""; |
1242 |
qop = ", qop=\"auth\""; |
1256 |
} |
1243 |
} |
1257 |
else if (!strcasecmp(conf->qop_list[0], "none")) { |
1244 |
else if (!strcasecmp(*(const char **)(conf->qop_list->elts), "none")) { |
1258 |
qop = ""; |
1245 |
qop = ""; |
1259 |
} |
1246 |
} |
1260 |
else { |
1247 |
else { |
1261 |
int cnt; |
1248 |
qop = apr_pstrcat(r->pool, ", qop=\"", |
1262 |
qop = apr_pstrcat(r->pool, ", qop=\"", conf->qop_list[0], NULL); |
1249 |
apr_array_pstrcat(r->pool, conf->qop_list, ','), |
1263 |
for (cnt = 1; conf->qop_list[cnt] != NULL; cnt++) { |
1250 |
"\"", |
1264 |
qop = apr_pstrcat(r->pool, qop, ",", conf->qop_list[cnt], NULL); |
1251 |
NULL); |
1265 |
} |
|
|
1266 |
qop = apr_pstrcat(r->pool, qop, "\"", NULL); |
1267 |
} |
1252 |
} |
1268 |
|
1253 |
|
1269 |
/* Setup opaque */ |
1254 |
/* Setup opaque */ |
Lines 1464-1472
Link Here
|
1464 |
return OK; |
1449 |
return OK; |
1465 |
} |
1450 |
} |
1466 |
|
1451 |
|
1467 |
if ((conf->qop_list != NULL) |
1452 |
if (!apr_is_empty_array(conf->qop_list) && |
1468 |
&&(conf->qop_list[0] != NULL) |
1453 |
!strcasecmp(*(const char **)(conf->qop_list->elts), "none")) { |
1469 |
&&!strcasecmp(conf->qop_list[0], "none")) { |
|
|
1470 |
/* qop is none, client must not send a nonce count */ |
1454 |
/* qop is none, client must not send a nonce count */ |
1471 |
if (snc != NULL) { |
1455 |
if (snc != NULL) { |
1472 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01772) |
1456 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01772) |
Lines 1893-1907
Link Here
|
1893 |
else { |
1877 |
else { |
1894 |
const char *exp_digest; |
1878 |
const char *exp_digest; |
1895 |
int match = 0, idx; |
1879 |
int match = 0, idx; |
1896 |
for (idx = 0; conf->qop_list[idx] != NULL; idx++) { |
1880 |
const char **tmp = (const char **)(conf->qop_list->elts); |
1897 |
if (!strcasecmp(conf->qop_list[idx], resp->message_qop)) { |
1881 |
for (idx = 0; idx < conf->qop_list->nelts; idx++) { |
|
|
1882 |
if (!strcasecmp(*tmp, resp->message_qop)) { |
1898 |
match = 1; |
1883 |
match = 1; |
1899 |
break; |
1884 |
break; |
1900 |
} |
1885 |
} |
|
|
1886 |
++tmp; |
1901 |
} |
1887 |
} |
1902 |
|
1888 |
|
1903 |
if (!match |
1889 |
if (!match |
1904 |
&& !(conf->qop_list[0] == NULL |
1890 |
&& !(apr_is_empty_array(conf->qop_list) |
1905 |
&& !strcasecmp(resp->message_qop, "auth"))) { |
1891 |
&& !strcasecmp(resp->message_qop, "auth"))) { |
1906 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01793) |
1892 |
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01793) |
1907 |
"invalid qop `%s' received: %s", |
1893 |
"invalid qop `%s' received: %s", |
Lines 1983-1989
Link Here
|
1983 |
|
1969 |
|
1984 |
/* do rfc-2069 digest |
1970 |
/* do rfc-2069 digest |
1985 |
*/ |
1971 |
*/ |
1986 |
if (conf->qop_list[0] && !strcasecmp(conf->qop_list[0], "none") |
1972 |
if (!apr_is_empty_array(conf->qop_list) && |
|
|
1973 |
!strcasecmp(*(const char **)(conf->qop_list->elts), "none") |
1987 |
&& resp->message_qop == NULL) { |
1974 |
&& resp->message_qop == NULL) { |
1988 |
/* use only RFC-2069 format */ |
1975 |
/* use only RFC-2069 format */ |
1989 |
ai = nextnonce; |
1976 |
ai = nextnonce; |