summaryrefslogtreecommitdiff
path: root/resolv/res_init.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-07-03 20:31:23 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-07-03 20:57:28 +0200
commitf30a54b21b83f254533c59ca72ad17af5249c6be (patch)
tree174c6e8b77d8fc1514f4108e3290b91d19d838a6 /resolv/res_init.c
parent352f4ff9a268b81ef5d4b2413f582565806e4790 (diff)
resolv: Introduce struct resolv_conf with extended resolver state
This change provides additional resolver configuration state which is not exposed through the _res ABI. It reuses the existing initstamp field in the supposedly-private part of _res. Some effort is undertaken to avoid memory safety issues introduced by applications which directly patch the _res object. With this commit, only the initstamp field is moved into struct resolv_conf. Additional members will be added later, eventually migrating the entire resolver configuration.
Diffstat (limited to 'resolv/res_init.c')
-rw-r--r--resolv/res_init.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 5d8b2c994d..659d3ea81f 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -102,6 +102,7 @@
#include <sys/types.h>
#include <inet/net-internal.h>
#include <errno.h>
+#include <resolv_conf.h>
static void res_setoptions (res_state, const char *);
static uint32_t net_mask (struct in_addr);
@@ -137,7 +138,6 @@ res_vinit_1 (res_state statp, bool preinit, FILE *fp, char **buffer)
bool havesearch = false;
int nsort = 0;
char *net;
- statp->_u._ext.initstamp = __res_initstamp;
if (!preinit)
{
@@ -457,6 +457,19 @@ __res_vinit (res_state statp, int preinit)
bool ok = res_vinit_1 (statp, preinit, fp, &buffer);
free (buffer);
+ if (ok)
+ {
+ struct resolv_conf init = { 0 }; /* No data yet. */
+ struct resolv_conf *conf = __resolv_conf_allocate (&init);
+ if (conf == NULL)
+ ok = false;
+ else
+ {
+ ok = __resolv_conf_attach (statp, conf);
+ __resolv_conf_put (conf);
+ }
+ }
+
if (!ok)
{
/* Deallocate the name server addresses which have been