summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2017-04-07 09:09:29 -0400
committerShyamsundar Ranganathan <srangana@redhat.com>2017-04-13 11:37:57 -0400
commite93e89b2e46033efa22447943269000c85588254 (patch)
tree5ebe46d8fc7dd28dc1aaac0a434cf881d42c7fb5 /xlators
parent0090727aea9dfcfdd06debadeb5cf9377adca64f (diff)
common-ha: fixes for Debian-based systems
1) Debian-based systems don't have /usr/libexec/... and there is a hard-coded invocation of /usr/libexec/ganesha/ganesha-ha.sh within ganesha-ha.sh itself. Fix: save $0 and use it instead for further invocations of self. 2) default shell is /bin/dash (not /bin/bash). Various runner_run() invocations for ganesha used what amounts to exec("sh /usr/$libexec/ganesha/ganesha-ha.sh ...); which executes the script using the default shell, but there are some bash-specific idioms that don't work if the shell is dash. Fix: change to exec("/usr/$libexec/ganesha/ganesha-ha.sh ...); so that the shebang forces the use of /bin/bash 3) Fedora and RHEL7 have merged /bin/ and /usr/bin, /bin is a symlink to /usr/bin. Debian-based systems are not merged, and systemd systems have /bin/systemctl. The logic to find .../bin/systemctl is backwards. If the logic looks for /usr/bin/systemctl it will not find it on Debian-based systems; if it looks for /bin/systemctl it will find it on Fedora and RHEL by virtue of the symlink. (RHEL6 and others will find their respective init regardless.) Fix: change the logic to look for /bin/systemctl instead. 4) The logic for deciding to run systemctl (or not) is a bit silly. Fix: simply invoke the found method via the function pointer in the table. Change-Id: I33681b296a73aebb078bda6ac0d3a1d3b9770a21 BUG: 1440148 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: https://review.gluster.org/17013 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-ganesha.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-ganesha.c b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
index 8dde82e89ed..f7b7f1371e5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-ganesha.c
+++ b/xlators/mgmt/glusterd/src/glusterd-ganesha.c
@@ -119,11 +119,10 @@ sc_service_action (struct service_command *sc, char *command)
static int
manage_service (char *action)
{
- struct stat stbuf = {0,};
int i = 0;
int ret = 0;
struct service_command sc_list[] = {
- { .binary = "/usr/bin/systemctl",
+ { .binary = "/bin/systemctl",
.service = "nfs-ganesha",
.action = sc_systemctl_action
},
@@ -140,16 +139,11 @@ manage_service (char *action)
};
while (sc_list[i].binary != NULL) {
- ret = sys_stat (sc_list[i].binary, &stbuf);
+ ret = sys_access (sc_list[i].binary, X_OK);
if (ret == 0) {
gf_msg_debug (THIS->name, 0,
- "%s found.", sc_list[i].binary);
- if (strcmp (sc_list[i].binary, "/usr/bin/systemctl") == 0)
- ret = sc_systemctl_action (&sc_list[i], action);
- else
- ret = sc_service_action (&sc_list[i], action);
-
- return ret;
+ "%s found.", sc_list[i].binary);
+ return sc_list[i].action (&sc_list[i], action);
}
i++;
}
@@ -465,9 +459,9 @@ manage_export_config (char *volname, char *value, char **op_errstr)
GF_ASSERT(volname);
runinit (&runner);
- runner_add_args (&runner, "sh",
- GANESHA_PREFIX"/create-export-ganesha.sh",
- CONFDIR, value, volname, NULL);
+ runner_add_args (&runner,
+ GANESHA_PREFIX"/create-export-ganesha.sh",
+ CONFDIR, value, volname, NULL);
ret = runner_run(&runner);
if (ret)
@@ -570,8 +564,9 @@ ganesha_manage_export (dict_t *dict, char *value, char **op_errstr)
}
if (check_host_list()) {
- runner_add_args (&runner, "sh", GANESHA_PREFIX"/dbus-send.sh",
- CONFDIR, value, volname, NULL);
+ runner_add_args (&runner,
+ GANESHA_PREFIX"/dbus-send.sh",
+ CONFDIR, value, volname, NULL);
ret = runner_run (&runner);
if (ret) {
gf_asprintf(op_errstr, "Dynamic export"
@@ -610,9 +605,9 @@ tear_down_cluster(gf_boolean_t run_teardown)
if (run_teardown) {
runinit (&runner);
- runner_add_args (&runner, "sh",
- GANESHA_PREFIX"/ganesha-ha.sh", "teardown",
- CONFDIR, NULL);
+ runner_add_args (&runner,
+ GANESHA_PREFIX"/ganesha-ha.sh", "teardown",
+ CONFDIR, NULL);
ret = runner_run(&runner);
/* *
* Remove all the entries in CONFDIR expect ganesha.conf and
@@ -675,7 +670,8 @@ setup_cluster(gf_boolean_t run_setup)
if (run_setup) {
runinit (&runner);
- runner_add_args (&runner, "sh", GANESHA_PREFIX"/ganesha-ha.sh",
+ runner_add_args (&runner,
+ GANESHA_PREFIX"/ganesha-ha.sh",
"setup", CONFDIR, NULL);
ret = runner_run (&runner);
}
@@ -702,8 +698,9 @@ teardown (gf_boolean_t run_teardown, char **op_errstr)
}
runinit (&runner);
- runner_add_args (&runner, "sh", GANESHA_PREFIX"/ganesha-ha.sh",
- "cleanup", CONFDIR, NULL);
+ runner_add_args (&runner,
+ GANESHA_PREFIX"/ganesha-ha.sh",
+ "cleanup", CONFDIR, NULL);
ret = runner_run (&runner);
if (ret)
gf_msg_debug (THIS->name, 0, "Could not clean up"
@@ -747,7 +744,8 @@ stop_ganesha (char **op_errstr) {
runner_t runner = {0,};
runinit (&runner);
- runner_add_args (&runner, "sh", GANESHA_PREFIX"/ganesha-ha.sh",
+ runner_add_args (&runner,
+ GANESHA_PREFIX"/ganesha-ha.sh",
"--setup-ganesha-conf-files", CONFDIR, "no", NULL);
ret = runner_run (&runner);
if (ret) {
@@ -809,7 +807,8 @@ start_ganesha (char **op_errstr)
}
runinit (&runner);
- runner_add_args (&runner, "sh", GANESHA_PREFIX"/ganesha-ha.sh",
+ runner_add_args (&runner,
+ GANESHA_PREFIX"/ganesha-ha.sh",
"--setup-ganesha-conf-files", CONFDIR, "yes", NULL);
ret = runner_run (&runner);
if (ret) {