diff -u dnsmasq-2.78/debian/changelog dnsmasq-2.78/debian/changelog --- dnsmasq-2.78/debian/changelog +++ dnsmasq-2.78/debian/changelog @@ -1,3 +1,15 @@ +dnsmasq (2.78-3) unstable; urgency=high + + * Make failure of pidfile chown a warning. (closes: #889857) + + -- Simon Kelley Thu, 8 Feb 2018 21:26:30 +0000 + +dnsmasq (2.78-2) unstable; urgency=high + + * Change ownership of pid file, to keep systemd happy. (closes: #889336) + + -- Simon Kelley Tue, 6 Feb 2018 17:21:30 +0000 + dnsmasq (2.78-1) unstable; urgency=high * New upstream. only in patch2: unchanged: --- dnsmasq-2.78.orig/src/dnsmasq.c +++ dnsmasq-2.78/src/dnsmasq.c @@ -48,6 +48,7 @@ long i, max_fd = sysconf(_SC_OPEN_MAX); char *baduser = NULL; int log_err; + int chown_warn = 0; #if defined(HAVE_LINUX_NETWORK) cap_user_header_t hdr = NULL; cap_user_data_t data = NULL; @@ -537,6 +538,16 @@ } else { + /* We're still running as root here. Change the ownership of the PID file + to the user we will be running as. Note that this is not to allow + us to delete the file, since that depends on the permissions + of the directory containing the file. That directory will + need to by owned by the dnsmasq user, and the ownership of the + file has to match, to keep systemd >273 happy. */ + if (getuid() == 0 && ent_pw && ent_pw->pw_uid != 0 && fchown(fd, ent_pw->pw_uid, ent_pw->pw_gid) == -1) + chown_warn = errno; + + if (!read_write(fd, (unsigned char *)daemon->namebuff, strlen(daemon->namebuff), 0)) err = 1; else @@ -726,7 +737,10 @@ } my_syslog(LOG_INFO, _("compile time options: %s"), compile_opts); - + + if (chown_warn != 0) + my_syslog(LOG_WARNING, "chown of PID file %s failed: %s", daemon->runfile, strerror(chown_warn)); + #ifdef HAVE_DBUS if (option_bool(OPT_DBUS)) {