Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
 <DBAPR83MB04564E1D356EA1FABFB2C3ADCB369@DBAPR83MB0456.EURPRD83.prod.outlook.com>
Date: Thu, 17 Feb 2022 20:37:34 +0000
From: Andy Caldwell <andycaldwell@...rosoft.com>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
CC: Yuri Kanivetsky <yuri.kanivetsky@...il.com>
Subject: RE: [EXTERNAL] Re: What determines the TERM variable value?

> On Sun, Feb 13, 2022 at 10:54:23AM +0200, Yuri Kanivetsky wrote:
> > I don't think it's configurable in a common sense:
> >
> > https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> > ub.com%2Fmoby%2Fmoby%2Fblob%2Fv20.10.12%2Fcontainer%2Fcontainer.go%23L
> > 752&amp;data=04%7C01%7Candy.caldwell%40microsoft.com%7C15c78d610615484
> > 4ccf808d9eed74d25%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C6378034
> > 31376969496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMz
> > IiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=Icw%2BHvFTPaaY0w%2B6
> > VcmyhhXT%2BXhube1WJ0kO5UmC0qk%3D&amp;reserved=0
> >
>
> Oh bloody hell. All this complexity, and this is the part they choose to make fixed?

It makes perfect sense that this is hard-coded.  As you say, the TERM variable is the way
programs running on the TTY learn what escape codes to use to ask the TTY to do things
(change colour, clear the screen, restart a line, etc.) so the TERM is _set by the TTY_.
When running a docker container with a TTY attached, the TTY is created by the docker
daemon and isn't the TTY that's hosting the docker client binary.  This is needed to allow
the client to disconnect from the deamon without killing the container, and it also needed
for cases where the client and daemon are on separate hosts.

The daemon is listening on the master side of the TTY it created then streams data to and
from the client (if there is one) which then reads _its_ TERM variable and translates the
operations that the container tried to make into the appropriate control codes for the local
TTY.  Changing the TERM inside the container only makes sense if you also change the TTY
handling that the daemon does to match, otherwise the daemon will incorrectly interpret
control characters, pass those misinterpretations to the client which will then "correctly"
apply the wrong behaviour to the user's console.

Awkwardly many TTY termcap control characters are _mostly_ compatible (since they're
all based on VT100) so if you misconfigure your TERM things _mostly_ work, then you try
to use some TUI-heavy tool (like vim) and some things subtly don't work correctly.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.