mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ctdb-mutex: Drop dependency on ctdb_set_helper
This makes the code more explicit and makes testing easier due to less dependencies. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
76ab0a2b82
commit
2b6f1a8ee6
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "replace.h"
|
#include "replace.h"
|
||||||
#include "system/network.h"
|
#include "system/network.h"
|
||||||
|
#include "system/filesys.h"
|
||||||
|
|
||||||
#include <tevent.h>
|
#include <tevent.h>
|
||||||
|
|
||||||
@ -32,7 +33,6 @@
|
|||||||
#include "lib/util/blocking.h"
|
#include "lib/util/blocking.h"
|
||||||
|
|
||||||
#include "ctdb_private.h"
|
#include "ctdb_private.h"
|
||||||
#include "common/common.h"
|
|
||||||
|
|
||||||
#include "ctdb_cluster_mutex.h"
|
#include "ctdb_cluster_mutex.h"
|
||||||
|
|
||||||
@ -121,21 +121,56 @@ static bool cluster_mutex_helper_args_file(TALLOC_CTX *mem_ctx,
|
|||||||
const char *argstring,
|
const char *argstring,
|
||||||
char ***argv)
|
char ***argv)
|
||||||
{
|
{
|
||||||
bool ok;
|
struct stat st;
|
||||||
|
size_t size = sizeof(cluster_mutex_helper);
|
||||||
|
const char *t;
|
||||||
char **args = NULL;
|
char **args = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
ok = ctdb_set_helper("cluster mutex helper",
|
if (cluster_mutex_helper[0] != '\0') {
|
||||||
cluster_mutex_helper,
|
goto helper_done;
|
||||||
sizeof(cluster_mutex_helper),
|
}
|
||||||
"CTDB_CLUSTER_MUTEX_HELPER",
|
|
||||||
|
t = getenv("CTDB_CLUSTER_MUTEX_HELPER");
|
||||||
|
if (t != NULL) {
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
len = strlcpy(cluster_mutex_helper, t, size);
|
||||||
|
if (len >= size) {
|
||||||
|
DBG_ERR("error: CTDB_CLUSTER_MUTEX_HELPER too long\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = snprintf(cluster_mutex_helper,
|
||||||
|
size,
|
||||||
|
"%s/%s",
|
||||||
CTDB_HELPER_BINDIR,
|
CTDB_HELPER_BINDIR,
|
||||||
"ctdb_mutex_fcntl_helper");
|
"ctdb_mutex_fcntl_helper");
|
||||||
if (! ok) {
|
if (ret < 0 || (size_t)ret >= size) {
|
||||||
DBG_ERR("ctdb exiting with error: "
|
D_ERR("Unable to set cluster mutex helper - "
|
||||||
"Unable to set cluster mutex helper\n");
|
"path too long\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = stat(cluster_mutex_helper, &st);
|
||||||
|
if (ret != 0) {
|
||||||
|
D_ERR("Unable to set cluster mutex helper \"%s\" - %s\n",
|
||||||
|
cluster_mutex_helper,
|
||||||
|
strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((st.st_mode & S_IXUSR) == 0) {
|
||||||
|
D_ERR("Unable to set cluster_mutex helper \"%s\" - "
|
||||||
|
"not executable\n",
|
||||||
|
cluster_mutex_helper);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
D_NOTICE("Set cluster mutex helper to \"%s\"\n", cluster_mutex_helper);
|
||||||
|
|
||||||
|
helper_done:
|
||||||
|
|
||||||
/* Array includes default helper, file and NULL */
|
/* Array includes default helper, file and NULL */
|
||||||
args = talloc_array(mem_ctx, char *, 3);
|
args = talloc_array(mem_ctx, char *, 3);
|
||||||
|
Loading…
Reference in New Issue
Block a user