diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-06-28 15:01:28 +0900 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-06-28 10:06:15 +0200 |
commit | f43580f17d9977ea330deacc8931982e41a49abf (patch) | |
tree | f85fcea01116f0073aeaab88a1ab0a817fb00093 /src/resolve/resolved-resolv-conf.c | |
parent | 48f5da19b6e8f0d05f5217bc9856093d354ce5d0 (diff) | |
download | systemd-f43580f17d9977ea330deacc8931982e41a49abf.tar.gz |
resolve: warn when our stub listener is disabled but resolv.conf uses it
Closes #9450.
Diffstat (limited to 'src/resolve/resolved-resolv-conf.c')
-rw-r--r-- | src/resolve/resolved-resolv-conf.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c index 5a022507c9..edad569acd 100644 --- a/src/resolve/resolved-resolv-conf.c +++ b/src/resolve/resolved-resolv-conf.c @@ -21,9 +21,49 @@ /* 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 */ +/* A static resolv.conf file containing no domains, but only our own DNS server address */ #define PRIVATE_STATIC_RESOLV_CONF ROOTLIBEXECDIR "/resolv.conf" +int manager_check_resolv_conf(const Manager *m) { + const char *path; + struct stat st; + int r; + + assert(m); + + /* This warns only when our stub listener is disabled and /etc/resolv.conf is a symlink to + * PRIVATE_STATIC_RESOLV_CONF or PRIVATE_STUB_RESOLV_CONF. */ + + if (m->dns_stub_listener_mode != DNS_STUB_LISTENER_NO) + return 0; + + r = stat("/etc/resolv.conf", &st); + if (r < 0) { + if (errno == ENOENT) + return 0; + + return log_warning_errno(errno, "Failed to stat /etc/resolv.conf: %m"); + } + + FOREACH_STRING(path, + 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) { + log_warning("In spite of DNSStubListner= is disabled, /etc/resolv.conf is a symlink to %s, " + "which expects DNSStubListner= is enabled.", path); + return -EOPNOTSUPP; + } + } + + return 0; +} + static bool file_is_our_own(const struct stat *st) { const char *path; |