diff -Nru ubiquity-17.04.7/debian/changelog ubiquity-17.04.8/debian/changelog --- ubiquity-17.04.7/debian/changelog 2017-02-10 17:20:44.000000000 +0100 +++ ubiquity-17.04.8/debian/changelog 2017-03-10 14:55:48.000000000 +0100 @@ -1,3 +1,9 @@ +ubiquity (17.04.8) zesty; urgency=medium + + * Prevent unlinking /etc/resolv.conf if resolvconf is used. (LP: #1646585) + + -- Dariusz Gadomski Wed, 10 Mar 2017 14:55:48 +0100 + ubiquity (17.04.7) zesty; urgency=medium [ David Mohammed ] diff -Nru ubiquity-17.04.7/d-i/source/netcfg/netcfg-common.c ubiquity-17.04.8/d-i/source/netcfg/netcfg-common.c --- ubiquity-17.04.7/d-i/source/netcfg/netcfg-common.c 2017-01-09 13:51:50.000000000 +0100 +++ ubiquity-17.04.8/d-i/source/netcfg/netcfg-common.c 2017-03-10 14:55:48.000000000 +0100 @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -1395,11 +1396,14 @@ { static char* remove[] = { INTERFACES_FILE, HOSTS_FILE, HOSTNAME_FILE, NETWORKS_FILE, - RESOLV_FILE, DHCLIENT_CONF, DOMAIN_FILE, 0 }; + DHCLIENT_CONF, DOMAIN_FILE, 0 }; char **ptr = remove; while (*ptr) unlink(*ptr++); + + if (!is_resolvconf_used()) + unlink(RESOLV_FILE); } /* Convert a space-separated list of nameservers in a single string (as might @@ -1797,3 +1801,18 @@ return s; } + +/* Check if /etc/resolv.conf symlinks to /run/resolvconf/resolv.conf. */ +int is_resolvconf_used() +{ + int resolvconf_used = 0; + + char *path = realpath(RESOLV_FILE, NULL); + + if (path) { + resolvconf_used = !strcmp(path, RESOLVCONF_FILE); + free(path); + } + + return resolvconf_used; +} diff -Nru ubiquity-17.04.7/d-i/source/netcfg/netcfg.h ubiquity-17.04.8/d-i/source/netcfg/netcfg.h --- ubiquity-17.04.7/d-i/source/netcfg/netcfg.h 2016-08-12 10:12:34.000000000 +0200 +++ ubiquity-17.04.8/d-i/source/netcfg/netcfg.h 2017-03-10 14:55:48.000000000 +0100 @@ -6,6 +6,7 @@ #define HOSTNAME_FILE "/etc/hostname" #define NETWORKS_FILE "/etc/networks" #define RESOLV_FILE "/etc/resolv.conf" +#define RESOLVCONF_FILE "/run/resolvconf/resolv.conf" #define DHCLIENT_CONF "/etc/dhclient.conf" #define DOMAIN_FILE "/tmp/domain_name" #define NTP_SERVER_FILE "/tmp/dhcp-ntp-servers" @@ -200,6 +201,7 @@ extern int nameserver_count (const struct netcfg_interface *interface); extern int read_resolv_conf_nameservers (char *resolv_conf_file, struct netcfg_interface *interface); +extern int is_resolvconf_used(); extern void sigchld_handler (int sig __attribute__ ((unused)));