Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman generate systemd doesn't escape the value for --entrypoint #12723

Closed
cognition9144 opened this issue Dec 31, 2021 · 1 comment
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@cognition9144
Copy link
Contributor

cognition9144 commented Dec 31, 2021

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

In continuation of #12719, the issue turns out to be that podman generate systemd generates a systemd unit where the --entrypoint parameter was not escaped.

Steps to reproduce the issue:

podman run --name magical_brahmagupta -d --rm --entrypoint \[\"/cron.sh\"\] docker.io/nextcloud:fpm-alpine
podman generate systemd --new --files --name magical_brahmagupta
cp container-magical_brahmagupta.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user start container-magical_brahmagupta.service

Describe the results you received:

Job for container-magical_brahmagupta.service failed because the control process exited with error code.
See "systemctl --user status container-magical_brahmagupta.service" and "journalctl --user -xeu container-magical_brahmagupta.service" for details.
> journalctl -f
*** localhost.localdomain systemd[2448]: Starting Podman container-magical_brahmagupta.service...
*** localhost.localdomain podman[1392667]: *** m=+0.092160086 image pull  docker.io/nextcloud:fpm-alpine
*** podman[1392667]: *** CST m=+0.226053150 volume create adf444b2725cb3355fcfe70049ae510062b8d422f3e1318a0e7ac5004c2fc378
*** podman[1392667]:
*** podman[1392667]: *** CST m=+0.233606209 container create 8cf560057c3eeba65eceaa91c7533bde1d7988e8ee12c6999c0fefcd59fa1df2 (image=docker.io/library/nextcloud:fpm-alpine, name=sleepy_gagarin, PODMAN_SYSTEMD_UNIT=container-magical_brahmagupta.service)
*** systemd[2448]: Started libcrun container.
*** podman[1392667]: Error: executable file `[/cron.sh]` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found
*** systemd[2448]: container-magical_brahmagupta.service: Main process exited, code=exited, status=127/n/a
*** podman[1392771]: *** CST m=+0.111559699 container remove 8cf560057c3eeba65eceaa91c7533bde1d7988e8ee12c6999c0fefcd59fa1df2 (image=docker.io/library/nextcloud:fpm-alpine, name=sleepy_gagarin, PODMAN_SYSTEMD_UNIT=container-magical_brahmagupta.service)
*** podman[1392771]: 8cf560057c3eeba65eceaa91c7533bde1d7988e8ee12c6999c0fefcd59fa1df2
*** systemd[2448]: container-magical_brahmagupta.service: Failed with result 'exit-code'.
cat container-magical_brahmagupta.service                       
# container-magical_brahmagupta.service
# autogenerated by Podman 3.4.4
# Fri Dec 31 21:25:47 CST 2021

[Unit]
Description=Podman container-magical_brahmagupta.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run --cidfile=%t/%n.ctr-id --cgroups=no-conmon --rm --sdnotify=conmon -d --entrypoint ["/cron.sh"] docker.io/nextcloud:fpm-alpine
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all

[Install]
WantedBy=default.target

Describe the results you expected:

The container starts successfully

cat /tmp/container-magical_brahmagupta.service                       
# container-magical_brahmagupta.service
# autogenerated by Podman 3.4.4
# Fri Dec 31 21:25:47 CST 2021

[Unit]
Description=Podman container-magical_brahmagupta.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run --cidfile=%t/%n.ctr-id --cgroups=no-conmon --rm --sdnotify=conmon -d --entrypoint \[\"/cron.sh\"\] docker.io/nextcloud:fpm-alpine
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all

[Install]
WantedBy=default.target

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Version:      3.4.4
API Version:  3.4.4
Go Version:   go1.16.8
Built:        Thu Dec  9 05:45:07 2021
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.23.1
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.0.30-2.fc35.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.30, commit: '
  cpus: 16
  distribution:
    distribution: fedora
    variant: workstation
    version: "35"
  eventLogger: journald
  hostname: localhost.localdomain
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.15.8-200.fc35.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 581038080
  memTotal: 12459884544
  ociRuntime:
    name: crun
    package: crun-1.3-1.fc35.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.3
      commit: 8e5757a4e68590326dafe8a8b1b4a584b10a1370
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.1.12-2.fc35.x86_64
    version: |-
      slirp4netns version 1.1.12
      commit: 7a104a101aa3278a2152351a082a6df71f57c9a3
      libslirp: 4.6.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.3
  swapFree: 7791439872
  swapTotal: 8589930496
  uptime: 222h 26m 42.34s (Approximately 9.25 days)
plugins:
  log:
  - k8s-file
  - none
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/***/.config/containers/storage.conf
  containerStore:
    number: 35
    paused: 0
    running: 23
    stopped: 12
  graphDriverName: overlay
  graphOptions:
    overlay.mount_program:
      Executable: /usr/bin/fuse-overlayfs
      Package: fuse-overlayfs-1.7.1-2.fc35.x86_64
      Version: |-
        fusermount3 version: 3.10.5
        fuse-overlayfs: version 1.7.1
        FUSE library version 3.10.5
        using FUSE kernel interface version 7.31
  graphRoot: /home/***/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 120
  runRoot: /run/user/1000/containers
  volumePath: /home/***/.local/share/containers/storage/volumes
version:
  APIVersion: 3.4.4
  Built: 1638999907
  BuiltTime: Thu Dec  9 05:45:07 2021
  GitCommit: ""
  GoVersion: go1.16.8
  OsArch: linux/amd64
  Version: 3.4.4

Package info (e.g. output of rpm -q podman or apt list podman):

podman-3.4.4-1.fc35.x86_64

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/master/troubleshooting.md)

Yes
Additional environment details (AWS, VirtualBox, physical, etc.):

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 31, 2021
@Luap99
Copy link
Member

Luap99 commented Dec 31, 2021

This was already fixed in #12545

@Luap99 Luap99 closed this as completed Dec 31, 2021
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

2 participants