diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-08 17:01:47 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-12-08 17:25:08 +0100 |
commit | b6de578d73bdef40124bb551abe7123923b4c33f (patch) | |
tree | 9c3a5cda24e50fd9cc51a2440a0ccf64197431d2 /src/resolve/resolved-resolv-conf.c | |
parent | a50d79103f31ece8cf2d63472b6542a047f5b5f7 (diff) | |
download | systemd-b6de578d73bdef40124bb551abe7123923b4c33f.tar.gz |
resolved: beef up logic to detect our own configuration files
Let's also check for the static resolv.conf, so that we filter all three
of our own files out.
Diffstat (limited to 'src/resolve/resolved-resolv-conf.c')
-rw-r--r-- | src/resolve/resolved-resolv-conf.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c index f681efd00d..b7c43d6ec4 100644 --- a/src/resolve/resolved-resolv-conf.c +++ b/src/resolve/resolved-resolv-conf.c @@ -32,25 +32,33 @@ #include "string-util.h" #include "strv.h" +/* A resolv.conf file containing the DNS server and domain data we learnt from uplink, i.e. the full uplink data */ #define PRIVATE_UPLINK_RESOLV_CONF "/run/systemd/resolve/resolv.conf" + +/* A resolv.conf file containing the domain data we learnt from uplink, but our own DNS server address. */ #define PRIVATE_STUB_RESOLV_CONF "/run/systemd/resolve/stub-resolv.conf" +/* A static resolv.conf file containing no domains, but only our own DNS sever address */ +#define PRIVATE_STATIC_RESOLV_CONF ROOTLIBEXECDIR "/resolv.conf" + static bool file_is_our_own(const struct stat *st) { - struct stat own1, own2; + const char *path; assert(st); - /* Is it symlinked to our own file? */ - if (stat(PRIVATE_UPLINK_RESOLV_CONF, &own1) >= 0 && - st->st_dev == own1.st_dev && - st->st_ino == own1.st_ino) - return true; - - /* Is it symlinked to our own stub file? */ - if (stat(PRIVATE_STUB_RESOLV_CONF, &own2) >= 0 && - st->st_dev == own2.st_dev && - st->st_ino == own2.st_ino) - return true; + FOREACH_STRING(path, + PRIVATE_UPLINK_RESOLV_CONF, + PRIVATE_STUB_RESOLV_CONF, + PRIVATE_STATIC_RESOLV_CONF) { + + struct stat own; + + /* Is it symlinked to our own uplink file? */ + if (stat(path, &own) >= 0 && + st->st_dev == own.st_dev && + st->st_ino == own.st_ino) + return true; + } return false; } |