Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP4:GA
pacemaker.14737
pacemaker-validate-PCMK_remote_port.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pacemaker-validate-PCMK_remote_port.patch of Package pacemaker.14737
commit b3f5dae4a17567bf2fd1a7e71c1318d877a6c6cd Author: Ken Gaillot <kgaillot@redhat.com> Date: Thu Aug 31 16:46:52 2017 -0500 Low: libcrmcommon,liblrmd,lrmd: validate PCMK_remote_port This adds a new function for getting the local host's default TCP port for Pacemaker Remote connections. This reduces code duplication and adds more validation (i.e. it uses the assigned port number if PCMK_remote_port is not a valid port number). Index: pacemaker/include/crm/common/util.h =================================================================== --- pacemaker.orig/include/crm/common/util.h +++ pacemaker/include/crm/common/util.h @@ -50,6 +50,9 @@ /* Status of an offline client */ # endif +/* public Pacemaker Remote functions (from remote.c) */ +int crm_default_remote_port(void); + char *crm_itoa_stack(int an_int, char *buf, size_t len); char *crm_itoa(int an_int); gboolean crm_is_true(const char *s); Index: pacemaker/lib/common/remote.c =================================================================== --- pacemaker.orig/lib/common/remote.c +++ pacemaker/lib/common/remote.c @@ -1016,3 +1016,31 @@ crm_remote_accept(int ssock) return csock; } + +/*! + * \brief Get the default remote connection TCP port on this host + * + * \return Remote connection TCP port number + */ +int +crm_default_remote_port() +{ + static int port = 0; + + if (port == 0) { + const char *env = getenv("PCMK_remote_port"); + + if (env) { + errno = 0; + port = strtol(env, NULL, 10); + if (errno || (port < 1) || (port > 65535)) { + crm_warn("Environment variable PCMK_remote_port has invalid value '%s', using %d instead", + env, DEFAULT_REMOTE_PORT); + port = DEFAULT_REMOTE_PORT; + } + } else { + port = DEFAULT_REMOTE_PORT; + } + } + return port; +} Index: pacemaker/lib/lrmd/lrmd_client.c =================================================================== --- pacemaker.orig/lib/lrmd/lrmd_client.c +++ pacemaker/lib/lrmd/lrmd_client.c @@ -2213,8 +2213,7 @@ lrmd_remote_api_new(const char *nodename native->server = server ? strdup(server) : strdup(nodename); native->port = port; if (native->port == 0) { - const char *remote_port_str = getenv("PCMK_remote_port"); - native->port = remote_port_str ? atoi(remote_port_str) : DEFAULT_REMOTE_PORT; + native->port = crm_default_remote_port(); } return new_lrmd; Index: pacemaker/lrmd/main.c =================================================================== --- pacemaker.orig/lrmd/main.c +++ pacemaker/lrmd/main.c @@ -605,8 +605,7 @@ main(int argc, char **argv, char **envp) #ifdef ENABLE_PCMK_REMOTE { - const char *remote_port_str = getenv("PCMK_remote_port"); - int remote_port = remote_port_str ? atoi(remote_port_str) : DEFAULT_REMOTE_PORT; + int remote_port = crm_default_remote_port(); if (lrmd_init_remote_tls_server(remote_port) < 0) { crm_err("Failed to create TLS server on port %d: shutting down and inhibiting respawn", remote_port);
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