summaryrefslogtreecommitdiff
path: root/src/manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-03-18 04:31:22 +0100
committerLennart Poettering <lennart@poettering.net>2011-03-18 04:53:31 +0100
commitf1dd0c3f9b4a257e81ff9c6a08070c702a0db45a (patch)
tree34ae8bb9ab04facd195a83a6300306edac96479e /src/manager.c
parent0732ec002ea941f32e8def518150d2b6423315e3 (diff)
syslog: rework syslog detection so that we need no compile-time option what the name of the syslog implementation is
Diffstat (limited to 'src/manager.c')
-rw-r--r--src/manager.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/manager.c b/src/manager.c
index 9edb8f09bb..a9aaee3d81 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -2451,6 +2451,12 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) {
if (m->n_deserializing > 0)
return;
+ if (m->running_as != MANAGER_SYSTEM)
+ return;
+
+ if (u->meta.type != UNIT_SERVICE)
+ return;
+
if (!(p = unit_name_to_prefix_and_instance(u->meta.id))) {
log_error("Failed to allocate unit name for audit message: %s", strerror(ENOMEM));
return;
@@ -2965,6 +2971,47 @@ int manager_set_default_controllers(Manager *m, char **controllers) {
return 0;
}
+void manager_recheck_syslog(Manager *m) {
+ Unit *u;
+
+ assert(m);
+
+ if (m->running_as != MANAGER_SYSTEM)
+ return;
+
+ if ((u = manager_get_unit(m, SPECIAL_SYSLOG_SOCKET))) {
+ SocketState state;
+
+ state = SOCKET(u)->state;
+
+ if (state != SOCKET_DEAD &&
+ state != SOCKET_FAILED &&
+ state != SOCKET_RUNNING) {
+
+ /* Hmm, the socket is not set up, or is still
+ * listening, let's better not try to use
+ * it. Note that we have no problem if the
+ * socket is completely down, since there
+ * might be a foreign /dev/log socket around
+ * and we want to make use of that.
+ */
+
+ log_close_syslog();
+ return;
+ }
+ }
+
+ if ((u = manager_get_unit(m, SPECIAL_SYSLOG_TARGET)))
+ if (TARGET(u)->state != TARGET_ACTIVE) {
+ log_close_syslog();
+ return;
+ }
+
+ /* Hmm, OK, so the socket is either fully up, or fully down,
+ * and the target is up, then let's make use of the socket */
+ log_open();
+}
+
static const char* const manager_running_as_table[_MANAGER_RUNNING_AS_MAX] = {
[MANAGER_SYSTEM] = "system",
[MANAGER_USER] = "user"