276 lines
11 KiB
Diff
276 lines
11 KiB
Diff
From 0f44cbdfcbf35278c984a12b22a1c01f38a2c5ab Mon Sep 17 00:00:00 2001
|
|
From: Lukas Slebodnik <lslebodn@redhat.com>
|
|
Date: Thu, 19 Jul 2018 09:44:33 +0200
|
|
Subject: [PATCH 3/7] krb5_locator: Simplify usage of macro PLUGIN_DEBUG
|
|
|
|
It should look like real function call
|
|
|
|
Merges: https://pagure.io/SSSD/sssd/pull-request/3786
|
|
|
|
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
(cherry picked from commit 276f2e345548947b66f7bd3b984628eaf6f4cbd4)
|
|
---
|
|
src/krb5_plugin/sssd_krb5_locator_plugin.c | 88 +++++++++++++++---------------
|
|
1 file changed, 44 insertions(+), 44 deletions(-)
|
|
|
|
diff --git a/src/krb5_plugin/sssd_krb5_locator_plugin.c b/src/krb5_plugin/sssd_krb5_locator_plugin.c
|
|
index 7800ab0..61fee6b 100644
|
|
--- a/src/krb5_plugin/sssd_krb5_locator_plugin.c
|
|
+++ b/src/krb5_plugin/sssd_krb5_locator_plugin.c
|
|
@@ -63,9 +63,9 @@
|
|
#define SSSD_KRB5_LOCATOR_DEBUG "SSSD_KRB5_LOCATOR_DEBUG"
|
|
#define SSSD_KRB5_LOCATOR_DISABLE "SSSD_KRB5_LOCATOR_DISABLE"
|
|
#define DEBUG_KEY "[sssd_krb5_locator] "
|
|
-#define PLUGIN_DEBUG(body) do { \
|
|
+#define PLUGIN_DEBUG(format, ...) do { \
|
|
if (ctx->debug) { \
|
|
- plugin_debug_fn body; \
|
|
+ plugin_debug_fn(format, ##__VA_ARGS__); \
|
|
} \
|
|
} while(0)
|
|
|
|
@@ -236,26 +236,26 @@ static int buf_to_addr_port_list(struct sssd_ctx *ctx,
|
|
port = strtol(port_str, &endptr, 10);
|
|
if (errno != 0) {
|
|
ret = errno;
|
|
- PLUGIN_DEBUG(("strtol failed on [%s]: [%d][%s], "
|
|
- "assuming default.\n", port_str, ret,
|
|
- strerror(ret)));
|
|
+ PLUGIN_DEBUG("strtol failed on [%s]: [%d][%s], "
|
|
+ "assuming default.\n",
|
|
+ port_str, ret, strerror(ret));
|
|
port = 0;
|
|
}
|
|
if (*endptr != '\0') {
|
|
- PLUGIN_DEBUG(("Found additional characters [%s] in port "
|
|
- "number [%s], assuming default.\n", endptr,
|
|
- port_str));
|
|
+ PLUGIN_DEBUG("Found additional characters [%s] in port "
|
|
+ "number [%s], assuming default.\n",
|
|
+ endptr, port_str);
|
|
port = 0;
|
|
}
|
|
|
|
if (port < 0 || port > 65535) {
|
|
- PLUGIN_DEBUG(("Illegal port number [%ld], assuming "
|
|
- "default.\n", port));
|
|
+ PLUGIN_DEBUG("Illegal port number [%ld], assuming "
|
|
+ "default.\n", port);
|
|
port = 0;
|
|
}
|
|
} else {
|
|
- PLUGIN_DEBUG(("Illegal port number [%s], assuming default.\n",
|
|
- port_str));
|
|
+ PLUGIN_DEBUG("Illegal port number [%s], assuming default.\n",
|
|
+ port_str);
|
|
port = 0;
|
|
}
|
|
}
|
|
@@ -270,7 +270,7 @@ static int buf_to_addr_port_list(struct sssd_ctx *ctx,
|
|
addr_str++;
|
|
}
|
|
|
|
- PLUGIN_DEBUG(("Found [%s][%d].\n", addr_str, port));
|
|
+ PLUGIN_DEBUG("Found [%s][%d].\n", addr_str, port);
|
|
|
|
l[c].addr = strdup(addr_str);
|
|
if (l[c].addr == NULL) {
|
|
@@ -314,7 +314,7 @@ static int get_krb5info(const char *realm, struct sssd_ctx *ctx,
|
|
name_tmpl = KPASSWDINFO_TMPL;
|
|
break;
|
|
default:
|
|
- PLUGIN_DEBUG(("Unsupported service [%d].\n", svc));
|
|
+ PLUGIN_DEBUG("Unsupported service [%d].\n", svc);
|
|
return EINVAL;
|
|
}
|
|
|
|
@@ -323,13 +323,13 @@ static int get_krb5info(const char *realm, struct sssd_ctx *ctx,
|
|
|
|
krb5info_name = calloc(1, len + 1);
|
|
if (krb5info_name == NULL) {
|
|
- PLUGIN_DEBUG(("malloc failed.\n"));
|
|
+ PLUGIN_DEBUG("malloc failed.\n");
|
|
return ENOMEM;
|
|
}
|
|
|
|
ret = snprintf(krb5info_name, len, name_tmpl, realm);
|
|
if (ret < 0) {
|
|
- PLUGIN_DEBUG(("snprintf failed.\n"));
|
|
+ PLUGIN_DEBUG("snprintf failed.\n");
|
|
ret = EINVAL;
|
|
goto done;
|
|
}
|
|
@@ -337,8 +337,8 @@ static int get_krb5info(const char *realm, struct sssd_ctx *ctx,
|
|
|
|
fd = open(krb5info_name, O_RDONLY);
|
|
if (fd == -1) {
|
|
- PLUGIN_DEBUG(("open failed [%s][%d][%s].\n",
|
|
- krb5info_name, errno, strerror(errno)));
|
|
+ PLUGIN_DEBUG("open failed [%s][%d][%s].\n",
|
|
+ krb5info_name, errno, strerror(errno));
|
|
ret = errno;
|
|
goto done;
|
|
}
|
|
@@ -349,15 +349,15 @@ static int get_krb5info(const char *realm, struct sssd_ctx *ctx,
|
|
len = sss_atomic_read_s(fd, buf, BUFSIZE);
|
|
if (len == -1) {
|
|
ret = errno;
|
|
- PLUGIN_DEBUG(("read failed [%d][%s].\n", ret, strerror(ret)));
|
|
+ PLUGIN_DEBUG("read failed [%d][%s].\n", ret, strerror(ret));
|
|
close(fd);
|
|
goto done;
|
|
}
|
|
close(fd);
|
|
|
|
if (len == BUFSIZE) {
|
|
- PLUGIN_DEBUG(("Content of krb5info file [%s] is [%d] or larger.\n",
|
|
- krb5info_name, BUFSIZE));
|
|
+ PLUGIN_DEBUG("Content of krb5info file [%s] is [%d] or larger.\n",
|
|
+ krb5info_name, BUFSIZE);
|
|
}
|
|
|
|
switch (svc) {
|
|
@@ -376,7 +376,7 @@ static int get_krb5info(const char *realm, struct sssd_ctx *ctx,
|
|
}
|
|
break;
|
|
default:
|
|
- PLUGIN_DEBUG(("Unsupported service [%d].\n", svc));
|
|
+ PLUGIN_DEBUG("Unsupported service [%d].\n", svc);
|
|
ret = EINVAL;
|
|
goto done;
|
|
}
|
|
@@ -401,7 +401,7 @@ krb5_error_code sssd_krb5_locator_init(krb5_context context,
|
|
ctx->debug = false;
|
|
} else {
|
|
ctx->debug = true;
|
|
- PLUGIN_DEBUG(("sssd_krb5_locator_init called\n"));
|
|
+ PLUGIN_DEBUG("sssd_krb5_locator_init called\n");
|
|
}
|
|
|
|
dummy = getenv(SSSD_KRB5_LOCATOR_DISABLE);
|
|
@@ -409,7 +409,7 @@ krb5_error_code sssd_krb5_locator_init(krb5_context context,
|
|
ctx->disabled = false;
|
|
} else {
|
|
ctx->disabled = true;
|
|
- PLUGIN_DEBUG(("SSSD KRB5 locator plugin is disabled.\n"));
|
|
+ PLUGIN_DEBUG("SSSD KRB5 locator plugin is disabled.\n");
|
|
}
|
|
|
|
*private_data = ctx;
|
|
@@ -424,7 +424,7 @@ void sssd_krb5_locator_close(void *private_data)
|
|
if (private_data == NULL) return;
|
|
|
|
ctx = (struct sssd_ctx *) private_data;
|
|
- PLUGIN_DEBUG(("sssd_krb5_locator_close called\n"));
|
|
+ PLUGIN_DEBUG("sssd_krb5_locator_close called\n");
|
|
|
|
free_addr_port_list(&(ctx->kdc_addr));
|
|
free_addr_port_list(&(ctx->kpasswd_addr));
|
|
@@ -460,7 +460,7 @@ krb5_error_code sssd_krb5_locator_lookup(void *private_data,
|
|
}
|
|
|
|
if (ctx->disabled) {
|
|
- PLUGIN_DEBUG(("Plugin disabled, nothing to do.\n"));
|
|
+ PLUGIN_DEBUG("Plugin disabled, nothing to do.\n");
|
|
return KRB5_PLUGIN_NO_HANDLE;
|
|
}
|
|
|
|
@@ -468,13 +468,13 @@ krb5_error_code sssd_krb5_locator_lookup(void *private_data,
|
|
free(ctx->sssd_realm);
|
|
ctx->sssd_realm = strdup(realm);
|
|
if (ctx->sssd_realm == NULL) {
|
|
- PLUGIN_DEBUG(("strdup failed.\n"));
|
|
+ PLUGIN_DEBUG("strdup failed.\n");
|
|
return KRB5_PLUGIN_NO_HANDLE;
|
|
}
|
|
|
|
ret = get_krb5info(realm, ctx, locate_service_kdc);
|
|
if (ret != EOK) {
|
|
- PLUGIN_DEBUG(("get_krb5info failed.\n"));
|
|
+ PLUGIN_DEBUG("get_krb5info failed.\n");
|
|
return KRB5_PLUGIN_NO_HANDLE;
|
|
}
|
|
|
|
@@ -482,22 +482,22 @@ krb5_error_code sssd_krb5_locator_lookup(void *private_data,
|
|
svc == locate_service_master_kdc) {
|
|
ret = get_krb5info(realm, ctx, locate_service_kpasswd);
|
|
if (ret != EOK) {
|
|
- PLUGIN_DEBUG(("reading kpasswd address failed, "
|
|
- "using kdc address.\n"));
|
|
+ PLUGIN_DEBUG("reading kpasswd address failed, "
|
|
+ "using kdc address.\n");
|
|
free_addr_port_list(&(ctx->kpasswd_addr));
|
|
ret = copy_addr_port_list(ctx->kdc_addr, true,
|
|
&(ctx->kpasswd_addr));
|
|
if (ret != EOK) {
|
|
- PLUGIN_DEBUG(("copying address list failed.\n"));
|
|
+ PLUGIN_DEBUG("copying address list failed.\n");
|
|
return KRB5_PLUGIN_NO_HANDLE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
- PLUGIN_DEBUG(("sssd_realm[%s] requested realm[%s] family[%d] socktype[%d] "
|
|
- "locate_service[%d]\n", ctx->sssd_realm, realm, family,
|
|
- socktype, svc));
|
|
+ PLUGIN_DEBUG("sssd_realm[%s] requested realm[%s] family[%d] socktype[%d] "
|
|
+ "locate_service[%d]\n",
|
|
+ ctx->sssd_realm, realm, family, socktype, svc);
|
|
|
|
switch (svc) {
|
|
case locate_service_kdc:
|
|
@@ -547,7 +547,7 @@ krb5_error_code sssd_krb5_locator_lookup(void *private_data,
|
|
memset(port_str, 0, PORT_STR_SIZE);
|
|
ret = snprintf(port_str, PORT_STR_SIZE-1, "%u", port);
|
|
if (ret < 0 || ret >= (PORT_STR_SIZE-1)) {
|
|
- PLUGIN_DEBUG(("snprintf failed.\n"));
|
|
+ PLUGIN_DEBUG("snprintf failed.\n");
|
|
return KRB5_PLUGIN_NO_HANDLE;
|
|
}
|
|
|
|
@@ -557,31 +557,31 @@ krb5_error_code sssd_krb5_locator_lookup(void *private_data,
|
|
|
|
ret = getaddrinfo(addr[c].addr, port_str, &ai_hints, &ai);
|
|
if (ret != 0) {
|
|
- PLUGIN_DEBUG(("getaddrinfo failed [%d][%s].\n", ret,
|
|
- gai_strerror(ret)));
|
|
+ PLUGIN_DEBUG("getaddrinfo failed [%d][%s].\n",
|
|
+ ret, gai_strerror(ret));
|
|
if (ret == EAI_SYSTEM) {
|
|
- PLUGIN_DEBUG(("getaddrinfo failed [%d][%s].\n",
|
|
- errno, strerror(errno)));
|
|
+ PLUGIN_DEBUG("getaddrinfo failed [%d][%s].\n",
|
|
+ errno, strerror(errno));
|
|
}
|
|
return KRB5_PLUGIN_NO_HANDLE;
|
|
}
|
|
|
|
- PLUGIN_DEBUG(("addr[%s:%s] family[%d] socktype[%d]\n", addr[c].addr,
|
|
- port_str, ai->ai_family, ai->ai_socktype));
|
|
+ PLUGIN_DEBUG("addr[%s:%s] family[%d] socktype[%d]\n",
|
|
+ addr[c].addr, port_str, ai->ai_family, ai->ai_socktype);
|
|
|
|
if ((family == AF_UNSPEC || ai->ai_family == family) &&
|
|
ai->ai_socktype == socktype) {
|
|
|
|
ret = cbfunc(cbdata, socktype, ai->ai_addr);
|
|
if (ret != 0) {
|
|
- PLUGIN_DEBUG(("cbfunc failed\n"));
|
|
+ PLUGIN_DEBUG("cbfunc failed\n");
|
|
freeaddrinfo(ai);
|
|
return ret;
|
|
} else {
|
|
- PLUGIN_DEBUG(("[%s] used\n", addr[c].addr));
|
|
+ PLUGIN_DEBUG("[%s] used\n", addr[c].addr);
|
|
}
|
|
} else {
|
|
- PLUGIN_DEBUG(("[%s] NOT used\n", addr[c].addr));
|
|
+ PLUGIN_DEBUG("[%s] NOT used\n", addr[c].addr);
|
|
}
|
|
freeaddrinfo(ai);
|
|
}
|
|
--
|
|
2.9.5
|
|
|