|
|
cdf651 |
From 45a48b9a73f39e9ef9e622dbcf87cc05a2a54e40 Mon Sep 17 00:00:00 2001
|
|
|
cdf651 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
cdf651 |
Date: Tue, 22 May 2018 17:59:52 +0200
|
|
|
cdf651 |
Subject: [PATCH] krb5 locator: fix IPv6 support
|
|
|
cdf651 |
|
|
|
cdf651 |
IPv6 addresses are added with surrounding '[' and ']' to the kdcinfo
|
|
|
cdf651 |
file to be able to specify a port number properly. The Kerberos location
|
|
|
cdf651 |
plugin didn't handle those entries properly.
|
|
|
cdf651 |
|
|
|
cdf651 |
Related to https://pagure.io/SSSD/sssd/issue/941
|
|
|
cdf651 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
cdf651 |
|
|
|
cdf651 |
(cherry picked from commit 9f683246228848173c57ad02bde241bd761481ea)
|
|
|
cdf651 |
---
|
|
|
cdf651 |
src/krb5_plugin/sssd_krb5_locator_plugin.c | 19 +++++++++++++++++--
|
|
|
cdf651 |
1 file changed, 17 insertions(+), 2 deletions(-)
|
|
|
cdf651 |
|
|
|
cdf651 |
diff --git a/src/krb5_plugin/sssd_krb5_locator_plugin.c b/src/krb5_plugin/sssd_krb5_locator_plugin.c
|
|
|
cdf651 |
index 82fb5c7b2ffa319ed250e54cdf9a0b6798d4ff51..58cac7f4b244903347e6f1811cd8de2d61281c4f 100644
|
|
|
cdf651 |
--- a/src/krb5_plugin/sssd_krb5_locator_plugin.c
|
|
|
cdf651 |
+++ b/src/krb5_plugin/sssd_krb5_locator_plugin.c
|
|
|
cdf651 |
@@ -159,6 +159,8 @@ static int buf_to_addr_port_list(struct sssd_ctx *ctx,
|
|
|
cdf651 |
uint8_t *pn;
|
|
|
cdf651 |
size_t c;
|
|
|
cdf651 |
size_t len;
|
|
|
cdf651 |
+ size_t addr_len;
|
|
|
cdf651 |
+ char *addr_str = NULL;
|
|
|
cdf651 |
char *tmp = NULL;
|
|
|
cdf651 |
char *port_str;
|
|
|
cdf651 |
long port;
|
|
|
cdf651 |
@@ -206,6 +208,9 @@ static int buf_to_addr_port_list(struct sssd_ctx *ctx,
|
|
|
cdf651 |
port_str = strrchr(tmp, ':');
|
|
|
cdf651 |
if (port_str == NULL) {
|
|
|
cdf651 |
port = 0;
|
|
|
cdf651 |
+ } else if (tmp[0] == '[' && *(port_str - 1) != ']') {
|
|
|
cdf651 |
+ /* IPv6 address without port number */
|
|
|
cdf651 |
+ port = 0;
|
|
|
cdf651 |
} else {
|
|
|
cdf651 |
*port_str = '\0';
|
|
|
cdf651 |
++port_str;
|
|
|
cdf651 |
@@ -239,9 +244,19 @@ static int buf_to_addr_port_list(struct sssd_ctx *ctx,
|
|
|
cdf651 |
}
|
|
|
cdf651 |
}
|
|
|
cdf651 |
|
|
|
cdf651 |
- PLUGIN_DEBUG(("Found [%s][%d].\n", tmp, port));
|
|
|
cdf651 |
+ /* make sure tmp is not modified so that it can be freed later */
|
|
|
cdf651 |
+ addr_str = tmp;
|
|
|
cdf651 |
+ /* strip leading '[' and trailing ']' from IPv6 addresses */
|
|
|
cdf651 |
+ if (addr_str[0] == '['
|
|
|
cdf651 |
+ && (addr_len = strlen(addr_str))
|
|
|
cdf651 |
+ && addr_str[addr_len - 1] == ']') {
|
|
|
cdf651 |
+ addr_str[addr_len -1] = '\0';
|
|
|
cdf651 |
+ addr_str++;
|
|
|
cdf651 |
+ }
|
|
|
cdf651 |
|
|
|
cdf651 |
- l[c].addr = strdup(tmp);
|
|
|
cdf651 |
+ PLUGIN_DEBUG(("Found [%s][%d].\n", addr_str, port));
|
|
|
cdf651 |
+
|
|
|
cdf651 |
+ l[c].addr = strdup(addr_str);
|
|
|
cdf651 |
if (l[c].addr == NULL) {
|
|
|
cdf651 |
ret = ENOMEM;
|
|
|
cdf651 |
goto done;
|
|
|
cdf651 |
--
|
|
|
cdf651 |
2.17.1
|
|
|
cdf651 |
|