init.d/sanlock.service.native | 2 +-
init.d/wdmd.service.native | 2 +-
src/main.c | 14 ++++++++++++--
wdmd/main.c | 13 ++++++++++---
4 files changed, 24 insertions(+), 7 deletions(-)
New commits:
commit c570bb9de43567024f3f3242e087de1f331fea0d
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Jun 15 12:59:33 2015 -0500
wdmd: remove -G from native systemd unit file
wdmd now tries to use the sanlock group for the
socket gid if it's available, so the command line
option is unnecessary.
diff --git a/init.d/wdmd.service.native b/init.d/wdmd.service.native
index 6596b07..ab0828e 100644
--- a/init.d/wdmd.service.native
+++ b/init.d/wdmd.service.native
@@ -5,7 +5,7 @@ After=syslog.target
[Service]
Type=forking
ExecStartPre=/lib/systemd/systemd-wdmd watchdog-check
-ExecStart=/usr/sbin/wdmd -G sanlock
+ExecStart=/usr/sbin/wdmd
SendSIGKILL=no
[Install]
commit 29e66d3a92cd6ce2f0ac140ecddfb368b643b4af
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Jun 15 12:57:32 2015 -0500
wdmd: default to socket gid of sanlock
If the socket group name is not specified on the
command line, and if the sanlock group is available,
use that for the socket gid instead of root.
diff --git a/wdmd/main.c b/wdmd/main.c
index 8a09632..c29667f 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -46,6 +46,11 @@
#define DEFAULT_FIRE_TIMEOUT 60
#define DEFAULT_HIGH_PRIORITY 1
+/*
+ * If the group name specified here, or specified on the
+ * command line is not found, then default to gid 0 (root).
+ */
+#define SOCKET_GNAME "sanlock"
#define DEFAULT_SOCKET_GID 0
#define DEFAULT_SOCKET_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
@@ -57,6 +62,7 @@ static int high_priority = DEFAULT_HIGH_PRIORITY;
static int daemon_quit;
static int daemon_debug;
static int socket_gid;
+static char *socket_gname = (char *)SOCKET_GNAME;
static time_t last_keepalive;
static time_t last_closeunclean;
static char lockfile_path[PATH_MAX];
@@ -1462,8 +1468,7 @@ static int group_to_gid(char *arg)
gr = getgrnam(arg);
if (gr == NULL) {
- log_error("group '%s' not found, "
- "using uid: %i", arg, DEFAULT_SOCKET_GID);
+ log_error("group '%s' not found, using socket gid: %i", arg,
DEFAULT_SOCKET_GID);
return DEFAULT_SOCKET_GID;
}
@@ -1577,7 +1582,7 @@ int main(int argc, char *argv[])
daemon_debug = 1;
break;
case 'G':
- socket_gid = group_to_gid(optarg);
+ socket_gname = strdup(optarg);
break;
case 'H':
high_priority = atoi(optarg);
@@ -1606,6 +1611,8 @@ int main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
+ socket_gid = group_to_gid(socket_gname);
+
if (!daemon_debug) {
if (daemon(0, 0) < 0) {
fprintf(stderr, "cannot fork daemon\n");
commit 27c9c2582c13d8587087eadae1757eba4f5d63f1
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Jun 15 11:51:48 2015 -0500
sanlock: remove -U and -G from native systemd unit file
sanlock now uses the sanlock user and group if it's
available on the system, so setting it from the
command line is unnecessary. To override the
default behavior when using the unit file, set the
desired user and group in sanlock.conf.
diff --git a/init.d/sanlock.service.native b/init.d/sanlock.service.native
index b915e92..11e020d 100644
--- a/init.d/sanlock.service.native
+++ b/init.d/sanlock.service.native
@@ -5,7 +5,7 @@ Wants=wdmd.service
[Service]
Type=forking
-ExecStart=/usr/sbin/sanlock daemon -U sanlock -G sanlock
+ExecStart=/usr/sbin/sanlock daemon
SendSIGKILL=no
[Install]
commit 95ddd92967e1af0a2ec9b67e714fa2793e505598
Author: David Teigland <teigland(a)redhat.com>
Date: Mon Jun 15 11:45:58 2015 -0500
sanlock: default to sanlock user and group if it exists
When the user and group are not specified on the command line
or in the config file, sanlock would previously default to the
"root" user and group. Now, it will check if the "sanlock"
user and group are available on the system, and if so default
to that instead of root.
diff --git a/src/main.c b/src/main.c
index d8a01ab..958b57b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3198,11 +3198,21 @@ int main(int argc, char *argv[])
com.max_worker_threads = DEFAULT_MAX_WORKER_THREADS;
com.io_timeout_arg = DEFAULT_IO_TIMEOUT;
com.aio_arg = DEFAULT_USE_AIO;
- com.uid = DEFAULT_SOCKET_UID;
- com.gid = DEFAULT_SOCKET_GID;
com.pid = -1;
com.sh_retries = DEFAULT_SH_RETRIES;
+ if (getgrnam("sanlock") && getpwnam("sanlock")) {
+ com.uname = (char *)"sanlock";
+ com.gname = (char *)"sanlock";
+ com.uid = user_to_uid(com.uname);
+ com.gid = group_to_gid(com.uname);
+ } else {
+ com.uname = NULL;
+ com.gname = NULL;
+ com.uid = DEFAULT_SOCKET_UID;
+ com.gid = DEFAULT_SOCKET_GID;
+ }
+
memset(&main_task, 0, sizeof(main_task));
/*
Show replies by thread