summaryrefslogtreecommitdiffstats
path: root/src/util/child_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/child_common.c')
-rw-r--r--src/util/child_common.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/util/child_common.c b/src/util/child_common.c
index e4a885b6e..cc6a8fa75 100644
--- a/src/util/child_common.c
+++ b/src/util/child_common.c
@@ -801,3 +801,32 @@ int child_io_destructor(void *ptr)
return EOK;
}
+
+errno_t child_debug_init(const char *logfile, int *debug_fd)
+{
+ int ret;
+ FILE *debug_filep;
+
+ if (debug_fd == NULL) {
+ return EOK;
+ }
+
+ if (debug_to_file != 0 && *debug_fd == -1) {
+ ret = open_debug_file_ex(logfile, &debug_filep, false);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_FATAL_FAILURE, "Error setting up logging (%d) [%s]\n",
+ ret, sss_strerror(ret));
+ return ret;
+ }
+
+ *debug_fd = fileno(debug_filep);
+ if (*debug_fd == -1) {
+ DEBUG(SSSDBG_FATAL_FAILURE,
+ "fileno failed [%d][%s]\n", errno, strerror(errno));
+ ret = errno;
+ return ret;
+ }
+ }
+
+ return EOK;
+}