diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2014-09-21 13:42:29 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-10-09 17:18:17 +0200 |
commit | 1925ce32f7c1dc226be31d4301a0a1dbb2448baa (patch) | |
tree | bf04e6090f6a19ff562e97d93544d488cf36ccf2 /src/util | |
parent | 25072dd5274f07255cdc930f6257c4cbf74692de (diff) | |
download | sssd-1925ce32f7c1dc226be31d4301a0a1dbb2448baa.tar.gz sssd-1925ce32f7c1dc226be31d4301a0a1dbb2448baa.tar.xz sssd-1925ce32f7c1dc226be31d4301a0a1dbb2448baa.zip |
UTIL: Do not depend on monitor code
Just moves code around. There should be a way to use the server.c module
without linking the monitor code.
Reviewed-by: Pavel Reichl <preichl@redhat.com>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/server.c | 36 | ||||
-rw-r--r-- | src/util/util.h | 2 |
2 files changed, 37 insertions, 1 deletions
diff --git a/src/util/server.c b/src/util/server.c index d00db3108..51934f8ba 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -370,13 +370,47 @@ static void te_server_hup(struct tevent_context *ev, DEBUG(SSSDBG_CRIT_FAILURE, "Received SIGHUP. Rotating logfiles.\n"); - ret = monitor_common_rotate_logs(lctx->confdb, lctx->confdb_path); + ret = server_common_rotate_logs(lctx->confdb, lctx->confdb_path); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, "Could not reopen log file [%s]\n", strerror(ret)); } } +errno_t server_common_rotate_logs(struct confdb_ctx *confdb, + const char *conf_path) +{ + errno_t ret; + int old_debug_level = debug_level; + + ret = rotate_debug_files(); + if (ret) { + sss_log(SSS_LOG_ALERT, "Could not rotate debug files! [%d][%s]\n", + ret, strerror(ret)); + return ret; + } + + /* Get new debug level from the confdb */ + ret = confdb_get_int(confdb, conf_path, + CONFDB_SERVICE_DEBUG_LEVEL, + old_debug_level, + &debug_level); + if (ret != EOK) { + DEBUG(SSSDBG_FATAL_FAILURE, "Error reading from confdb (%d) [%s]\n", + ret, strerror(ret)); + /* Try to proceed with the old value */ + debug_level = old_debug_level; + } + + if (debug_level != old_debug_level) { + DEBUG(SSSDBG_FATAL_FAILURE, + "Debug level changed to %#.4x\n", debug_level); + debug_level = debug_convert_old_level(debug_level); + } + + return EOK; +} + int server_setup(const char *name, int flags, const char *conf_entry, struct main_context **main_ctx) diff --git a/src/util/util.h b/src/util/util.h index df82b3fa4..482a660e7 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -237,6 +237,8 @@ struct main_context { pid_t parent_pid; }; +errno_t server_common_rotate_logs(struct confdb_ctx *confdb, + const char *conf_entry); int die_if_parent_died(void); int pidfile(const char *path, const char *name); int server_setup(const char *name, int flags, |