diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2011-05-02 13:46:27 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-05-06 10:24:37 -0400 |
commit | d818283d39d56204ffe710b6c9b83a2cf497f946 (patch) | |
tree | 0177903f733ba54c56cfc4fbfefc6c81927d8878 /src/util | |
parent | 28a410f423bf9bcdf43ed14cd4c50634753b51f3 (diff) | |
download | sssd-d818283d39d56204ffe710b6c9b83a2cf497f946.tar.gz sssd-d818283d39d56204ffe710b6c9b83a2cf497f946.tar.xz sssd-d818283d39d56204ffe710b6c9b83a2cf497f946.zip |
Allow changing the log level without restart
We will now re-read the confdb debug_level value when processing
the monitor_common_logrotate() function, which occurs when the
monitor receives a SIGHUP.
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/debug.c | 1 | ||||
-rw-r--r-- | src/util/server.c | 26 |
2 files changed, 24 insertions, 3 deletions
diff --git a/src/util/debug.c b/src/util/debug.c index 129b9d9b1..dbd54c1e9 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -39,7 +39,6 @@ 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; diff --git a/src/util/server.c b/src/util/server.c index 977c75117..e12623738 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -31,6 +31,7 @@ #include "util/util.h" #include "ldb.h" #include "confdb/confdb.h" +#include "monitor/monitor_interfaces.h" #ifdef HAVE_PRCTL #include <sys/prctl.h> @@ -346,6 +347,11 @@ int die_if_parent_died(void) return EOK; } +struct logrotate_ctx { + struct confdb_ctx *confdb; + const char *confdb_path; +}; + static void te_server_hup(struct tevent_context *ev, struct tevent_signal *se, int signum, @@ -353,8 +359,17 @@ static void te_server_hup(struct tevent_context *ev, void *siginfo, void *private_data) { + errno_t ret; + struct logrotate_ctx *lctx = + talloc_get_type(private_data, struct logrotate_ctx); + DEBUG(1, ("Received SIGHUP. Rotating logfiles.\n")); - rotate_debug_files(); + + ret = monitor_common_rotate_logs(lctx->confdb, lctx->confdb_path); + if (ret != EOK) { + DEBUG(0, ("Could not reopen log file [%s]\n", + strerror(ret))); + } } int server_setup(const char *name, int flags, @@ -369,6 +384,7 @@ int server_setup(const char *name, int flags, bool dt; bool dl; struct tevent_signal *tes; + struct logrotate_ctx *lctx; debug_prg_name = strdup(name); if (!debug_prg_name) { @@ -483,8 +499,14 @@ int server_setup(const char *name, int flags, if (dl) debug_to_file = 1; /* before opening the log file set up log rotation */ + lctx = talloc_zero(ctx, struct logrotate_ctx); + if (!lctx) return ENOMEM; + + lctx->confdb = ctx->confdb_ctx; + lctx->confdb_path = conf_entry; + tes = tevent_add_signal(ctx->event_ctx, ctx, SIGHUP, 0, - te_server_hup, NULL); + te_server_hup, lctx); if (tes == NULL) { return EIO; } |