summaryrefslogtreecommitdiff
path: root/dns.afsdb.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2020-04-14 16:07:26 +0100
committerDavid Howells <dhowells@redhat.com>2020-07-06 17:21:18 +0100
commit75e7568dc516db698093b33ea273e1b4a30b70be (patch)
tree3f615a1f9aa9ec35b87d43d9f69f1f3cd7a5372c /dns.afsdb.c
parentd44a41376b17450c3908978b123e1f05a361885f (diff)
downloadkeyutils-75e7568dc516db698093b33ea273e1b4a30b70be.tar.gz
dns: Apply a default TTL to records obtained from getaddrinfo()
Address records obtained from getaddrinfo() don't come with any TTL information, even if they're obtained from the DNS, with the result that key.dns_resolver upcall program doesn't set an expiry time on dns_resolver records unless they include a component obtained directly from the DNS, such as an SRV or AFSDB record. Fix this to apply a default TTL of 10mins in the event that we haven't got one. This can be configured in /etc/keyutils/key.dns_resolver.conf by adding the line: default_ttl = <number-of-seconds> to the file. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Ben Boeckel <me@benboeckel.net> Reviewed-by: Jeff Layton <jlayton@kernel.org>
Diffstat (limited to 'dns.afsdb.c')
-rw-r--r--dns.afsdb.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/dns.afsdb.c b/dns.afsdb.c
index fa60e04..986c0f3 100644
--- a/dns.afsdb.c
+++ b/dns.afsdb.c
@@ -37,8 +37,6 @@
*/
#include "key.dns.h"
-static unsigned long afs_ttl = ULONG_MAX;
-
/*
*
*/
@@ -114,8 +112,8 @@ static void afsdb_hosts_to_addrs(ns_msg handle, ns_sect section)
}
}
- afs_ttl = ttl;
- info("ttl: %u", ttl);
+ key_expiry = ttl;
+ info("ttl: %u", key_expiry);
}
/*
@@ -203,8 +201,8 @@ static void srv_hosts_to_addrs(ns_msg handle, ns_sect section)
}
}
- afs_ttl = ttl;
- info("ttl: %u", ttl);
+ key_expiry = ttl;
+ info("ttl: %u", key_expiry);
}
/*
@@ -240,7 +238,7 @@ static int dns_query_AFSDB(const char *cell)
/* look up the hostnames we've obtained to get the actual addresses */
afsdb_hosts_to_addrs(handle, ns_s_an);
- info("DNS query AFSDB RR results:%u ttl:%lu", payload_index, afs_ttl);
+ info("DNS query AFSDB RR results:%u ttl:%u", payload_index, key_expiry);
return 0;
}
@@ -279,7 +277,7 @@ static int dns_query_VL_SRV(const char *cell)
/* look up the hostnames we've obtained to get the actual addresses */
srv_hosts_to_addrs(handle, ns_s_an);
- info("DNS query VL SRV RR results:%u ttl:%lu", payload_index, afs_ttl);
+ info("DNS query VL SRV RR results:%u ttl:%u", payload_index, key_expiry);
return 0;
}
@@ -293,7 +291,7 @@ void afs_instantiate(const char *cell)
/* set the key's expiry time from the minimum TTL encountered */
if (!debug_mode) {
- ret = keyctl_set_timeout(key, afs_ttl);
+ ret = keyctl_set_timeout(key, key_expiry);
if (ret == -1)
error("%s: keyctl_set_timeout: %m", __func__);
}