diff options
author | Giedrius Statkevičius <giedriuswork@gmail.com> | 2020-03-22 22:40:18 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-04-03 17:34:10 +0200 |
commit | aa5408e2e8a66b71f38531f1dcb91252c586a23c (patch) | |
tree | d8a03ef2c97b56f36f2d70cea9bf349b4497f745 /src/resolve/resolved-manager.h | |
parent | 50f5e2e2817d3435a1d6c0ce0d434efe5dcc2748 (diff) | |
download | systemd-aa5408e2e8a66b71f38531f1dcb91252c586a23c.tar.gz |
resolve: reload /etc/hosts on inode change
On certain distributions such as NixOS the mtime of `/etc/hosts` is
locked to a fixed value. In such cases, only checking the last mtime of
`/etc/hosts` is not enough - we also need to check if the st_ino/st_dev
match up. Thus, let's make sure make sure that systemd-resolved also
rereads `/etc/hosts` if the inode or the device containing `/etc/hosts` changes.
Test script:
```bash
hosts="/etc/hosts"
echo "127.0.0.1 testpr" > "hosts_new"
mv "hosts_new" "$hosts"
resolvectl query testpr || exit 1
mtime="$(stat -c %y "$hosts")"
echo "127.0.0.1 newhost" > "hosts_tmp"
touch -d "$mtime" "hosts_tmp"
install -p "hosts_tmp" "$hosts"
sleep 10
resolvectl query newhost || exit 1
rm -f "hosts_tmp"
```
Closes #14456.
Diffstat (limited to 'src/resolve/resolved-manager.h')
-rw-r--r-- | src/resolve/resolved-manager.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/resolve/resolved-manager.h b/src/resolve/resolved-manager.h index 7f7d3a6b9c..446f258b49 100644 --- a/src/resolve/resolved-manager.h +++ b/src/resolve/resolved-manager.h @@ -127,6 +127,8 @@ struct Manager { /* Data from /etc/hosts */ EtcHosts etc_hosts; usec_t etc_hosts_last, etc_hosts_mtime; + ino_t etc_hosts_ino; + dev_t etc_hosts_dev; bool read_etc_hosts; /* Local DNS stub on 127.0.0.53:53 */ |