diff options
author | Sumit Bose <sbose@redhat.com> | 2009-10-12 15:38:29 +0200 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-10-15 18:10:21 -0400 |
commit | c0dfe79ba578d62a991b0a829d7e0f670a445109 (patch) | |
tree | dc109923822b41d1242a52fc980bf7f0f766b3fd /server/util | |
parent | dc71edea5cda411cdce039777a2ba3b00e19ca27 (diff) | |
download | sssd-c0dfe79ba578d62a991b0a829d7e0f670a445109.tar.gz sssd-c0dfe79ba578d62a991b0a829d7e0f670a445109.tar.bz2 sssd-c0dfe79ba578d62a991b0a829d7e0f670a445109.zip |
enable debugging of krb5_child
Diffstat (limited to 'server/util')
-rw-r--r-- | server/util/debug.c | 40 | ||||
-rw-r--r-- | server/util/util.h | 2 |
2 files changed, 38 insertions, 4 deletions
diff --git a/server/util/debug.c b/server/util/debug.c index c6aa27c9..862367ce 100644 --- a/server/util/debug.c +++ b/server/util/debug.c @@ -37,6 +37,22 @@ int debug_to_file = 0; const char *debug_log_file = "sssd"; FILE *debug_file = NULL; + +errno_t set_debug_file_from_fd(const int fd) +{ + FILE *dummy; + + dummy = fdopen(fd, "a"); + if (dummy == NULL) { + DEBUG(1, ("fdopen failed [%d][%s].\n", errno, strerror(errno))); + return errno; + } + + debug_file = dummy; + + return EOK; +} + void debug_fn(const char *format, ...) { va_list ap; @@ -99,19 +115,26 @@ void ldb_debug_messages(void *context, enum ldb_debug_level level, free(message); } -int open_debug_file() +int open_debug_file_ex(const char *filename, FILE **filep) { FILE *f = NULL; char *logpath; + const char *log_file; mode_t old_umask; int ret; - ret = asprintf(&logpath, "%s/%s.log", LOG_PATH, debug_log_file); + if (filename == NULL) { + log_file = debug_log_file; + } else { + log_file = filename; + } + + ret = asprintf(&logpath, "%s/%s.log", LOG_PATH, log_file); if (ret == -1) { return ENOMEM; } - if (debug_file) fclose(debug_file); + if (debug_file && !filep) fclose(debug_file); old_umask = umask(0177); f = fopen(logpath, "a"); @@ -121,7 +144,16 @@ int open_debug_file() } umask(old_umask); - debug_file = f; + if (filep == NULL) { + debug_file = f; + } else { + *filep = f; + } free(logpath); return EOK; } + +int open_debug_file(void) +{ + return open_debug_file_ex(NULL, NULL); +} diff --git a/server/util/util.h b/server/util/util.h index b7deb854..a9d25532 100644 --- a/server/util/util.h +++ b/server/util/util.h @@ -46,6 +46,7 @@ extern int debug_timestamps; extern int debug_to_file; extern const char *debug_log_file; void debug_fn(const char *format, ...); +errno_t set_debug_file_from_fd(const int fd); #define SSSD_DEBUG_OPTS \ {"debug-level", 'd', POPT_ARG_INT, &debug_level, 0, \ @@ -137,6 +138,7 @@ void debug_fn(const char *format, ...); /* From debug.c */ void ldb_debug_messages(void *context, enum ldb_debug_level level, const char *fmt, va_list ap); +int open_debug_file_ex(const char *filename, FILE **filep); int open_debug_file(void); /* from server.c */ |