FS#48044 - [connman] upgrade to 1.31 overwrites users /etc/resolv.conf without asking
Attached to Project:
Community Packages
Opened by Steven Honeyman (stevenhoneyman) - Friday, 05 February 2016, 13:26 GMT
Last edited by Antonio Rojas (arojas) - Tuesday, 29 March 2016, 20:44 GMT
Opened by Steven Honeyman (stevenhoneyman) - Friday, 05 February 2016, 13:26 GMT
Last edited by Antonio Rojas (arojas) - Tuesday, 29 March 2016, 20:44 GMT
|
Details
Description:
The day after connman was upgraded to 1.31, I noticed DNS was broken. Found that my /etc/resolv.conf had been overwritten by a symlink to a file that doesn't exist... Some digging around and found that the problem is caused by /usr/lib/tmpfiles.d/connman_resolvconf.conf Additional info: * package version 1.31-1 Steps to reproduce: 1. Have a custom /etc/resolv.conf which has nothing to do with connman 2. Upgrade connman from 1.30 to 1.31 3. Reboot 4. Ping google.co.uk (fails) |
This task depends upon
Closed by Antonio Rojas (arojas)
Tuesday, 29 March 2016, 20:44 GMT
Reason for closing: Fixed
Additional comments about closing: connman 1.31-5
Tuesday, 29 March 2016, 20:44 GMT
Reason for closing: Fixed
Additional comments about closing: connman 1.31-5
Overwriting resolv.conf with a dynamically generated resolv.conf is standard behavior for networking processes like Connman and NetworkManager (i.e. it's not a bug). Connman has always done this. For further info, look at: https://wiki.archlinux.org/index.php/Resolv.conf#Preserve_DNS_settings
While connman 1.31 should fall back to directly overwriting /etc/resolv.conf if /var/run/connman isn't present, it fails to do so on my system. I've tried to removing the resolv.conf symlink and replacing it with an empty resolv.conf but so far I haven't been able to make this work. I suspect there might be an upstream bug in the fallback code involved.
Re-enabling /usr/lib/tmpfiles.d/connman_resolvconf.conf fixes the problem for me. My suspection is that the problem the original reporter of this bug encountered is related to a problem with systemd-tmpfiles-setup.service on his system.
Please note that DNS is actually working on my system despite the broken resolv.conf. Only some processes like docker which rely on a correct resolv.conf are failing.
ProtectSystem=full
was added which effectively protects /etc from writes by connman. So we could either
1) keep removing the tmpfile and patch connman.service to use less restrictive protection (ProtectSystem=true allows for writes to /etc)
2) use the tmpfile
I haven't tested this yet but the first approach probably would have the benefit of restoring /etc/resolv.conf after connman exits while keeping the tmpfile would make the symlink permanent even if we're not using connman. However, the resolv.conf page on the Archlinux wiki suggests NetworkManager does the same. Both solutions would be OK for me but I'm not sure which one is preferable.
You can add this line to the package() function in the PKGBUILD to fix the connman service file:
sed -i s/ProtectSystem=full/ProtectSystem=true/ "$pkgdir"/usr/lib/systemd/system/connman.service
I've tested this after removing the symlink and the /var/run/connman directory and it works fine. The only question remaining is what to do about the leftover symlink from 1.31-1. Ask the users to remove it manually?
I set ProtectSystem=full in service file, restarted the connman and now the /etc/resolv.conf has correct contents (nameserver is 127.0.0.1, as expected).
Thanks Felix!
lrwxrwxrwx 1 root root 28 мар 12 22:18 /etc/resolv.conf -> /var/run/connman/resolv.conf
$ ls -la /var/run/connman/resolv.conf
-rw-r--r-- 1 root root 70 мар 14 20:53 /var/run/connman/resolv.conf
$ cat /var/run/connman/resolv.conf
# Generated by Connection Manager
nameserver 127.0.0.1
nameserver ::1
All as expected...
As for the question whether or not the symlink from /var/run/connman/resolv.conf to /etc/resolv.conf should be set by the tempfile I don't have an answer. Technically this is only provided for compatibility reasons and most programs will use the DNS proxy provided by connman anyways. So my proposal to handle this would be to remove the creation of this symlink from the tempfile shipped with connman and let users decide whether they want to set up the symlink for compatibilty. Systemd-networkd also keeps it's own copy of resolv.conf in tmpfs and setting the symlink to /etc/resolv.conf is optional.
This could be a text editor or anything, it shouldn't overwrite config files.
Every other package does this https://wiki.archlinux.org/index.php/Pacman/Pacnew_and_Pacsave#Package_backup_files
And of course it has to do with being a network manager, NetworkManager and netctl also modify the file (via openresolv).
Installed or reinstalled - this changed in pacman 5, and used to be .pacorig but has since been changed to match the reinstall behaviour (new file is .pacnew)