Repository navigation
[IMP] Allow Podman's libpod API paths - #193
Open
junkerderprovinz wants to merge 1 commit into
Open
junkerderprovinz wants to merge 1 commit into
junkerderprovinz wants to merge 1 commit into
Conversation
The Podman client sends every request to /v{version}/libpod/..., so the
endpoint rules answered even _ping with 403 and podman --url could not
connect. Each rule now also matches with a /libpod segment, under the
same variable as its Docker counterpart. Podman-only sections such as
pods stay blocked, and so do the libpod routes that reach further than
the Docker endpoint behind the same variable: secret inspect, volume
export and import, system prune and check, and image scp.
Fixes Tecnativa#104
Co-authored-by: Alex-K37 <106149389+Alex-K37@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #113 by @Alex-K37 (and #103). Thanks for the original work!
Fixes #104
Problem
The Podman client sends its requests to the native API under
/v{version}/libpod/...,starting with
GET /v4.6.1/libpod/_ping. The rules inhaproxy.cfgonly accept^(/v[\d\.]+)?/<endpoint>, so the proxy answers 403 to all of them andpodman --url tcp://...cannot connect.Change
Every endpoint rule, and the
use_backend docker-eventsrule, gets an optional(/libpod)?segment after the version. A libpod path is allowed by the same variable asits Docker counterpart, so
/v5.0.0/libpod/containers/jsonneedsCONTAINERS=1, thesame as
/containers/json.#113 used
(/\w+)?, which accepts any word in that position.(/libpod)?only opens theprefix Podman uses.
A few libpod routes can do more than the Docker endpoint behind the same variable. A
deny rule before the allow rules blocks them whatever the variables say:
secrets/{name}/jsonreturns the secret in plain text withshowsecret=true. Podmanonly honours that flag on libpod paths.
volumes/{name}/exportstreams a volume's contents, andvolumes/{name}/importwrites into it.
system/prunedeletes unused data, andsystem/checkcan repair storage withrepair_lossy.images/scp/{name}copies an image to another host over the host's SSH.Listing secrets and volumes,
secrets/{name}/existsandsystem/dfstill work, and sodoes the Docker style
secrets/{name}inspect.Libpod container subpaths that Docker lacks (mount, checkpoint, restore, init) fall
under the
CONTAINERSprefix rule, the same way every/containers/...path does. WithPOST=1that rule already allows creating containers.containers/{name}/healthcheckis a GET that runs the container's configured healthcheck; it stays under
CONTAINERSbecause it cannot run anything else.
I checked Podman's route registrations (
pkg/api/server/register_*.go) and its client(
pkg/bindings/connection.go). By default the client builds/v{major}.{minor}.{patch}/libpod/...; anAPI-Versionheader overrides the version.Podman-only endpoints such as pods, manifests, kube, play, generate, artifacts, quadlets
and
local/...have no variable here and stay blocked.How tested
test_libpod_permissions: withCONTAINERS=1, the libpod paths for_ping,versionandcontainersgo through, whileimages,info,podsand/v4.6.1/other/containers/jsonget 403.test_libpod_routes_beyond_docker_blocked: withIMAGES,SECRETS,SYSTEMandVOLUMESset, the libpod list routes andsystem/dfgo through, while secretinspect, volume export, system prune and image scp get 403. Without the deny rule this
test fails on
/v4.6.1/libpod/secrets/foo/json.poetry run pytest --prebuildon Python 3.8 against Docker 29.9.2: 7 passed, bothserial and with the default
-n auto.haproxy -cin the built image (HAProxy 3.4.2) accepts the config. Its only warningis the missing timeouts for
docker-events, which master shows as well.CONTAINERS,IMAGES,SECRETS,SYSTEM,VOLUMESandPOSTset:ps,images,secret ls,secret create,volume ls,volume createandsystem dfwork.volume export,system pruneandsystem checkget 403, and so dosecret inspect --showsecretandsecret inspect,according to the proxy log.
pre-commit runpasses on the changed files.The last scheduled CI run on master failed with connection resets in three existing
tests, while the runs before it were green. If CI here fails the same way, a re-run
should show whether it is that.