From c2dfa8104f4fa891b7663649996d95f8f570bddf Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Jan 12 2018 15:42:03 +0000 Subject: Fix lockfile() to use the given "dir" argument lockfile() was using SANLK_RUN_DIR for creating the run directory, and the dir argument for building the lockfile path. Use only dir so we can create a lockfile in another directory. This will be useful for running sanlock as non-privileged user during the tests. Signed-off-by: Nir Soffer --- diff --git a/src/lockfile.c b/src/lockfile.c index e3b720c..1839f56 100644 --- a/src/lockfile.c +++ b/src/lockfile.c @@ -25,7 +25,6 @@ #include #include "sanlock_internal.h" -#include "sanlock_sock.h" #include "log.h" #include "lockfile.h" @@ -38,17 +37,17 @@ int lockfile(const char *dir, const char *name, int uid, int gid) int fd, rv; old_umask = umask(0022); - rv = mkdir(SANLK_RUN_DIR, 0775); + rv = mkdir(dir, 0775); if (rv < 0 && errno != EEXIST) { umask(old_umask); return rv; } umask(old_umask); - rv = chown(SANLK_RUN_DIR, uid, gid); + rv = chown(dir, uid, gid); if (rv < 0) { log_error("lockfile chown error %s: %s", - SANLK_RUN_DIR, strerror(errno)); + dir, strerror(errno)); return rv; }