shared/ptyfwd: allow window title but not background color as a valid state

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.
This commit is contained in:
Sam Leonard
2024-02-28 11:50:18 +00:00
parent 73a72e3a7b
commit 9eb118eea7
+6 -2
View 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 */