Skip to content

apiclient exec ignores TERM environment variable #496

@arnaldo2792

Description

@arnaldo2792

Package I'm using:
apiclient

What I expected to happen:
I expect that apiclient uses the TERM configured here:

What actually happened:

The TERM environment variable is set for the process calling ctr but not for the actual process exec'd in the container:

# Process running ctr, forked by apiserver
[root@admin]# ps aux | grep "task exec"
root       85291  0.1  0.0 1846756 25168 ?       Ssl+ 19:07   0:00 /usr/bin/ctr -a /run/host-containerd/containerd.sock task exec --exec-id apiexec-PwuupPC70QMeV8xD --tty admin bash

[root@admin]# cat /proc/85291/environ
TERM=screen

# The actual process that exec'ed
[root@admin]# cat /proc/self/environ
NO_PROXY=localhost,127.0.0.1,032e431c8c6db4d7c0b634561b5195bd.gr7.us-west-2.eks.amazonaws.com,.cluster.localPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binPWD=/SHLVL=1HOME=/rootno_proxy=localhost,127.0.0.1,032e431c8c6db4d7c0b634561b5195bd.gr7.us-west-2.eks.amazonaws.com,.cluster.local_

How to reproduce the problem:
From the control container, just apiclient exec admin bash and check TERM;

[ssm-user@control]$ apiclient exec admin sh -c 'echo $TERM' 
dumb

I haven't nail down where is this dumb coming from. Is not set by ctr and it isn't in the environment variables list as shown above. My guess is that it is an automatic value set by the terminal emulator.

I tried to force ctr to override this env variable, but ctr doesn't allow overrides in exec. One thing to try is to force the container image to have ENV TERM=screen, so that the main container process always has TERM set and theoretically, ctr will respect that when forking the exec'd process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions