From dd0b4df329ff7ff2a656404db271c8ee8379ff9d Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 21 Jan 2020 17:25:39 +0100 Subject: resolv: Enhance __resolv_conf_load to capture file change data The data is captured after reading the file. This allows callers to check the change data against an earlier measurement. Reviewed-by: Adhemerval Zanella --- resolv/res_init.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'resolv/res_init.c') diff --git a/resolv/res_init.c b/resolv/res_init.c index 09345718cd..98d84f264d 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -103,6 +103,7 @@ #include #include #include +#include static uint32_t net_mask (struct in_addr); @@ -549,7 +550,8 @@ res_vinit_1 (FILE *fp, struct resolv_conf_parser *parser) } struct resolv_conf * -__resolv_conf_load (struct __res_state *preinit) +__resolv_conf_load (struct __res_state *preinit, + struct file_change_detection *change) { /* Ensure that /etc/hosts.conf has been loaded (once). */ _res_hconf_init (); @@ -577,7 +579,13 @@ __resolv_conf_load (struct __res_state *preinit) resolv_conf_parser_init (&parser, preinit); struct resolv_conf *conf = NULL; - if (res_vinit_1 (fp, &parser)) + bool ok = res_vinit_1 (fp, &parser); + if (ok && change != NULL) + /* Update the file change information if the configuration was + loaded successfully. */ + ok = file_change_detection_for_fp (change, fp); + + if (ok) { parser.template.nameserver_list = nameserver_list_begin (&parser.nameserver_list); @@ -615,7 +623,7 @@ __res_vinit (res_state statp, int preinit) if (preinit && has_preinit_values (statp)) /* For the preinit case, we cannot use the cached configuration because some settings could be different. */ - conf = __resolv_conf_load (statp); + conf = __resolv_conf_load (statp, NULL); else conf = __resolv_conf_get_current (); if (conf == NULL) -- cgit v1.2.1