[lxc/lxc] 0636ec: lxc/conf,start: fix setting container_ttys environ...

1 view
Skip to first unread message

Serge Hallyn

unread,
Apr 25, 2025, 4:39:40 PMApr 25
to lxc-...@lists.linuxcontainers.org
Branch: refs/heads/main
Home: https://github.com/lxc/lxc
Commit: 0636ec66b950dd42342fc937cbba97365e92f01e
https://github.com/lxc/lxc/commit/0636ec66b950dd42342fc937cbba97365e92f01e
Author: Roman Azarenko <roman.az...@genexis.eu>
Date: 2025-04-22 (Tue, 22 Apr 2025)

Changed paths:
M src/lxc/conf.c
M src/lxc/start.c

Log Message:
-----------
lxc/conf,start: fix setting container_ttys environment variable

Commit eae44ce19931 ("conf: fix append_ttyname()") changed the format
of `conf->ttys.tty_names`, where the `container_ttys=` prefix was
removed.

This seems to have been taken into account in `lxc_create_ttys()` in
`src/lxc/conf.c`, however that's not enough. `do_start()` in
`src/lxc/start.c` clears the environment, and then does `putenv(...)`
directly on the value of `tty_names`. As it no longer has the
`container_ttys=` prefix, this call doesn't have the intended effect.

This behaviour is also confirmed via `ltrace` when doing `lxc-start`:

[pid 53587] liblxc.so.1->setenv("container_ttys", "pts/1 pts/2 pts/3 pts/4", 1) = 0
[pid 53587] liblxc.so.1->clearenv(0, 1, 0, 0) = 0
[pid 53587] liblxc.so.1->putenv("container=lxc") = 0
[pid 53587] liblxc.so.1->putenv("pts/1 pts/2 pts/3 pts/4") = 0

Given that `do_start()` clears the environment anyway, there is no
reason for another `setenv()` call in `lxc_create_ttys()`, and a fix
is required for `putenv()` in `do_start()`.

Change the `putenv()` call to `setenv()` in `do_start()` to account
for the change of format in `conf->ttys.tty_names`. Remove extraneous
`setenv()` from `lxc_create_ttys()`.

Fixes #4198

Fixes: eae44ce19931 ("conf: fix append_ttyname()")
Signed-off-by: Roman Azarenko <roman.az...@genexis.eu>


Commit: b294df5d4f50d0372ce8ad7d2a2b041ad0abee6f
https://github.com/lxc/lxc/commit/b294df5d4f50d0372ce8ad7d2a2b041ad0abee6f
Author: Serge Hallyn <se...@hallyn.com>
Date: 2025-04-25 (Fri, 25 Apr 2025)

Changed paths:
M src/lxc/conf.c
M src/lxc/start.c

Log Message:
-----------
Merge pull request #4544 from RomanGenexis/4198-fix-container-ttys-env

lxc/conf,start: fix setting container_ttys environment variable


Compare: https://github.com/lxc/lxc/compare/eb971465232d...b294df5d4f50

To unsubscribe from these emails, change your notification settings at https://github.com/lxc/lxc/settings/notifications
Reply all
Reply to author
Forward
0 new messages