summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/monitor/monitor.c4
-rw-r--r--src/monitor/monitor_interfaces.h6
-rw-r--r--src/monitor/monitor_sbus.c25
-rw-r--r--src/providers/data_provider_be.c25
-rw-r--r--src/responder/common/responder.h3
-rw-r--r--src/responder/common/responder_common.c12
-rw-r--r--src/responder/nss/nsssrv.c2
-rw-r--r--src/responder/pam/pamsrv.c2
-rw-r--r--src/util/debug.c1
-rw-r--r--src/util/server.c26
10 files changed, 89 insertions, 17 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 194e74c5d..baa9994e4 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -122,6 +122,7 @@ struct mt_ctx {
bool check_children;
bool services_started;
struct netlink_ctx *nlctx;
+ const char *conf_path;
};
static int start_service(struct mt_svc *mt_svc);
@@ -2372,7 +2373,8 @@ int main(int argc, const char *argv[])
}
/* set up things like debug , signals, daemonization, etc... */
- ret = server_setup("sssd", flags, CONFDB_MONITOR_CONF_ENTRY, &main_ctx);
+ monitor->conf_path = CONFDB_MONITOR_CONF_ENTRY;
+ ret = server_setup("sssd", flags, monitor->conf_path, &main_ctx);
if (ret != EOK) return 2;
monitor->ev = main_ctx->event_ctx;
diff --git a/src/monitor/monitor_interfaces.h b/src/monitor/monitor_interfaces.h
index 8ec6d89bd..51ac254cd 100644
--- a/src/monitor/monitor_interfaces.h
+++ b/src/monitor/monitor_interfaces.h
@@ -19,6 +19,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "sbus/sssd_dbus.h"
+
/*** Monitor ***/
#define MONITOR_VERSION 0x0001
@@ -53,8 +55,8 @@ int monitor_common_pong(DBusMessage *message,
struct sbus_connection *conn);
int monitor_common_res_init(DBusMessage *message,
struct sbus_connection *conn);
-int monitor_common_rotate_logs(DBusMessage *message,
- struct sbus_connection *conn);
+int monitor_common_rotate_logs(struct confdb_ctx *confdb,
+ const char *conf_entry);
errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
diff --git a/src/monitor/monitor_sbus.c b/src/monitor/monitor_sbus.c
index 3d0d9d310..632de496f 100644
--- a/src/monitor/monitor_sbus.c
+++ b/src/monitor/monitor_sbus.c
@@ -178,10 +178,11 @@ int monitor_common_res_init(DBusMessage *message,
return monitor_common_pong(message, conn);
}
-int monitor_common_rotate_logs(DBusMessage *message,
- struct sbus_connection *conn)
+errno_t monitor_common_rotate_logs(struct confdb_ctx *confdb,
+ const char *conf_path)
{
- int ret;
+ errno_t ret;
+ int old_debug_level = debug_level;
ret = rotate_debug_files();
if (ret) {
@@ -190,7 +191,23 @@ int monitor_common_rotate_logs(DBusMessage *message,
return ret;
}
- return monitor_common_pong(message, conn);
+ /* Get new debug level from the confdb */
+ ret = confdb_get_int(confdb, NULL, conf_path,
+ CONFDB_SERVICE_DEBUG_LEVEL,
+ old_debug_level,
+ &debug_level);
+ if (ret != EOK) {
+ DEBUG(0, ("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(0, ("Debug level changed to %d\n", debug_level));
+ }
+
+ return EOK;
}
errno_t sss_monitor_init(TALLOC_CTX *mem_ctx,
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
index 0fbf809e5..380e6cdb1 100644
--- a/src/providers/data_provider_be.c
+++ b/src/providers/data_provider_be.c
@@ -57,13 +57,15 @@ static int data_provider_go_offline(DBusMessage *message,
struct sbus_connection *conn);
static int data_provider_reset_offline(DBusMessage *message,
struct sbus_connection *conn);
+static int data_provider_logrotate(DBusMessage *message,
+ struct sbus_connection *conn);
struct sbus_method monitor_be_methods[] = {
{ MON_CLI_METHOD_PING, monitor_common_pong },
{ MON_CLI_METHOD_RES_INIT, data_provider_res_init },
{ MON_CLI_METHOD_OFFLINE, data_provider_go_offline },
{ MON_CLI_METHOD_RESET_OFFLINE, data_provider_reset_offline },
- { MON_CLI_METHOD_ROTATE, monitor_common_rotate_logs },
+ { MON_CLI_METHOD_ROTATE, data_provider_logrotate },
{ NULL, NULL }
};
@@ -1183,8 +1185,8 @@ int main(int argc, const char *argv[])
poptContext pc;
char *be_domain = NULL;
char *srv_name = NULL;
- char *conf_entry = NULL;
struct main_context *main_ctx;
+ char *confdb_path;
int ret;
struct poptOption long_options[] = {
@@ -1222,10 +1224,10 @@ int main(int argc, const char *argv[])
srv_name = talloc_asprintf(NULL, "sssd[be[%s]]", be_domain);
if (!srv_name) return 2;
- conf_entry = talloc_asprintf(NULL, CONFDB_DOMAIN_PATH_TMPL, be_domain);
- if (!conf_entry) return 2;
+ confdb_path = talloc_asprintf(NULL, CONFDB_DOMAIN_PATH_TMPL, be_domain);
+ if (!confdb_path) return 2;
- ret = server_setup(srv_name, 0, conf_entry, &main_ctx);
+ ret = server_setup(srv_name, 0, confdb_path, &main_ctx);
if (ret != EOK) {
DEBUG(0, ("Could not set up mainloop [%d]\n", ret));
return 2;
@@ -1283,3 +1285,16 @@ static int data_provider_reset_offline(DBusMessage *message,
check_if_online(be_ctx);
return monitor_common_pong(message, conn);
}
+
+static int data_provider_logrotate(DBusMessage *message,
+ struct sbus_connection *conn)
+{
+ errno_t ret;
+ struct be_ctx *be_ctx = talloc_get_type(sbus_conn_get_private_data(conn),
+ struct be_ctx);
+
+ ret = monitor_common_rotate_logs(be_ctx->cdb, be_ctx->conf_path);
+ if (ret != EOK) return ret;
+
+ return monitor_common_pong(message, conn);
+}
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h
index 6b81aadac..321cedda8 100644
--- a/src/responder/common/responder.h
+++ b/src/responder/common/responder.h
@@ -171,4 +171,7 @@ int sss_dp_send_acct_req(struct resp_ctx *rctx, TALLOC_CTX *callback_memctx,
bool fast_reply, int type,
const char *opt_name, uint32_t opt_id);
+int responder_logrotate(DBusMessage *message,
+ struct sbus_connection *conn);
+
#endif /* __SSS_RESPONDER_H__ */
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
index 4ddb549c1..37761ae9a 100644
--- a/src/responder/common/responder_common.c
+++ b/src/responder/common/responder_common.c
@@ -652,3 +652,15 @@ int sss_dp_get_domain_conn(struct resp_ctx *rctx, const char *domain,
return EOK;
}
+int responder_logrotate(DBusMessage *message,
+ struct sbus_connection *conn)
+{
+ errno_t ret;
+ struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(conn),
+ struct resp_ctx);
+
+ ret = monitor_common_rotate_logs(rctx->cdb, rctx->confdb_service_path);
+ if (ret != EOK) return ret;
+
+ return monitor_common_pong(message, conn);
+}
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c
index 95a1549f4..9ae6f05e1 100644
--- a/src/responder/nss/nsssrv.c
+++ b/src/responder/nss/nsssrv.c
@@ -51,7 +51,7 @@
struct sbus_method monitor_nss_methods[] = {
{ MON_CLI_METHOD_PING, monitor_common_pong },
{ MON_CLI_METHOD_RES_INIT, monitor_common_res_init },
- { MON_CLI_METHOD_ROTATE, monitor_common_rotate_logs },
+ { MON_CLI_METHOD_ROTATE, responder_logrotate },
{ NULL, NULL }
};
diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c
index 91ee4a899..86283eaec 100644
--- a/src/responder/pam/pamsrv.c
+++ b/src/responder/pam/pamsrv.c
@@ -50,7 +50,7 @@
struct sbus_method monitor_pam_methods[] = {
{ MON_CLI_METHOD_PING, monitor_common_pong },
{ MON_CLI_METHOD_RES_INIT, monitor_common_res_init },
- { MON_CLI_METHOD_ROTATE, monitor_common_rotate_logs },
+ { MON_CLI_METHOD_ROTATE, responder_logrotate },
{ NULL, NULL }
};
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;
}