]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/ptyfwd: allow window title but not background color as a valid state
authorSam Leonard <sam.leonard@codethink.co.uk>
Tue, 27 Feb 2024 15:08:37 +0000 (15:08 +0000)
committerSam Leonard <sam.leonard@codethink.co.uk>
Wed, 28 Feb 2024 11:50:18 +0000 (11:50 +0000)
Previously if a PTYForward instance had the window title set but no
background color set then it would crash in an assertion as
pty_forward_ansi_process didn't require both to be present.

systemd-vmspawn could get into this state if it failed to get the
terminal tint color.

Now any method that would have called background_color_sequence now
becomes just a NOP if the background color is not set.

This allows keeping the functionality to set window titles even if the
terminal doesn't support the background coloring.

src/shared/ptyfwd.c

index f910f3aaf91b7659e2a76ff69054c3192d416cfd..bf775425e78be8fbb2475df056d7956012e4bb92 100644 (file)
@@ -270,7 +270,9 @@ static int insert_newline_color_erase(PTYForward *f, size_t offset) {
         _cleanup_free_ char *s = NULL;
 
         assert(f);
-        assert(f->background_color);
+
+        if (!f->background_color)
+                return 0;
 
         /* When we see a newline (ASCII 10) then this sets the background color to the desired one, and erase the rest
          * of the line with it */
@@ -289,7 +291,9 @@ static int insert_carriage_return_color(PTYForward *f, size_t offset) {
         _cleanup_free_ char *s = NULL;
 
         assert(f);
-        assert(f->background_color);
+
+        if (!f->background_color)
+                return 0;
 
         /* When we see a carriage return (ASCII 13) this this sets only the background */