When -T cookiealwaysvalid is passed to named, DNS cookie checks for
the incoming queries always pass, given they are structurally correct.
(cherry picked from commit
807ef8545d2e06c77826f3b2ac3f1cb7a7413dad)
* Only accept COOKIE if we have talked to the client in the last hour.
*/
isc_stdtime_get(&now);
+ if (ns_g_cookiealwaysvalid) {
+ now = when;
+ }
if (isc_serial_gt(when, (now + 300)) || /* In the future. */
isc_serial_lt(when, (now - 3600))) { /* In the past. */
isc_stats_increment(ns_g_server->nsstats,
isc_buffer_init(&db, dbuf, sizeof(dbuf));
compute_cookie(client, when, nonce, ns_g_server->secret, &db);
- if (isc_safe_memequal(old, dbuf, COOKIE_SIZE)) {
+ if (isc_safe_memequal(old, dbuf, COOKIE_SIZE) || ns_g_cookiealwaysvalid)
+ {
isc_stats_increment(ns_g_server->nsstats,
dns_nsstatscounter_cookiematch);
client->attributes |= NS_CLIENTATTR_HAVECOOKIE;
EXTERN isc_time_t ns_g_configtime;
EXTERN bool ns_g_memstatistics INIT(false);
EXTERN bool ns_g_clienttest INIT(false);
+EXTERN bool ns_g_cookiealwaysvalid INIT(false);
EXTERN bool ns_g_dropedns INIT(false);
EXTERN bool ns_g_ednsformerr INIT(false);
EXTERN bool ns_g_ednsnotimp INIT(false);
*/
if (!strcmp(option, "clienttest")) {
ns_g_clienttest = true;
+ } else if (!strcmp(option, "cookiealwaysvalid")) {
+ ns_g_cookiealwaysvalid = true;
} else if (!strncmp(option, "delay=", 6)) {
ns_g_delay = atoi(option + 6);
} else if (!strcmp(option, "dropedns")) {
foreach my $t_option(
"dropedns", "ednsformerr", "ednsnotimp", "ednsrefused",
- "noaa", "noedns", "nosoa", "maxudp512", "maxudp1460",
+ "cookiealwaysvalid", "noaa", "noedns", "nosoa",
+ "maxudp512", "maxudp1460",
) {
if (-e "$testdir/$server/named.$t_option") {
$command .= "-T $t_option "