From 9b51b3c0a3e8139c6b03a211f8a1dde6ecd96b50 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Tue, 19 Mar 2019 20:09:37 +0100 Subject: Allow customizing lockfile location at configure time Users may pass LOCKFILE=/some/path/to/file when calling configure to make libebtc use that path for its lockfile. To simplify things, drop LOCKDIR completely and instead call dirname() when trying to create the parent directory. Given that we always define LOCKFILE via compiler flag, drop the fallback define from libebtc.c. Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- libebtc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'libebtc.c') diff --git a/libebtc.c b/libebtc.c index 92fd764..f2a2b50 100644 --- a/libebtc.c +++ b/libebtc.c @@ -36,6 +36,7 @@ #include #include #include +#include static void decrease_chain_jumps(struct ebt_u_replace *replace); static int iterate_entries(struct ebt_u_replace *replace, int type); @@ -134,10 +135,6 @@ void ebt_list_extensions() } } -#ifndef LOCKFILE -#define LOCKDIR "/var/lib/ebtables" -#define LOCKFILE LOCKDIR"/lock" -#endif int use_lockfd; /* Returns 0 on success, -1 when the file is locked by another process * or -2 on any other error. */ @@ -148,7 +145,7 @@ static int lock_file() retry: fd = open(LOCKFILE, O_CREAT, 00600); if (fd < 0) { - if (try == 1 || mkdir(LOCKDIR, 00700)) + if (try == 1 || mkdir(dirname(LOCKFILE), 00700)) return -2; try = 1; goto retry; -- cgit v1.2.3