On Thu, May 23, 2019 at 3:35 PM Pavel Bar <pbar@redhat.com> wrote:
Looks OK.
Too bad there is no clean way to eliminate the hard-coded appearance of the "/run" across multiple files (.c, .h, scripts).

It is possible to avoid the duplication. For example, keeping the configuration
in a text file, and generating config.h, config.py, and config.sh files to share
the values with the components that need these values.

But this is is a task for another day.

On Wed, May 22, 2019 at 10:37 PM Nir Soffer <nirsof@gmail.com> wrote:
/var/run is a symlink to /run since RHEL 7, and few year before that on
Fedora. rpmlint is complaining in Fedora that we still use it:

    sanlock.x86_64: E: dir-or-file-in-var-run /var/run/sanlock

Replace all instance of /var/run with /run.

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
---
 fence_sanlock/fence_sanlock.in |  2 +-
 fence_sanlock/fence_sanlockd.c |  6 +++---
 init.d/fence_sanlockd          | 12 ++++++------
 init.d/sanlock                 |  8 ++++----
 init.d/wdmd                    |  8 ++++----
 reset/sanlk_reset.h            |  2 +-
 sanlock.spec.in                |  2 +-
 src/sanlock_internal.h         |  2 +-
 tests/clientn                  |  4 ++--
 wdmd/main.c                    |  4 ++--
 wdmd/wdmd_sock.h               |  2 +-
 11 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/fence_sanlock/fence_sanlock.in b/fence_sanlock/fence_sanlock.in
index dbc0f24..a46773c 100755
--- a/fence_sanlock/fence_sanlock.in
+++ b/fence_sanlock/fence_sanlock.in
@@ -254,11 +254,11 @@ action_off() {

        # pid file should be unique for each instance so multiple
        # fence_sanlock's can run in parallel.  fence_sanlockd may read
        # this file to see which host_id we are fencing.

-       pidfile=/var/run/$prog/$prog.pid.$$
+       pidfile=/run/$prog/$prog.pid.$$

        echo "$$ host_id $host_id gen $owner_gen ver $ver timestamp $timestamp" > $pidfile

        logger -t $prog "$$ host_id $host_id gen $owner_gen ver $ver timestamp $timestamp"

diff --git a/fence_sanlock/fence_sanlockd.c b/fence_sanlock/fence_sanlockd.c
index be342c1..6ad7be1 100644
--- a/fence_sanlock/fence_sanlockd.c
+++ b/fence_sanlock/fence_sanlockd.c
@@ -35,12 +35,12 @@
 #define MAX_HOSTS 128 /* keep in sync with fence_sanlock definition */

 #define LIVE_INTERVAL 5
 #define EXPIRE_INTERVAL 20

-#define DAEMON_RUN_DIR "/var/run/fence_sanlockd"
-#define AGENT_RUN_DIR "/var/run/fence_sanlock"
+#define DAEMON_RUN_DIR "/run/fence_sanlockd"
+#define AGENT_RUN_DIR "/run/fence_sanlock"

 static char *prog_name = (char *)"fence_sanlockd";

 static int we_are_victim;
 static int we_are_fencing;
@@ -439,11 +439,11 @@ static int check_fence_agent(int *victim_host_id)
                memset(name, 0, sizeof(name));

                log_debug("read %s", de->d_name);

                /*
-                * read /var/run/fence_sanlock/fence_sanlock.pid.<pid>
+                * read /run/fence_sanlock/fence_sanlock.pid.<pid>
                 * to get the pid of fence_sanlock and the victim's host_id
                 *
                 * read /proc/pid/comm to check that the pid from that file
                 * is still running and hasn't been killed
                 *
diff --git a/init.d/fence_sanlockd b/init.d/fence_sanlockd
index fb5fae8..99041b5 100755
--- a/init.d/fence_sanlockd
+++ b/init.d/fence_sanlockd
@@ -21,12 +21,12 @@

 . /etc/rc.d/init.d/functions

 prog="fence_sanlockd"
 agent="fence_sanlock"
-runfile="/var/run/$prog/$prog.pid"
-fifofile="/var/run/$prog/$prog.fifo"
+runfile="/run/$prog/$prog.pid"
+fifofile="/run/$prog/$prog.fifo"
 lockfile="/var/lock/subsys/$prog"
 exec="/usr/sbin/$prog"

 FENCESANLOCKDOPTS="-w"

@@ -39,21 +39,21 @@ start() {

        service wdmd status > /dev/null 2>&1 || service wdmd start

        service sanlock status > /dev/null 2>&1 || service sanlock start

-       [ ! -d /var/run/$prog ] && install -d -m 775 /var/run/$prog
+       [ ! -d /run/$prog ] && install -d -m 775 /run/$prog

-       [ ! -d /var/run/$agent ] && install -d -m 775 /var/run/$agent
+       [ ! -d /run/$agent ] && install -d -m 775 /run/$agent

        [ -n "$(which restorecon)" ] && \
                [ -x "$(which restorecon)" ] && \
-               restorecon /var/run/$prog
+               restorecon /run/$prog

        [ -n "$(which restorecon)" ] && \
                [ -x "$(which restorecon)" ] && \
-               restorecon /var/run/$agent
+               restorecon /run/$agent

        echo -n $"Starting $prog: "
        daemon $prog $FENCESANLOCKDOPTS
        retval=$?
        echo
diff --git a/init.d/sanlock b/init.d/sanlock
index 83b35e8..bc1c330 100644
--- a/init.d/sanlock
+++ b/init.d/sanlock
@@ -20,11 +20,11 @@
 ### END INIT INFO

 . /etc/rc.d/init.d/functions

 prog="sanlock"
-runfile="/var/run/$prog/$prog.pid"
+runfile="/run/$prog/$prog.pid"
 lockfile="/var/lock/subsys/$prog"
 exec="/usr/sbin/$prog"

 SANLOCKUSER="sanlock"
 SANLOCKOPTS="-U $SANLOCKUSER -G $SANLOCKUSER"
@@ -32,13 +32,13 @@ SANLOCKOPTS="-U $SANLOCKUSER -G $SANLOCKUSER"
 [ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

 start() {
        [ -x $exec ] || exit 5

-       if [ ! -d /var/run/$prog ]; then
-               install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775 /var/run/$prog
-               [ -x /sbin/restorecon ] && restorecon /var/run/$prog
+       if [ ! -d /run/$prog ]; then
+               install -d -o $SANLOCKUSER -g $SANLOCKUSER -m 775 /run/$prog
+               [ -x /sbin/restorecon ] && restorecon /run/$prog
        fi

        echo -n $"Starting $prog: "
        daemon $prog daemon $SANLOCKOPTS
        retval=$?
diff --git a/init.d/wdmd b/init.d/wdmd
index 565342d..b6a2a79 100644
--- a/init.d/wdmd
+++ b/init.d/wdmd
@@ -20,11 +20,11 @@
 ### END INIT INFO

 . /etc/rc.d/init.d/functions

 prog="wdmd"
-runfile="/var/run/$prog/$prog.pid"
+runfile="/run/$prog/$prog.pid"
 lockfile="/var/lock/subsys/$prog"
 exec="/usr/sbin/$prog"

 WDMDGROUP="sanlock"
 WDMDOPTS="-G $WDMDGROUP"
@@ -58,13 +58,13 @@ watchdog_check() {
 start() {
        watchdog_check

        [ -x $exec ] || exit 5

-       if [ ! -d /var/run/$prog ]; then
-               install -d -g $WDMDGROUP -m 775 /var/run/$prog
-               [ -x /sbin/restorecon ] && restorecon /var/run/$prog
+       if [ ! -d /run/$prog ]; then
+               install -d -g $WDMDGROUP -m 775 /run/$prog
+               [ -x /sbin/restorecon ] && restorecon /run/$prog
        fi

        echo -n $"Starting $prog: "
        daemon $prog $WDMDOPTS
        retval=$?
diff --git a/reset/sanlk_reset.h b/reset/sanlk_reset.h
index 8c92c8e..377f511 100644
--- a/reset/sanlk_reset.h
+++ b/reset/sanlk_reset.h
@@ -12,11 +12,11 @@
 #define EVENT_RESET              1
 #define EVENT_RESETTING          2
 #define EVENT_REBOOT             4
 #define EVENT_REBOOTING          8

-#define SANLK_RESETD_RUNDIR "/var/run/sanlk-resetd"
+#define SANLK_RESETD_RUNDIR "/run/sanlk-resetd"
 #define SANLK_RESETD_SOCKET SANLK_RESETD_RUNDIR "/sanlk-resetd.sock"
 #define SANLK_RESETD_SOCKET_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)

 #define UPDATE_SIZE 256  /* sendmsg size on unix socket */

diff --git a/sanlock.spec.in b/sanlock.spec.in
index 6485c61..cf72ad4 100644
--- a/sanlock.spec.in
+++ b/sanlock.spec.in
@@ -89,11 +89,11 @@ install -Dd -m 0775 $RPM_BUILD_ROOT/%{_localstatedir}/run/sanlk-resetd
 %pre
 getent group sanlock > /dev/null || /usr/sbin/groupadd \
        -g 179 sanlock
 getent passwd sanlock > /dev/null || /usr/sbin/useradd \
        -u 179 -c "sanlock" -s /sbin/nologin -r \
-       -g 179 -d /var/run/sanlock sanlock
+       -g 179 -d /run/sanlock sanlock
 /usr/sbin/usermod -a -G disk sanlock

 %post
 %systemd_post wdmd.service sanlock.service

diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
index 3a09b62..a78c81f 100644
--- a/src/sanlock_internal.h
+++ b/src/sanlock_internal.h
@@ -44,11 +44,11 @@
 /* this is just the path to the executable, not full command line */

 #define COMMAND_MAX 4096

 #define SANLOCK_RUN_DIR "SANLOCK_RUN_DIR"
-#define DEFAULT_RUN_DIR "/var/run/sanlock"
+#define DEFAULT_RUN_DIR "/run/sanlock"
 #define SANLOCK_PRIVILEGED "SANLOCK_PRIVILEGED"

 #define SANLK_LOG_DIR "/var/log"
 #define SANLK_LOGFILE_NAME "sanlock.log"
 #define SANLK_LOCKFILE_NAME "sanlock.pid"
diff --git a/tests/clientn b/tests/clientn
index 85b4181..bd6bf5a 100755
--- a/tests/clientn
+++ b/tests/clientn
@@ -31,11 +31,11 @@ elif [ "$cmd" == "start" ]; then

 elif [ "$cmd" == "delay" ]; then

        sec=$3

-       pid=`cat /var/run/sanlock/sanlock.pid`
+       pid=`cat /run/sanlock/sanlock.pid`

        echo sync with daemon renewals
        kill -s SIGSTOP $pid
        sleep 20
        kill -s SIGCONT $pid
@@ -52,11 +52,11 @@ elif [ "$cmd" == "delay" ]; then

 elif [ "$cmd" == "iodelay" ]; then

        sec=$4

-       pid=`cat /var/run/sanlock/sanlock.pid`
+       pid=`cat /run/sanlock/sanlock.pid`

        echo sync with daemon renewals
        kill -s SIGSTOP $pid
        sleep 20
        kill -s SIGCONT $pid
diff --git a/wdmd/main.c b/wdmd/main.c
index 911d833..edd15e8 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -567,11 +567,11 @@ static int active_clients(void)
        return 0;
 }


 #ifdef TEST_FILES
-#define FILES_DIR "/var/run/wdmd/test_files"
+#define FILES_DIR "/run/wdmd/test_files"
 const char *files_built = " files";
 static DIR *files_dir;

 static void close_files(void)
 {
@@ -1022,11 +1022,11 @@ static int _setup_watchdog(char *path)
                return -1;
        }
  out:
        log_error("%s armed with fire_timeout %d", watchdog_path, fire_timeout);

-       /* TODO: save watchdog_path in /var/run/wdmd/saved_path,
+       /* TODO: save watchdog_path in /run/wdmd/saved_path,
         * and in startup read that file, copying it to saved_path */

        return 0;
 }

diff --git a/wdmd/wdmd_sock.h b/wdmd/wdmd_sock.h
index 6818683..f5ed27e 100644
--- a/wdmd/wdmd_sock.h
+++ b/wdmd/wdmd_sock.h
@@ -8,11 +8,11 @@
  */

 #ifndef __WDMD_SOCK_H__
 #define __WDMD_SOCK_H__

-#define WDMD_RUN_DIR "/var/run/wdmd"
+#define WDMD_RUN_DIR "/run/wdmd"
 #define WDMD_SOCKET_NAME "wdmd.sock"

 enum {
        CMD_REGISTER = 1,
        CMD_REFCOUNT_SET,
--
2.17.2