forked from pool/systemd
.
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=724
This commit is contained in:
parent
d319cc9c90
commit
cac73ff3da
149
set-and-use-default-logconsole.patch
Normal file
149
set-and-use-default-logconsole.patch
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
Use and set default logging console for both journald and kernel messages
|
||||||
|
|
||||||
|
---
|
||||||
|
src/journal/journald-console.c | 92 +++++++++++++++++++++++++++++++++++++++++
|
||||||
|
src/journal/journald-console.h | 4 +
|
||||||
|
src/journal/journald-server.c | 5 ++
|
||||||
|
src/journal/journald.conf | 2
|
||||||
|
4 files changed, 102 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
--- src/journal/journald-console.c
|
||||||
|
+++ src/journal/journald-console.c 2014-07-22 11:22:49.574235948 +0000
|
||||||
|
@@ -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"
|
||||||
|
@@ -43,6 +51,74 @@ static bool prefix_timestamp(void) {
|
||||||
|
return cached_printk_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
+#ifdef HAVE_SYSV_COMPAT
|
||||||
|
+void defaul_tty_path(Server *s)
|
||||||
|
+{
|
||||||
|
+ 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;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void klogconsole(Server *s)
|
||||||
|
+{
|
||||||
|
+ _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)
|
||||||
|
+ return false;
|
||||||
|
+
|
||||||
|
+ 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
|
||||||
|
+
|
||||||
|
void server_forward_console(
|
||||||
|
Server *s,
|
||||||
|
int priority,
|
||||||
|
@@ -101,7 +177,23 @@ void server_forward_console(
|
||||||
|
fd = open_terminal(tty, O_WRONLY|O_NOCTTY|O_CLOEXEC);
|
||||||
|
if (fd < 0) {
|
||||||
|
log_debug("Failed to open %s for logging: %m", tty);
|
||||||
|
+#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)
|
||||||
|
--- src/journal/journald-console.h
|
||||||
|
+++ src/journal/journald-console.h 2014-07-22 11:20:52.754235644 +0000
|
||||||
|
@@ -24,3 +24,7 @@
|
||||||
|
#include "journald-server.h"
|
||||||
|
|
||||||
|
void server_forward_console(Server *s, int priority, const char *identifier, const char *message, struct ucred *ucred);
|
||||||
|
+#ifdef HAVE_SYSV_COMPAT
|
||||||
|
+void klogconsole(Server *s);
|
||||||
|
+void defaul_tty_path(Server *s);
|
||||||
|
+#endif
|
||||||
|
--- src/journal/journald-server.c
|
||||||
|
+++ src/journal/journald-server.c 2014-07-22 11:16:45.966236859 +0000
|
||||||
|
@@ -1509,6 +1509,11 @@ int server_init(Server *s) {
|
||||||
|
|
||||||
|
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) {
|
||||||
|
log_debug("Setting both rate limit interval and burst from %llu,%u to 0,0",
|
||||||
|
(long long unsigned) s->rate_limit_interval,
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jul 22 11:50:44 UTC 2014 - werner@suse.de
|
||||||
|
|
||||||
|
- Add patch set-and-use-default-logconsole.patch to use and set
|
||||||
|
the default logging console for both journald and kernel messages
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Jul 21 13:22:35 UTC 2014 - werner@suse.de
|
Mon Jul 21 13:22:35 UTC 2014 - werner@suse.de
|
||||||
|
|
||||||
|
@ -722,6 +722,8 @@ Patch349: 0001-bash-completion-p-option-for-journalctl.patch
|
|||||||
Patch350: 0002-journalctl-man-allow-only-between-terms.patch
|
Patch350: 0002-journalctl-man-allow-only-between-terms.patch
|
||||||
# PATCH-FIX-UPSTREAM added at 2014/07/21
|
# PATCH-FIX-UPSTREAM added at 2014/07/21
|
||||||
Patch351: 0003-systemd-use-pager-for-test-and-help.patch
|
Patch351: 0003-systemd-use-pager-for-test-and-help.patch
|
||||||
|
# PATCH-FIX-SUSE
|
||||||
|
Patch352: set-and-use-default-logconsole.patch
|
||||||
|
|
||||||
# UDEV PATCHES
|
# UDEV PATCHES
|
||||||
# ============
|
# ============
|
||||||
@ -1343,6 +1345,7 @@ cp %{SOURCE7} m4/
|
|||||||
%patch349 -p0
|
%patch349 -p0
|
||||||
%patch350 -p0
|
%patch350 -p0
|
||||||
%patch351 -p0
|
%patch351 -p0
|
||||||
|
%patch352 -p0
|
||||||
|
|
||||||
# udev patches
|
# udev patches
|
||||||
%patch1001 -p1
|
%patch1001 -p1
|
||||||
@ -1431,6 +1434,14 @@ do
|
|||||||
done
|
done
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# In combination with Patch352 set-and-use-default-logconsole.patch
|
||||||
|
# Ensure that journald log on tty10
|
||||||
|
#
|
||||||
|
%ifarch %ix86 x86_64 x32
|
||||||
|
sed -ri 's:#TTYPath=/dev/console:#TTYPath=/dev/tty10:' src/journal/journald.conf
|
||||||
|
%endif
|
||||||
|
|
||||||
%build
|
%build
|
||||||
cflags ()
|
cflags ()
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jul 22 11:50:44 UTC 2014 - werner@suse.de
|
||||||
|
|
||||||
|
- Add patch set-and-use-default-logconsole.patch to use and set
|
||||||
|
the default logging console for both journald and kernel messages
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Jul 21 13:22:35 UTC 2014 - werner@suse.de
|
Mon Jul 21 13:22:35 UTC 2014 - werner@suse.de
|
||||||
|
|
||||||
|
11
systemd.spec
11
systemd.spec
@ -717,6 +717,8 @@ Patch349: 0001-bash-completion-p-option-for-journalctl.patch
|
|||||||
Patch350: 0002-journalctl-man-allow-only-between-terms.patch
|
Patch350: 0002-journalctl-man-allow-only-between-terms.patch
|
||||||
# PATCH-FIX-UPSTREAM added at 2014/07/21
|
# PATCH-FIX-UPSTREAM added at 2014/07/21
|
||||||
Patch351: 0003-systemd-use-pager-for-test-and-help.patch
|
Patch351: 0003-systemd-use-pager-for-test-and-help.patch
|
||||||
|
# PATCH-FIX-SUSE
|
||||||
|
Patch352: set-and-use-default-logconsole.patch
|
||||||
|
|
||||||
# UDEV PATCHES
|
# UDEV PATCHES
|
||||||
# ============
|
# ============
|
||||||
@ -1338,6 +1340,7 @@ cp %{SOURCE7} m4/
|
|||||||
%patch349 -p0
|
%patch349 -p0
|
||||||
%patch350 -p0
|
%patch350 -p0
|
||||||
%patch351 -p0
|
%patch351 -p0
|
||||||
|
%patch352 -p0
|
||||||
|
|
||||||
# udev patches
|
# udev patches
|
||||||
%patch1001 -p1
|
%patch1001 -p1
|
||||||
@ -1426,6 +1429,14 @@ do
|
|||||||
done
|
done
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# In combination with Patch352 set-and-use-default-logconsole.patch
|
||||||
|
# Ensure that journald log on tty10
|
||||||
|
#
|
||||||
|
%ifarch %ix86 x86_64 x32
|
||||||
|
sed -ri 's:#TTYPath=/dev/console:#TTYPath=/dev/tty10:' src/journal/journald.conf
|
||||||
|
%endif
|
||||||
|
|
||||||
%build
|
%build
|
||||||
cflags ()
|
cflags ()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user