diff mbox series

[v2,3/3] package/pppd: create rundir when it is missing

Message ID 20240411133507.82781-4-alexis.lothore@bootlin.com
State New
Headers show
Series package/pppd: fix pppd startup with upstream patches | expand

Commit Message

Alexis Lothoré April 11, 2024, 1:35 p.m. UTC
pppd fails to start on buildroot 2024.02, because of non-existing directory
pppd in /var/run

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
---
 ...0007-try-to-create-rundir-if-missing.patch | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 package/pppd/0007-try-to-create-rundir-if-missing.patch
diff mbox series

Patch

diff --git a/package/pppd/0007-try-to-create-rundir-if-missing.patch b/package/pppd/0007-try-to-create-rundir-if-missing.patch
new file mode 100644
index 000000000000..d223abf801bf
--- /dev/null
+++ b/package/pppd/0007-try-to-create-rundir-if-missing.patch
@@ -0,0 +1,52 @@ 
+From 8ef2b1d5e13540cfb365490ea1ed131784184c1a Mon Sep 17 00:00:00 2001
+From: Dominique Martinet <dominique.martinet@atmark-techno.com>
+Date: Thu, 3 Aug 2023 16:37:27 +0900
+Subject: [PATCH] try to create rundir if missing
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Runtime dir changed from /run to /run/pppd in commit 66a8c74c3f73 ("Let
+./configure control the paths for pppd") and is likely to not exist on
+some distros, in which case the pppdb will not be created.
+
+See: #419 (lock directory moved in ppp-2.5.0)
+Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
+Upstream: https://github.com/ppp-project/ppp/commit/3a4fec968174fd6f387d5ec872a56343f256f645
+Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
+---
+ pppd/tdb.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/pppd/tdb.c b/pppd/tdb.c
+index 8a563f88b9a6..62644171aa6e 100644
+--- a/pppd/tdb.c
++++ b/pppd/tdb.c
+@@ -60,8 +60,11 @@
+ #include <sys/mman.h>
+ #include <sys/stat.h>
+ #include <signal.h>
++
++#include "pppd-private.h"
+ #include "tdb.h"
+ #include "spinlock.h"
++#include "pathnames.h"
+ 
+ #define TDB_MAGIC_FOOD "TDB file\n"
+ #define TDB_VERSION (0x26011967 + 6)
+@@ -1728,7 +1731,12 @@ TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
+ 		goto internal;
+ 	}
+ 
++again:
+ 	if ((tdb->fd = open(name, open_flags, mode)) == -1) {
++		if ((open_flags & O_CREAT) && errno == ENOENT &&
++			mkdir_recursive(PPP_PATH_VARRUN) == 0)
++			goto again;
++
+ 		TDB_LOG((tdb, 5, "tdb_open_ex: could not open file %s: %s\n",
+ 			 name, strerror(errno)));
+ 		goto fail;	/* errno set by open(2) */
+-- 
+2.44.0
+