]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
build: Move rundir from /var/run to /var/run/dhcpcd
authorRoy Marples <roy@marples.name>
Thu, 28 Nov 2019 11:47:29 +0000 (11:47 +0000)
committerRoy Marples <roy@marples.name>
Thu, 28 Nov 2019 11:47:29 +0000 (11:47 +0000)
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.

configure
src/defs.h
src/dhcpcd.8.in
src/dhcpcd.c

index 9efa1638d5809416e552ef78d7086d2c0ad862d7..54a9b791ae883d5b329c43bf434785936d225b29 100755 (executable)
--- 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
index e9289e5df1e012d43526e972d50b3c41376cf818..c0116d367e3c7f274e2c31840313493abd37765d 100644 (file)
 # 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"
index 0199df883a7950d88ad5ee03e5dd53c9f5dae54e..9c145049d02df811ef7a0115e8de51f9409b5115 100644 (file)
@@ -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
index 11e8198014c31226452331350a15ee2b5daf133c..94c27780fc592dabca01d7aa23188b1057f492c7 100644 (file)
@@ -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)",