2014-07-23 22:06:11 +02:00
|
|
|
Use and set default logging console for both journald and kernel messages
|
|
|
|
|
|
|
|
---
|
|
|
|
src/journal/journald-console.c | 96 +++++++++++++++++++++++++++++++++++++++++
|
|
|
|
src/journal/journald-console.h | 4 +
|
|
|
|
src/journal/journald-server.c | 5 ++
|
|
|
|
3 files changed, 105 insertions(+)
|
|
|
|
|
2015-03-01 14:49:19 +01:00
|
|
|
--- systemd-219.orig/src/journal/journald-console.c
|
|
|
|
+++ systemd-219/src/journal/journald-console.c
|
2014-07-23 22:06:11 +02:00
|
|
|
@@ -23,6 +23,14 @@
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
+#ifdef HAVE_SYSV_COMPAT
|
|
|
|
+# include <linux/tiocl.h>
|
|
|
|
+# include <linux/vt.h>
|
|
|
|
+# include <sys/ioctl.h>
|
|
|
|
+# include <sys/klog.h>
|
|
|
|
+# include <errno.h>
|
|
|
|
+# include "util.h"
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
#include "fileio.h"
|
|
|
|
#include "journald-server.h"
|
2015-03-01 14:49:19 +01:00
|
|
|
@@ -43,6 +51,76 @@ static bool prefix_timestamp(void) {
|
2014-07-23 22:06:11 +02:00
|
|
|
return cached_printk_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
+void defaul_tty_path(Server *s)
|
|
|
|
+{
|
2015-03-01 14:49:19 +01:00
|
|
|
+#ifdef HAVE_SYSV_COMPAT
|
2014-07-23 22:06:11 +02:00
|
|
|
+ static const char list[] = "/dev/tty10\0" "/dev/console\0";
|
|
|
|
+ const char *vc;
|
|
|
|
+
|
|
|
|
+ if (s->tty_path)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ NULSTR_FOREACH(vc, list) {
|
|
|
|
+ _cleanup_close_ int fd = -1;
|
|
|
|
+
|
|
|
|
+ if (access(vc, F_OK) < 0)
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ fd = open_terminal(vc, O_WRONLY|O_NOCTTY|O_CLOEXEC);
|
|
|
|
+ if (fd < 0)
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ s->tty_path = strdup(vc);
|
|
|
|
+ break;
|
|
|
|
+ }
|
2015-03-01 14:49:19 +01:00
|
|
|
+#endif
|
2014-07-23 22:06:11 +02:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void klogconsole(Server *s)
|
|
|
|
+{
|
2015-03-01 14:49:19 +01:00
|
|
|
+#ifdef HAVE_SYSV_COMPAT
|
2014-07-23 22:06:11 +02:00
|
|
|
+ _cleanup_free_ char *klogconsole_params = NULL;
|
|
|
|
+ _cleanup_close_ int fd = -1;
|
|
|
|
+ const char *vc = s->tty_path;
|
|
|
|
+ const char *num;
|
|
|
|
+ int tiocl[2];
|
|
|
|
+ int r;
|
|
|
|
+
|
|
|
|
+ if (!vc || *vc == 0 || !strneq("/dev/tty", vc, 8))
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ num = vc + strcspn(vc, "0123456789");
|
|
|
|
+ if (safe_atoi(num, &r) < 0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ if (access(vc, F_OK) < 0)
|
Accepting request 242359 from Base:System
- Disable blkrrpart for SLES12 and below
- Add upstream patch
1054-udev-exclude-MD-from-block-device-ownership-event-lo.patch
- Add with condition blkrrpart to be able to disable the patches
1025, 1027, 1029, 1030, 1031, 1032, 1033, 1034, 1037, and 1054
which uses the BLKRRPART ioctl for e.g. synthesize change events
which may interfere with other tools like parted.
- Update
handle-disable_caplock-and-compose_table-and-kbd_rate.patch,
handle-numlock-value-in-etc-sysconfig-keyboard.patch: read
/etc/vconsole.conf after /etc/sysconfig/(keyboard,console)
otherwise empty value in /etc/sysconfig/keyboard might override
/etc/vconsole.conf values.
- Update :
0001-journal-compress-return-early-in-uncompress_startswi.patch
0002-util-don-t-consider-tabs-special-in-string_has_cc-an.patch
0002-vconsole-setup-run-setfont-before-loadkeys.patch
0003-core-never-consider-failure-when-reading-drop-ins-fa.patch
0003-fsck-consider-a-fsck-implementation-linked-to-bin-tr.patch
apply-ACL-for-nvidia-device-nodes.patch
keep-crypt-password-prompt.patch
log-target-null-instead-kmsg.patch
parse-crypttab-for-noauto-option.patch
set-and-use-default-logconsole.patch: fix all warnings in code
- Remove 0001-compress-fix-return-value.patch: not relevant to
systemd v210 code.
- Also change udev-generate-peristent-rule to udev-generate-persistent-rule
OBS-URL: https://build.opensuse.org/request/show/242359
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=195
2014-07-26 12:19:44 +02:00
|
|
|
+ return;
|
2014-07-23 22:06:11 +02:00
|
|
|
+
|
|
|
|
+ fd = open_terminal(vc, O_RDWR|O_NOCTTY|O_CLOEXEC);
|
|
|
|
+ if (fd < 0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ tiocl[0] = TIOCL_SETKMSGREDIRECT;
|
|
|
|
+ tiocl[1] = r;
|
|
|
|
+
|
|
|
|
+ if (ioctl(fd, TIOCLINUX, tiocl) < 0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ zero(klogconsole_params);
|
|
|
|
+ r = parse_env_file("/etc/sysconfig/boot", NEWLINE,
|
|
|
|
+ "KLOGCONSOLE_PARAMS", &klogconsole_params,
|
|
|
|
+ NULL);
|
|
|
|
+ if (r < 0)
|
|
|
|
+ return;
|
|
|
|
+ if (!klogconsole_params || *klogconsole_params == 0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ num = klogconsole_params + strcspn(klogconsole_params, "0123456789");
|
|
|
|
+ if (safe_atoi(num, &r) == 0)
|
|
|
|
+ klogctl(8, 0, r);
|
|
|
|
+#endif
|
2015-03-01 14:49:19 +01:00
|
|
|
+}
|
2014-07-23 22:06:11 +02:00
|
|
|
+
|
|
|
|
void server_forward_console(
|
|
|
|
Server *s,
|
|
|
|
int priority,
|
2015-03-01 14:49:19 +01:00
|
|
|
@@ -64,6 +142,12 @@ void server_forward_console(
|
2014-07-23 22:06:11 +02:00
|
|
|
if (LOG_PRI(priority) > s->max_level_console)
|
|
|
|
return;
|
Accepting request 242359 from Base:System
- Disable blkrrpart for SLES12 and below
- Add upstream patch
1054-udev-exclude-MD-from-block-device-ownership-event-lo.patch
- Add with condition blkrrpart to be able to disable the patches
1025, 1027, 1029, 1030, 1031, 1032, 1033, 1034, 1037, and 1054
which uses the BLKRRPART ioctl for e.g. synthesize change events
which may interfere with other tools like parted.
- Update
handle-disable_caplock-and-compose_table-and-kbd_rate.patch,
handle-numlock-value-in-etc-sysconfig-keyboard.patch: read
/etc/vconsole.conf after /etc/sysconfig/(keyboard,console)
otherwise empty value in /etc/sysconfig/keyboard might override
/etc/vconsole.conf values.
- Update :
0001-journal-compress-return-early-in-uncompress_startswi.patch
0002-util-don-t-consider-tabs-special-in-string_has_cc-an.patch
0002-vconsole-setup-run-setfont-before-loadkeys.patch
0003-core-never-consider-failure-when-reading-drop-ins-fa.patch
0003-fsck-consider-a-fsck-implementation-linked-to-bin-tr.patch
apply-ACL-for-nvidia-device-nodes.patch
keep-crypt-password-prompt.patch
log-target-null-instead-kmsg.patch
parse-crypttab-for-noauto-option.patch
set-and-use-default-logconsole.patch: fix all warnings in code
- Remove 0001-compress-fix-return-value.patch: not relevant to
systemd v210 code.
- Also change udev-generate-peristent-rule to udev-generate-persistent-rule
OBS-URL: https://build.opensuse.org/request/show/242359
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=195
2014-07-26 12:19:44 +02:00
|
|
|
|
2015-03-01 14:49:19 +01:00
|
|
|
+#ifdef HAVE_SYSV_COMPAT
|
2014-07-23 22:06:11 +02:00
|
|
|
+ /* Do not write security/authorization (private) messages to console */
|
2015-01-21 21:53:05 +01:00
|
|
|
+ if ((priority & LOG_FACMASK) == LOG_AUTHPRIV)
|
2014-07-23 22:06:11 +02:00
|
|
|
+ return;
|
2015-03-01 14:49:19 +01:00
|
|
|
+#endif
|
Accepting request 242359 from Base:System
- Disable blkrrpart for SLES12 and below
- Add upstream patch
1054-udev-exclude-MD-from-block-device-ownership-event-lo.patch
- Add with condition blkrrpart to be able to disable the patches
1025, 1027, 1029, 1030, 1031, 1032, 1033, 1034, 1037, and 1054
which uses the BLKRRPART ioctl for e.g. synthesize change events
which may interfere with other tools like parted.
- Update
handle-disable_caplock-and-compose_table-and-kbd_rate.patch,
handle-numlock-value-in-etc-sysconfig-keyboard.patch: read
/etc/vconsole.conf after /etc/sysconfig/(keyboard,console)
otherwise empty value in /etc/sysconfig/keyboard might override
/etc/vconsole.conf values.
- Update :
0001-journal-compress-return-early-in-uncompress_startswi.patch
0002-util-don-t-consider-tabs-special-in-string_has_cc-an.patch
0002-vconsole-setup-run-setfont-before-loadkeys.patch
0003-core-never-consider-failure-when-reading-drop-ins-fa.patch
0003-fsck-consider-a-fsck-implementation-linked-to-bin-tr.patch
apply-ACL-for-nvidia-device-nodes.patch
keep-crypt-password-prompt.patch
log-target-null-instead-kmsg.patch
parse-crypttab-for-noauto-option.patch
set-and-use-default-logconsole.patch: fix all warnings in code
- Remove 0001-compress-fix-return-value.patch: not relevant to
systemd v210 code.
- Also change udev-generate-peristent-rule to udev-generate-persistent-rule
OBS-URL: https://build.opensuse.org/request/show/242359
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=195
2014-07-26 12:19:44 +02:00
|
|
|
+
|
2014-07-23 22:06:11 +02:00
|
|
|
/* First: timestamp */
|
|
|
|
if (prefix_timestamp()) {
|
Accepting request 242359 from Base:System
- Disable blkrrpart for SLES12 and below
- Add upstream patch
1054-udev-exclude-MD-from-block-device-ownership-event-lo.patch
- Add with condition blkrrpart to be able to disable the patches
1025, 1027, 1029, 1030, 1031, 1032, 1033, 1034, 1037, and 1054
which uses the BLKRRPART ioctl for e.g. synthesize change events
which may interfere with other tools like parted.
- Update
handle-disable_caplock-and-compose_table-and-kbd_rate.patch,
handle-numlock-value-in-etc-sysconfig-keyboard.patch: read
/etc/vconsole.conf after /etc/sysconfig/(keyboard,console)
otherwise empty value in /etc/sysconfig/keyboard might override
/etc/vconsole.conf values.
- Update :
0001-journal-compress-return-early-in-uncompress_startswi.patch
0002-util-don-t-consider-tabs-special-in-string_has_cc-an.patch
0002-vconsole-setup-run-setfont-before-loadkeys.patch
0003-core-never-consider-failure-when-reading-drop-ins-fa.patch
0003-fsck-consider-a-fsck-implementation-linked-to-bin-tr.patch
apply-ACL-for-nvidia-device-nodes.patch
keep-crypt-password-prompt.patch
log-target-null-instead-kmsg.patch
parse-crypttab-for-noauto-option.patch
set-and-use-default-logconsole.patch: fix all warnings in code
- Remove 0001-compress-fix-return-value.patch: not relevant to
systemd v210 code.
- Also change udev-generate-peristent-rule to udev-generate-persistent-rule
OBS-URL: https://build.opensuse.org/request/show/242359
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=195
2014-07-26 12:19:44 +02:00
|
|
|
assert_se(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
|
2015-03-01 14:49:19 +01:00
|
|
|
@@ -100,7 +184,23 @@ void server_forward_console(
|
2014-07-23 22:06:11 +02:00
|
|
|
fd = open_terminal(tty, O_WRONLY|O_NOCTTY|O_CLOEXEC);
|
|
|
|
if (fd < 0) {
|
2015-03-01 14:49:19 +01:00
|
|
|
log_debug_errno(errno, "Failed to open %s for logging: %m", tty);
|
2014-07-23 22:06:11 +02:00
|
|
|
+#ifdef HAVE_SYSV_COMPAT
|
|
|
|
+ if (fd != -ENOENT && fd != -ENODEV)
|
|
|
|
+ return;
|
|
|
|
+ if (tty != s->tty_path)
|
|
|
|
+ return;
|
|
|
|
+ if (!streq("/dev/console", tty)) {
|
|
|
|
+ if (s->tty_path)
|
|
|
|
+ free(s->tty_path);
|
|
|
|
+ s->tty_path = NULL;
|
|
|
|
+ tty = "/dev/console";
|
|
|
|
+ fd = open_terminal(tty, O_WRONLY|O_NOCTTY|O_CLOEXEC);
|
|
|
|
+ if (fd < 0)
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+#else
|
|
|
|
return;
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (writev(fd, iovec, n) < 0)
|
2015-03-01 14:49:19 +01:00
|
|
|
--- systemd-219.orig/src/journal/journald-console.h
|
|
|
|
+++ systemd-219/src/journal/journald-console.h
|
|
|
|
@@ -24,3 +24,6 @@
|
2014-07-23 22:06:11 +02:00
|
|
|
#include "journald-server.h"
|
|
|
|
|
2015-03-01 14:49:19 +01:00
|
|
|
void server_forward_console(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred);
|
|
|
|
+
|
2014-07-23 22:06:11 +02:00
|
|
|
+void klogconsole(Server *s);
|
|
|
|
+void defaul_tty_path(Server *s);
|
2015-03-01 14:49:19 +01:00
|
|
|
--- systemd-219.orig/src/journal/journald-server.c
|
|
|
|
+++ systemd-219/src/journal/journald-server.c
|
|
|
|
@@ -1520,6 +1520,11 @@ int server_init(Server *s) {
|
2014-07-23 22:06:11 +02:00
|
|
|
|
|
|
|
server_parse_config_file(s);
|
|
|
|
server_parse_proc_cmdline(s);
|
|
|
|
+ defaul_tty_path(s);
|
|
|
|
+
|
|
|
|
+ if (s->tty_path)
|
|
|
|
+ klogconsole(s);
|
|
|
|
+
|
|
|
|
if (!!s->rate_limit_interval ^ !!s->rate_limit_burst) {
|
2015-03-01 14:49:19 +01:00
|
|
|
log_debug("Setting both rate limit interval and burst from "USEC_FMT",%u to 0,0",
|
|
|
|
s->rate_limit_interval, s->rate_limit_burst);
|