From: Roy Marples Date: Thu, 28 Nov 2019 11:47:29 +0000 (+0000) Subject: build: Move rundir from /var/run to /var/run/dhcpcd X-Git-Tag: v9.0.0~214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49e5ee5eee0f685600d8f6c5fc6cffa26833865d;p=thirdparty%2Fdhcpcd.git build: Move rundir from /var/run to /var/run/dhcpcd This will allow dhcpcd to create and unlink pidfiles and sockets which it could otherwise not if dropped priviledges. Downstream packages such as dhcpcd-ui will need to be adjusted. --- diff --git a/configure b/configure index 9efa1638..54a9b791 100755 --- a/configure +++ b/configure @@ -71,7 +71,8 @@ for x do --libexecdir) LIBEXECDIR=$var;; --statedir|--localstatedir) STATEDIR=$var;; --dbdir) DBDIR=$var;; - --rundir|--runstatedir) RUNDIR=$var;; + --rundir) RUNDIR=$var;; + --runstatedir) RUNSTATEDIR=$var;; --mandir) MANDIR=$var;; --datadir) DATADIR=$var;; --with-ccopts|CFLAGS) CFLAGS=$var;; @@ -253,7 +254,8 @@ echo "/* $OS */" >$CONFIG_H : ${LIBEXECDIR:=$PREFIX/libexec} : ${STATEDIR:=/var} : ${DBDIR:=$STATEDIR/db/dhcpcd} -: ${RUNDIR:=$STATEDIR/run} +: ${RUNSTATEDIR:=$STATEDIR/run} +: ${RUNDIR:=$RUNSTATEDIR/dhcpcd} : ${MANDIR:=${PREFIX:-/usr}/share/man} : ${DATADIR:=${PREFIX:-/usr}/share} @@ -506,7 +508,7 @@ if [ -z "$INET" -o "$INET" = yes ]; then echo "DHCPCD_SRCS+= ipv4ll.c" >>$CONFIG_MK fi fi -if [ -z "$INET6" -o "$INET6" = yes ]; then +if [ -z "$INET6" ] || [ "$INET6" = yes ]; then echo "Enabling INET6 support" echo "CPPFLAGS+= -DINET6" >>$CONFIG_MK echo "DHCPCD_SRCS+= ipv6.c ipv6nd.c" >>$CONFIG_MK diff --git a/src/defs.h b/src/defs.h index e9289e5d..c0116d36 100644 --- a/src/defs.h +++ b/src/defs.h @@ -53,13 +53,13 @@ # define LEASEFILE6 LEASEFILE "6" #endif #ifndef PIDFILE -# define PIDFILE RUNDIR "/" PACKAGE "%s%s%s.pid" +# define PIDFILE RUNDIR "/%s%s%spid" #endif #ifndef CONTROLSOCKET -# define CONTROLSOCKET RUNDIR "/" PACKAGE "%s%s.sock" +# define CONTROLSOCKET RUNDIR "/%s%ssock" #endif #ifndef UNPRIVSOCKET -# define UNPRIVSOCKET RUNDIR "/" PACKAGE ".unpriv.sock" +# define UNPRIVSOCKET RUNDIR "/unpriv.sock" #endif #ifndef RDM_MONOFILE # define RDM_MONOFILE DBDIR "/rdm_monotonic" diff --git a/src/dhcpcd.8.in b/src/dhcpcd.8.in index 0199df88..9c145049 100644 --- a/src/dhcpcd.8.in +++ b/src/dhcpcd.8.in @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 9, 2019 +.Dd November 28, 2019 .Dt DHCPCD 8 .Os .Sh NAME @@ -804,20 +804,20 @@ lease and use the file's mtime as when it was issued. Stores the monotonic counter used in the .Ar replay field in Authentication Options. -.It Pa @RUNDIR@/dhcpcd.pid +.It Pa @RUNDIR@/pid Stores the PID of .Nm running on all interfaces. -.It Pa @RUNDIR@/dhcpcd\- Ns Ar interface Ns .pid +.It Pa @RUNDIR@/ Ns Ar interface Ns .pid Stores the PID of .Nm running on the .Ar interface . -.It Pa @RUNDIR@/dhcpcd.sock +.It Pa @RUNDIR@/sock Control socket to the master daemon. -.It Pa @RUNDIR@/dhcpcd.unpriv.sock +.It Pa @RUNDIR@/unpriv.sock Unprivileged socket to the master daemon, only allows state retrieval. -.It Pa @RUNDIR@/dhcpcd\- Ns Ar interface Ns .sock +.It Pa @RUNDIR@/ Ns Ar interface Ns .sock Control socket to per interface daemon. .El .Sh SEE ALSO diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 11e81980..94c27780 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -1639,6 +1639,12 @@ main(int argc, char **argv) #endif #ifdef INET ctx.udp_fd = -1; +#endif +#ifdef INET6 + ctx.nd_fd = -1; +#endif +#ifdef DHCP6 + ctx.dhcp6_fd = -1; #endif rt_init(&ctx); @@ -1807,7 +1813,7 @@ printpidfile: per = ""; } snprintf(ctx.pidfile, sizeof(ctx.pidfile), - PIDFILE, "-", ifname, per); + PIDFILE, ifname, per, "."); } else { snprintf(ctx.pidfile, sizeof(ctx.pidfile), PIDFILE, "", "", ""); @@ -1982,7 +1988,8 @@ printpidfile: if ((pid = pidfile_lock(ctx.pidfile)) != 0) { if (pid == -1) - logerr("%s: pidfile_lock", __func__); + logerr("%s: pidfile_lock: %s", + __func__, ctx.pidfile); else logerrx(PACKAGE " already running on pid %d (%s)",