RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2059658 - join template in podman inspect errors when new line is selected as a separator
Summary: join template in podman inspect errors when new line is selected as a separator
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: podman
Version: 8.6
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: rc
: ---
Assignee: Jindrich Novy
QA Contact: Yuhui Jiang
URL:
Whiteboard:
Depends On:
Blocks: 2026666 2078411
TreeView+ depends on / blocked
 
Reported: 2022-03-01 16:22 UTC by Matus Marhefka
Modified: 2023-05-16 09:00 UTC (History)
13 users (show)

Fixed In Version: podman-4.3.1-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2078411 (view as bug list)
Environment:
Last Closed: 2023-05-16 08:18:40 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github containers podman pull 15673 0 None Merged Fix go template parsing with "\n" in it 2022-12-01 11:45:23 UTC
Red Hat Issue Tracker RHELPLAN-114139 0 None None None 2022-03-01 16:34:49 UTC
Red Hat Product Errata RHSA-2023:2758 0 None None None 2023-05-16 08:38:51 UTC

Description Matus Marhefka 2022-03-01 16:22:20 UTC
Description of problem:
join template in `podman inspect --format` does not accept new line as a separator:

# podman inspect ubi8 --format '{{join .Config.Env "\n"}}'
ERRO[0000] Printing inspect output: template: all inspect:1: unterminated quoted string 

But space/tab works:

# podman inspect ubi8 --format '{{join .Config.Env "\t"}}'
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin  container=oci
# podman inspect ubi8 --format '{{join .Config.Env " "}}'
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin container=oci

Version-Release number of selected component (if applicable):
podman-4.0.0-3.module+el8.6.0+14305+6b14f34e.x86_64

How reproducible:
always

Steps to Reproduce:
1. podman inspect ubi8 --format '{{join .Config.Env "\n"}}'
2.
3.

Actual results:
ERRO[0000] Printing inspect output: template: all inspect:1: unterminated quoted string

Expected results:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
container=oci

Additional info:

Comment 1 Daniel Walsh 2022-03-01 20:03:58 UTC
Jhon PTAL

Comment 2 Jindrich Novy 2022-05-10 08:25:29 UTC
This is still happening in podman-4.1.0:

jnovy@localhost ~/bin$ podman inspect registry.access.redhat.com/ubi8/ubi:latest --format '{{join .Config.Env "\n"}}'
ERRO[0000] Printing inspect output: template: all inspect:1: unterminated quoted string 

jnovy@localhost ~/bin$ podman inspect registry.access.redhat.com/ubi8/ubi:latest --format '{{join .Config.Env "\t"}}'
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin  container=oci

Comment 4 Paul Holzinger 2022-07-29 11:17:41 UTC
IMO it is not a good idea to replace characters inside the template block `{{` ... `}}`.
I looked at what docker is doing and they have the same problem except for the inspect commands where no replace is done.
I would argue that we should not touch the user input at all but I guess this was done for docker compat.

A simple reproducer that should work with all --format flags is: --format '{{printf "\n"}}'
I see three solutions:
1. do not replace at all (this will break docker compat)
2. do not replace inside {{ }} blocks (could also break backwards compat)
3. replace and parse the template, if it fails parse again with the raw input without replace.

I would prefer 3 since this will not cause any regressions for user relying on the current implementation.
@jhonce WDYT?

Comment 5 Jhon Honce 2022-08-09 15:03:32 UTC
(In reply to Paul Holzinger from comment #4)
> IMO it is not a good idea to replace characters inside the template block
> `{{` ... `}}`.
> I looked at what docker is doing and they have the same problem except for
> the inspect commands where no replace is done.
> I would argue that we should not touch the user input at all but I guess
> this was done for docker compat.
> 
> A simple reproducer that should work with all --format flags is: --format
> '{{printf "\n"}}'
> I see three solutions:
> 1. do not replace at all (this will break docker compat)
> 2. do not replace inside {{ }} blocks (could also break backwards compat)
> 3. replace and parse the template, if it fails parse again with the raw
> input without replace.
> 
> I would prefer 3 since this will not cause any regressions for user relying
> on the current implementation.
> @jhonce WDYT?

@pholzing #3 sounds like the best solution, we need the compat where possible.

Comment 6 Paul Holzinger 2022-09-08 16:07:33 UTC
Upstream PR (not yet merged) with a fix: https://github.com/containers/podman/pull/15673

Comment 11 errata-xmlrpc 2023-05-16 08:18:40 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: container-tools:rhel8 security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2758

Comment 12 errata-xmlrpc 2023-05-16 08:38:40 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: container-tools:rhel8 security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2758


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