containers / toolbox

Tool for interactive command line environments on Linux
https://containertoolbx.org/
Apache License 2.0
2.38k stars 208 forks source link

cmd/initContainer: Prevent passwd(1) from confusing the log parser #1508

Closed debarshiray closed 3 weeks ago

debarshiray commented 3 weeks ago

When a Toolbx container is started for the first time and the entry point invokes passwd --delete root to actually remove the password for root, passwd(1) writes the following to its standard error stream:

  passwd: Note: deleting a password also unlocks the password.

This doesn't happen when the same container is stopped and started once again.

Since, passwd(1) directly writes to its standard error stream without going through Logrus, the corresponding log entry in podman logs doesn't have a level key, and is assumed by the log parser in the enter and run commands to be an error. If the entry point doesn't actually encounter an error, then this confusion doesn't have any user-visible effect. However, if the entry point does encounter an error after this point, then the message from passwd(1) gets prepended to it and presented to the user:

  $ toolbox enter
  Error: passwd: Note: deleting a password also unlocks the password.
  failed to set KCM as the default Kerberos credential cache

Prevent this by intercepting the standard error stream of passwd(1) and make it go through Logrus when passwd(1) fails. Losing this particular message when passwd(1) actually succeeds in removing the password is not a big problem, because it's somewhat redundant.

Fallout from 815d7f60354dad2d0ce675025b1e2856e64df8a3

https://github.com/containers/toolbox/issues/750

softwarefactory-project-zuul[bot] commented 3 weeks ago

Build succeeded. https://softwarefactory-project.io/zuul/t/local/buildset/7d8ae4199e354303a7bf5d35155d2014

:heavy_check_mark: unit-test SUCCESS in 6m 41s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 06s :heavy_check_mark: unit-test-restricted SUCCESS in 5m 40s :heavy_check_mark: system-test-fedora-rawhide SUCCESS in 36m 46s :heavy_check_mark: system-test-fedora-40 SUCCESS in 34m 35s :heavy_check_mark: system-test-fedora-39 SUCCESS in 34m 17s :heavy_check_mark: system-test-fedora-38 SUCCESS in 34m 27s

softwarefactory-project-zuul[bot] commented 3 weeks ago

Build succeeded. https://softwarefactory-project.io/zuul/t/local/buildset/599d01d324524a1b9fea1c7251d42db8

:heavy_check_mark: unit-test SUCCESS in 6m 41s :heavy_check_mark: unit-test-migration-path-for-coreos-toolbox SUCCESS in 3m 47s :heavy_check_mark: unit-test-restricted SUCCESS in 5m 46s :heavy_check_mark: system-test-fedora-rawhide SUCCESS in 37m 12s :heavy_check_mark: system-test-fedora-40 SUCCESS in 35m 24s :heavy_check_mark: system-test-fedora-39 SUCCESS in 34m 07s :heavy_check_mark: system-test-fedora-38 SUCCESS in 34m 04s