summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-02-13 19:01:47 +0100
committerLennart Poettering <lennart@poettering.net>2011-02-13 19:01:47 +0100
commit3030ccd79f71854551d06cda904fd56b85b1aeb7 (patch)
tree165e09786ef1b43eca7f86053b94e6102fff9f9e
parent2633eb8317623138f585957fcf8337a99fb1528f (diff)
util: when determining the right TERM for /dev/console consult /sys/class/tty/console/active
-rw-r--r--src/util.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/util.c b/src/util.c
index 09c13143c6..e78063c5aa 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3550,18 +3550,28 @@ void filter_environ(const char *prefix) {
}
const char *default_term_for_tty(const char *tty) {
+ char *active = NULL;
+ const char *term;
+
assert(tty);
if (startswith(tty, "/dev/"))
tty += 5;
- if (startswith(tty, "tty") &&
- tty[3] >= '0' && tty[3] <= '9')
- return "TERM=linux";
+ /* Resolve where /dev/console is pointing when determining
+ * TERM */
+ if (streq(tty, "console"))
+ if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
+ truncate_nl(active);
+ tty = active;
+ }
+
+ term = (startswith(tty, "tty") &&
+ tty[3] >= '0' && tty[3] <= '9') ? "TERM=linux" : "TERM=vt100";
- /* FIXME: Proper handling of /dev/console would be cool */
+ free(active);
- return "TERM=vt100";
+ return term;
}
bool running_in_vm(void) {