[SSSD] [PATCH] Improve nsupdate error logging
Jakub Hrozek
jhrozek at redhat.com
Wed Apr 8 13:01:18 UTC 2015
Hi,
the attached simple patches add more debugging to nsupdate runs and
capture nsupdate stderr to the sssd debug logs. I used them to get more
data in case where nsupdate was failing without more data.
-------------- next part --------------
>From e28e55dfe578322e9c184eeb929f982006cd01e8 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 8 Apr 2015 14:29:05 +0200
Subject: [PATCH 1/3] UTIL: Add a simple function to get the fd of debug_file
---
src/util/debug.c | 9 +++++++++
src/util/util.h | 1 +
2 files changed, 10 insertions(+)
diff --git a/src/util/debug.c b/src/util/debug.c
index 3121c70b17a4c996da143b2ffa449b686b57fab4..bf83624c98769c4c53d9c25522712a9705b26ed2 100644
--- a/src/util/debug.c
+++ b/src/util/debug.c
@@ -70,6 +70,15 @@ errno_t set_debug_file_from_fd(const int fd)
return EOK;
}
+int get_fd_from_debug_file(void)
+{
+ if (debug_file == NULL) {
+ return STDERR_FILENO;
+ }
+
+ return fileno(debug_file);
+}
+
int debug_convert_old_level(int old_level)
{
if ((old_level != 0) && !(old_level & 0x000F))
diff --git a/src/util/util.h b/src/util/util.h
index 704e10dc657b3a9e7b15f24a907ac385fa501431..d831d533f38a9ecae1f24265e3f2869eb6144a8b 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -78,6 +78,7 @@ void debug_fn(const char *file,
const char *format, ...) SSS_ATTRIBUTE_PRINTF(5,6);
int debug_convert_old_level(int old_level);
errno_t set_debug_file_from_fd(const int fd);
+int get_fd_from_debug_file(void);
#define SSS_DOM_ENV "_SSS_DOM"
--
2.1.0
-------------- next part --------------
>From fb5b168b05a2efad72f9aecd992f5bb0a1fc85ec Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 8 Apr 2015 14:31:06 +0200
Subject: [PATCH 2/3] dyndns: Log nsupdate stderr with a high debug level
https://fedorahosted.org/sssd/ticket/2224
---
src/providers/dp_dyndns.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/src/providers/dp_dyndns.c b/src/providers/dp_dyndns.c
index 7db21509d181b1a5f2de0fd603711e7829a5a452..eb69731b513e283467ccd8be16179f231a6b6bad 100644
--- a/src/providers/dp_dyndns.c
+++ b/src/providers/dp_dyndns.c
@@ -925,6 +925,7 @@ struct tevent_req *be_nsupdate_send(TALLOC_CTX *mem_ctx,
struct tevent_req *subreq = NULL;
struct be_nsupdate_state *state;
char **args;
+ int debug_fd;
req = tevent_req_create(mem_ctx, &state, struct be_nsupdate_state);
if (req == NULL) {
@@ -952,6 +953,17 @@ struct tevent_req *be_nsupdate_send(TALLOC_CTX *mem_ctx,
goto done;
}
+ if (debug_level >= SSSDBG_TRACE_LIBS) {
+ debug_fd = get_fd_from_debug_file();
+ ret = dup2(debug_fd, STDERR_FILENO);
+ if (ret == -1) {
+ ret = errno;
+ DEBUG(SSSDBG_MINOR_FAILURE,
+ "dup2 failed [%d][%s].\n", ret, strerror(ret));
+ /* stderr is not fatal */
+ }
+ }
+
args = be_nsupdate_args(state, auth_type, force_tcp);
if (args == NULL) {
ret = ENOMEM;
--
2.1.0
-------------- next part --------------
>From 22b312efb92e1879c5530395e2932743cb5d9bf6 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed, 8 Apr 2015 14:35:26 +0200
Subject: [PATCH 3/3] nsupdate: Append -d/-D to nsupdate with a high debug
level
https://fedorahosted.org/sssd/ticket/897
---
src/providers/dp_dyndns.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/providers/dp_dyndns.c b/src/providers/dp_dyndns.c
index eb69731b513e283467ccd8be16179f231a6b6bad..1cac3d0fae2454cea823ed640a4325f27580353f 100644
--- a/src/providers/dp_dyndns.c
+++ b/src/providers/dp_dyndns.c
@@ -1010,7 +1010,7 @@ be_nsupdate_args(TALLOC_CTX *mem_ctx,
char **argv;
int argc = 0;
- argv = talloc_zero_array(mem_ctx, char *, 4);
+ argv = talloc_zero_array(mem_ctx, char *, 6);
if (argv == NULL) {
return NULL;
}
@@ -1047,6 +1047,22 @@ be_nsupdate_args(TALLOC_CTX *mem_ctx,
argc++;
}
+ if (debug_level >= SSSDBG_TRACE_LIBS) {
+ argv[argc] = talloc_strdup(argv, "-d");
+ if (argv[argc] == NULL) {
+ goto fail;
+ }
+ argc++;
+ }
+
+ if (debug_level >= SSSDBG_TRACE_INTERNAL) {
+ argv[argc] = talloc_strdup(argv, "-D");
+ if (argv[argc] == NULL) {
+ goto fail;
+ }
+ argc++;
+ }
+
return argv;
fail:
--
2.1.0
More information about the sssd-devel
mailing list