Skip to content

Commit

Permalink
try to create rundir if missing
Browse files Browse the repository at this point in the history
Runtime dir changed from /run to /run/pppd in commit 66a8c74 ("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>
  • Loading branch information
martinetd committed Oct 10, 2023
1 parent b0e7307 commit 3a4fec9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pppd/tdb.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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) */
Expand Down

0 comments on commit 3a4fec9

Please sign in to comment.