Bug 2230212 - Multi-line value used for --env is cut at newline [NEEDINFO]
Summary: Multi-line value used for --env is cut at newline
Keywords:
Status: POST
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: podman
Version: CentOS Stream
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: rc
: ---
Assignee: Jindrich Novy
QA Contact: Yuhui Jiang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-08-09 01:48 UTC by Takashi Kajinami
Modified: 2023-08-11 12:36 UTC (History)
15 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:
tsweeney: needinfo? (jnovy)


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github containers podman pull 19560 0 None open fix(env): parsing --env incorrect in cli 2023-08-09 11:20:04 UTC
Red Hat Issue Tracker RHELPLAN-164942 0 None None None 2023-08-09 01:49:52 UTC

Description Takashi Kajinami 2023-08-09 01:48:30 UTC
Description of problem:

We noticed that podman-4.6.0-3.el9.x86_64 does not handle multi-line values passed to the --env option
and it only accepts the first line.

+ podman inspect container-puppet-memcached
[
     {
          "Id": "36166f7f5e31e581e3b17db5b02b80bfb11204a24d6923cce3c938aaa612ae07",
          ...
          "Config": {
               ...
               "Env": [
                    "NET_HOST=true",
                    "DEBUG=false",
                    "HOSTNAME=standalone",
                    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                    "container=oci",
                    "PUPPET_TAGS=file,file_line,concat,augeas,cron,file",
                    "STEP=6",
                    "LANG=en_US.UTF-8",
                    "NAME=memcached",
                    "STEP_CONFIG=include ::tripleo::packages", <=====(*)
                    "HOME=/root"
               ],
               ...
     }
}

This problem was not seen when podman-4.6.0-1.el9.x86_64 is used.

+ podman inspect container-puppet-memcached
[
     {
          "Id": "36166f7f5e31e581e3b17db5b02b80bfb11204a24d6923cce3c938aaa612ae07",
          ...
          "Config": {
               ...
               "Env": [
                    "NET_HOST=true",
                    "NO_ARCHIVE=",
                    "TERM=xterm",
                    "container=oci",
                    "STEP=6",
                    "DEBUG=false",
                    "HOSTNAME=standalone",
                    "PUPPET_TAGS=file,file_line,concat,augeas,cron,file",
                    "NAME=memcached",
                    "STEP_CONFIG=include ::tripleo::packages\ninclude tripleo::profile::base::memcached\n", <=====(*)
                    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                    "LANG=en_US.UTF-8",
                    "HOME=/root"
               ],
               ...
     }
]

Version-Release number of selected component (if applicable):
podman-4.6.0-3.el9.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Create a container with an environment which has multi-line value
$ podman run -it --env foo="bar
baz" <image> /bin/bash

2. Echo the environment inside the container
# echo $foo

3. Check Config.Env of the container by inspect
$ podman inspect <container name>


Actual results:
The environment in container contains only the first line

```
[root@131d1dc33adc /]# echo $foo
bar
[root@131d1dc33adc /]#
```

```
$ podman inspect naughty_kowalevski | head -3
[
     {
          "Id": "131d1dc33adc781ad8f171b6d569321a8b35ed2e4831e5feb6109bcc8886e596",
          ...
               "Env": [
                    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                    "container=podman",
                    "TERM=xterm",
                    "foo=bar",
                    "HOME=/root",
                    "HOSTNAME=131d1dc33adc"
               ],

```

Expected results:
The environment in container contains all the lines

```
[root@cecaed241326 /]# echo $foo
bar baz
[root@cecaed241326 /]#
```

```
$ podman inspect agitated_hamilton
[
     {
          "Id": "cecaed2413262f4e19e1e0dce64b1bfaa0db23032aece7a924293974aafe08b5",
          ...
               "Env": [
                    "container=podman",
                    "foo=bar\nbaz",
                    "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                    "TERM=xterm",
                    "HOME=/root",
                    "HOSTNAME=cecaed241326"
               ],
```

Additional info:
This issue was initially found in the TripleO project in OpenStack.

Comment 1 Takashi Kajinami 2023-08-09 03:45:32 UTC
We currently suspect the new version contains https://github.com/containers/podman/pull/19096 and that causes the problem.
(though it does not make very good sense that such as change can be pulled in a revision change)

Comment 2 Takashi Kajinami 2023-08-09 03:54:57 UTC
I checked c9s distgit and confirmed that the -3 containers change for https://github.com/containers/podman/pull/19096 while -1 does not contain it.
I've reported the issue in that PR but we have to get it fixed in podman and pull the fix into the c9s package.

Comment 3 Black-Hole 2023-08-09 06:12:20 UTC
Fix PR: https://github.com/containers/podman/pull/19560


Note You need to log in before you can comment on or make changes to this bug.