diff options
Diffstat (limited to 'daemons/execd/remoted_tls.c')
-rw-r--r-- | daemons/execd/remoted_tls.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/daemons/execd/remoted_tls.c b/daemons/execd/remoted_tls.c index c65e3f3..23a2dcf 100644 --- a/daemons/execd/remoted_tls.c +++ b/daemons/execd/remoted_tls.c @@ -273,39 +273,44 @@ bind_and_listen(struct addrinfo *addr) fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); if (fd < 0) { - crm_perror(LOG_ERR, "Listener socket creation failed"); - return -1; + rc = errno; + crm_err("Listener socket creation failed: %", pcmk_rc_str(rc)); + return -rc; } /* reuse address */ optval = 1; rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)); if (rc < 0) { - crm_perror(LOG_ERR, "Local address reuse not allowed on %s", buffer); + rc = errno; + crm_err("Local address reuse not allowed on %s: %s", buffer, pcmk_rc_str(rc)); close(fd); - return -1; + return -rc; } if (addr->ai_family == AF_INET6) { optval = 0; rc = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &optval, sizeof(optval)); if (rc < 0) { - crm_perror(LOG_INFO, "Couldn't disable IPV6-only on %s", buffer); + rc = errno; + crm_err("Couldn't disable IPV6-only on %s: %s", buffer, pcmk_rc_str(rc)); close(fd); - return -1; + return -rc; } } if (bind(fd, addr->ai_addr, addr->ai_addrlen) != 0) { - crm_perror(LOG_ERR, "Cannot bind to %s", buffer); + rc = errno; + crm_err("Cannot bind to %s: %s", buffer, pcmk_rc_str(rc)); close(fd); - return -1; + return -rc; } if (listen(fd, 10) == -1) { - crm_perror(LOG_ERR, "Cannot listen on %s", buffer); + rc = errno; + crm_err("Cannot listen on %s: %s", buffer, pcmk_rc_str(rc)); close(fd); - return -1; + return -rc; } return fd; } @@ -325,12 +330,15 @@ get_address_info(const char *bind_name, int port, struct addrinfo **res) snprintf(port_str, sizeof(port_str), "%d", port); rc = getaddrinfo(bind_name, port_str, &hints, res); - if (rc) { + rc = pcmk__gaierror2rc(rc); + + if (rc != pcmk_rc_ok) { crm_err("Unable to get IP address(es) for %s: %s", - (bind_name? bind_name : "local node"), gai_strerror(rc)); - return -EADDRNOTAVAIL; + (bind_name? bind_name : "local node"), pcmk_rc_str(rc)); + return rc; } - return pcmk_ok; + + return pcmk_rc_ok; } int @@ -340,7 +348,7 @@ lrmd_init_remote_tls_server(void) int port = crm_default_remote_port(); struct addrinfo *res = NULL, *iter; gnutls_datum_t psk_key = { NULL, 0 }; - const char *bind_name = getenv("PCMK_remote_address"); + const char *bind_name = pcmk__env_option(PCMK__ENV_REMOTE_ADDRESS); static struct mainloop_fd_callbacks remote_listen_fd_callbacks = { .dispatch = lrmd_remote_listen, @@ -371,7 +379,7 @@ lrmd_init_remote_tls_server(void) } gnutls_free(psk_key.data); - if (get_address_info(bind_name, port, &res) != pcmk_ok) { + if (get_address_info(bind_name, port, &res) != pcmk_rc_ok) { return -1; } @@ -391,7 +399,7 @@ lrmd_init_remote_tls_server(void) if (iter->ai_family == filter) { ssock = bind_and_listen(iter); } - if (ssock != -1) { + if (ssock >= 0) { break; } |