]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Try to initialize TERM from systemd.tty.term.console as well
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 8 May 2023 09:27:31 +0000 (11:27 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 12 May 2023 06:38:20 +0000 (08:38 +0200)
We already have the systemd.tty.xxx kernel cmdline arguments for
configuring tty's for services, let's make sure the term cmdline
argument applies to pid1 as well.

man/kernel-command-line.xml
src/core/main.c

index 09f8ace4de691f7287e91cdad435a8479f281518..211ae5ac57186e65457b089cdcc4b8b01d709a6a 100644 (file)
 
         <listitem><para>These arguments allow configuring default values for <varname>$TERM</varname>,
         <varname>TTYRows=</varname>, and <varname>TTYColumns=</varname> for tty
-        <replaceable>tty</replaceable>. The tty name should be specified without the
-        <filename>/dev/</filename> prefix (e.g. <literal>systemd.tty.rows.ttyS0=80</literal>).
+        <replaceable>tty</replaceable>. Additionally, <varname>systemd.tty.term.console</varname> will
+        configure the <varname>$TERM</varname> value used by <command>systemd</command> if not set explicitly
+        using <varname>TERM</varname> on the kernel command line. The tty name should be specified without
+        the <filename>/dev/</filename> prefix (e.g. <literal>systemd.tty.rows.ttyS0=80</literal>).
         </para></listitem>
       </varlistentry>
     </variablelist>
index 5347372c817a298d4f038138053b455b6afc1cef..86385d64656a0931a39e062619b4864c73332579 100644 (file)
@@ -1425,6 +1425,12 @@ static int fixup_environment(void) {
         if (r < 0)
                 return r;
 
+        if (r == 0) {
+                r = proc_cmdline_get_key("systemd.tty.term.console", 0, &term);
+                if (r < 0)
+                        return r;
+        }
+
         t = term ?: default_term_for_tty("/dev/console");
 
         if (setenv("TERM", t, 1) < 0)