summaryrefslogtreecommitdiff
path: root/src/journal/journald.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-22 03:36:29 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-22 03:36:29 +0200
commit3b7124a8db56ed57525b9ecfd19cfdc8c9facba0 (patch)
treee4b64aac9cac7cafb67c3a581a75423b87d696ab /src/journal/journald.c
parenta45b9fca6b91a767dcd9060cfcb30617dad234c7 (diff)
journald: split console transport stuff into its own file
Diffstat (limited to 'src/journal/journald.c')
-rw-r--r--src/journal/journald.c56
1 files changed, 1 insertions, 55 deletions
diff --git a/src/journal/journald.c b/src/journal/journald.c
index cce11f73d..5836119be 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -57,6 +57,7 @@
#include "journald-kmsg.h"
#include "journald-syslog.h"
#include "journald-stream.h"
+#include "journald-console.h"
#ifdef HAVE_ACL
#include <sys/acl.h>
@@ -772,61 +773,6 @@ finish:
dispatch_message_real(s, iovec, n, m, ucred, tv, label, label_len, unit_id);
}
-void server_forward_console(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred) {
- struct iovec iovec[4];
- char header_pid[16];
- int n = 0, fd;
- char *ident_buf = NULL;
- const char *tty;
-
- assert(s);
- assert(message);
-
- if (LOG_PRI(priority) > s->max_level_console)
- return;
-
- /* First: identifier and PID */
- if (ucred) {
- if (!identifier) {
- get_process_comm(ucred->pid, &ident_buf);
- identifier = ident_buf;
- }
-
- snprintf(header_pid, sizeof(header_pid), "[%lu]: ", (unsigned long) ucred->pid);
- char_array_0(header_pid);
-
- if (identifier)
- IOVEC_SET_STRING(iovec[n++], identifier);
-
- IOVEC_SET_STRING(iovec[n++], header_pid);
- } else if (identifier) {
- IOVEC_SET_STRING(iovec[n++], identifier);
- IOVEC_SET_STRING(iovec[n++], ": ");
- }
-
- /* Third: message */
- IOVEC_SET_STRING(iovec[n++], message);
- IOVEC_SET_STRING(iovec[n++], "\n");
-
- tty = s->tty_path ? s->tty_path : "/dev/console";
-
- fd = open_terminal(tty, O_WRONLY|O_NOCTTY|O_CLOEXEC);
- if (fd < 0) {
- log_debug("Failed to open %s for logging: %s", tty, strerror(errno));
- goto finish;
- }
-
- if (writev(fd, iovec, n) < 0)
- log_debug("Failed to write to %s for logging: %s", tty, strerror(errno));
-
- close_nointr_nofail(fd);
-
-finish:
- free(ident_buf);
-}
-
-
-
static bool valid_user_field(const char *p, size_t l) {
const char *a;