Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP1:GA
pacemaker.13283
pacemaker-libcrmservice-find-absolute-paths-whe...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pacemaker-libcrmservice-find-absolute-paths-when-used-with-service.patch of Package pacemaker.13283
commit f9739f8f57cc64d6d9025f42e5c59ecfe4635817 Author: Ken Gaillot <kgaillot@redhat.com> Date: Mon May 7 13:17:14 2018 -0500 Fix: libcrmservice: find absolute paths when used with "service:" Previously, "service:" would work correctly only when specified with a path relative to the LSB init directory. Now, it also works when the agent type is an absolute path. This also refactors the relevant code into new functions in services_lsb.c. diff --git a/lib/services/services.c b/lib/services/services.c index 251ea040d..caf6254cc 100644 --- a/lib/services/services.c +++ b/lib/services/services.c @@ -12,9 +12,7 @@ #endif #include <sys/types.h> -#include <sys/stat.h> #include <stdio.h> - #include <errno.h> #include <unistd.h> #include <dirent.h> @@ -63,18 +61,9 @@ static void handle_blocked_ops(void); const char * resources_find_service_class(const char *agent) { - char *path = NULL; - -#ifdef LSB_ROOT_DIR - struct stat st; - - path = crm_strdup_printf("%s/%s", LSB_ROOT_DIR, agent); - if (stat(path, &st) == 0) { - free(path); + if (services__lsb_agent_exists(agent)) { return PCMK_RESOURCE_CLASS_LSB; } - free(path); -#endif #if SUPPORT_SYSTEMD if (systemd_unit_exists(agent)) { @@ -235,7 +224,7 @@ resources_action_create(const char *name, const char *standard, op->opaque->args[1] = strdup(action); } else if (strcasecmp(op->standard, PCMK_RESOURCE_CLASS_LSB) == 0) { - op->opaque->exec = dup_file_path(op->agent, LSB_ROOT_DIR); + op->opaque->exec = services__lsb_agent_path(op->agent); op->opaque->args[0] = strdup(op->opaque->exec); op->opaque->args[1] = strdup(op->action); op->opaque->args[2] = NULL; diff --git a/lib/services/services_lsb.c b/lib/services/services_lsb.c index 69063e9a8..f0b0d12b6 100644 --- a/lib/services/services_lsb.c +++ b/lib/services/services_lsb.c @@ -13,6 +13,7 @@ #include <stdio.h> #include <errno.h> +#include <sys/stat.h> #include <crm/crm.h> #include <crm/services.h> @@ -244,6 +245,25 @@ services__list_lsb_agents(void) return services_os_get_directory_list(LSB_ROOT_DIR, TRUE, TRUE); } +char * +services__lsb_agent_path(const char *agent) +{ + return (*agent == '/')? strdup(agent) + : crm_strdup_printf("%s/%s", LSB_ROOT_DIR, agent); +} + +bool +services__lsb_agent_exists(const char *agent) +{ + bool rc = FALSE; + struct stat st; + char *path = services__lsb_agent_path(agent); + + rc = (stat(path, &st) == 0); + free(path); + return rc; +} + /* The remaining functions below are not used by the Pacemaker code base, and * are provided for API compatibility only. * diff --git a/lib/services/services_lsb.h b/lib/services/services_lsb.h index 8a0d99d0e..11a07ca86 100644 --- a/lib/services/services_lsb.h +++ b/lib/services/services_lsb.h @@ -10,5 +10,7 @@ G_GNUC_INTERNAL int services__get_lsb_metadata(const char *type, char **output); G_GNUC_INTERNAL GList *services__list_lsb_agents(void); +G_GNUC_INTERNAL char *services__lsb_agent_path(const char *agent); +G_GNUC_INTERNAL bool services__lsb_agent_exists(const char *agent); #endif
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor