summaryrefslogtreecommitdiff
path: root/src/getty-generator
diff options
context:
space:
mode:
authorMichael Marineau <michael.marineau@coreos.com>2013-08-16 20:28:24 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-09-12 08:34:30 -0400
commit39f0570d6ea01476dd82bbcae60f51f97f614cec (patch)
tree91428c419654976db76b23a357e81807d6c2c884 /src/getty-generator
parent176cceb051fd9537239e5e8a43f80a33d06fe3b8 (diff)
downloadsystemd-39f0570d6ea01476dd82bbcae60f51f97f614cec.tar.gz
getty-generator: Enable getty on all active serial consoles.
This enables a getty on active kernel consoles even when they are not the last one specified on the kernel command line and mapped to /dev/console. Now the order "console=ttyS0 console=tty0" works in addition to "console=tty0 console=ttyS0".
Diffstat (limited to 'src/getty-generator')
-rw-r--r--src/getty-generator/getty-generator.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/getty-generator/getty-generator.c b/src/getty-generator/getty-generator.c
index 4b7a60a4ec..6c938062de 100644
--- a/src/getty-generator/getty-generator.c
+++ b/src/getty-generator/getty-generator.c
@@ -122,33 +122,42 @@ int main(int argc, char *argv[]) {
}
if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
- const char *tty;
-
- tty = strrchr(active, ' ');
- if (tty)
- tty ++;
- else
- tty = active;
-
- /* Automatically add in a serial getty on the kernel
- * console */
- if (isempty(tty) || tty_is_vc(tty))
- free(active);
- else {
+ char *w, *state;
+ size_t l;
+
+ /* Automatically add in a serial getty on all active
+ * kernel consoles */
+ FOREACH_WORD(w, l, active, state) {
+ char *tty;
int k;
+ tty = strndup(w, l);
+ if (!tty) {
+ log_oom();
+ free(active);
+ r = EXIT_FAILURE;
+ goto finish;
+ }
+
+ if (isempty(tty) || tty_is_vc(tty)) {
+ free(tty);
+ continue;
+ }
+
/* We assume that gettys on virtual terminals are
* started via manual configuration and do this magic
* only for non-VC terminals. */
k = add_serial_getty(tty);
- free(active);
if (k < 0) {
+ free(tty);
+ free(active);
r = EXIT_FAILURE;
goto finish;
}
}
+ free(active);
}
/* Automatically add in a serial getty on the first