feat(driver-podman): add userns config - #2562
Conversation
|
All contributors have signed the DCO ✍️ ✅ |
32a94ab to
31a1f54
Compare
|
Potential Concerns
Minor: extraction runs on the sandbox-create path rather than driver startup (first create per digest pays inspect + create + download + remove); the mid-file use openshell_core::driver_utils::SUPERVISOR_IMAGE_BINARY_PATH; at driver.rs:964 breaks the file's import convention; #[serde(rename = "AutoUserNs")] would be cleaner than #[allow(non_snake_case)]. |
31a1f54 to
e3619ff
Compare
|
I have read the DCO document and I hereby sign the DCO. |
e3619ff to
444fe35
Compare
|
thanks! Comments addressed |
|
• ## PR review: Request changes Findings
Required follow-ups
|
444fe35 to
573f5dc
Compare
|
Two minor things left now:
|
|
Needs rebase then we can kick off tests. |
…hell-core Move supervisor binary extraction, caching, and validation helpers from the Docker driver into openshell-core::driver_utils so both Docker and Podman drivers can reuse them. Moved helpers: extract_first_tar_entry, write_cache_binary_atomic, supervisor_cache_path, temp_extract_container_name, and validate_linux_elf_binary. The shared extract_first_tar_entry gains entry-type and empty-payload checks that the Docker-local version lacked. supervisor_cache_path takes a driver_subdir parameter so each driver caches under its own namespace (docker-supervisor vs podman-supervisor). Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
573f5dc to
cbbb604
Compare
|
P2: clean up partially created TLS secrets ( OpenShell/crates/openshell-driver-podman/src/driver.rs Lines 185 to 205 in cbbb604 lines 809–817 does not remove them, and the server does not call driver deletion after failed creation. Clean up names before returning the error. |
cbbb604 to
98e068e
Compare
|
/ok to test 98e068e |
5f7ab03 to
d1dad78
Compare
|
I've added support also for |
Add a `userns` option to the Podman compute driver that maps to Podman's user namespace modes. The mode string is split on the first colon into the API's `nsmode` and `value` fields so parameterized values like `auto:size=65536` and `keep-id:uid=1000,gid=1000` are forwarded correctly. When the mode is `auto`, the container spec also sets `idmappings.AutoUserNs = true` as required by the API. An allowlist validates the mode at startup: `auto` and `keep-id` accept optional parameters; `host`, `private`, and `nomap` reject them; everything else is an error. Podman image volumes use overlay mounts internally and the kernel does not support idmapped mounts on overlay (`mount_setattr` returns EINVAL). When userns is configured (any mode except `host`), the driver extracts the supervisor binary from the image to a host-side cache and bind-mounts it instead of using an image volume. Configurable via TOML `userns = "auto"`, CLI `--userns`, or environment variable `OPENSHELL_PODMAN_USERNS`. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
d1dad78 to
209f209
Compare
Summary
Add user namespace support to the Podman compute driver. The userns config option maps to Podman's namespace modes with parameterized value support (auto:size=65536, keep-id:uid=1000,gid=1000). When userns is configured, the driver extracts the supervisor binary to a host-side cache and bind-mounts it instead of using an OCI image volume, because the kernel does not support idmapped mounts on overlay.
The private mode supports explicit UID/GID mappings via uidmap and gidmap config arrays, giving operators full control over which container IDs map to which host IDs. This is needed when auto breaks host-owned bind-mounts (e.g. TLS files with mode 0600 become unreadable when container UID 0 maps to an unprivileged host UID).
A preparatory refactor commit extracts shared supervisor binary helpers (extraction, caching, ELF validation) from the Docker driver into openshell-core::driver_utils so both drivers reuse the same code with hardened integrity checks.
Related Issue
Fixes: #2554
Changes
Commit 1: refactor(driver): extract shared supervisor binary helpers into openshell-core
extract_first_tar_entry,write_cache_binary_atomic,supervisor_cache_path,temp_extract_container_name, andvalidate_linux_elf_binaryfrom Docker driver toopenshell-core::driver_utilsextract_first_tar_entrysupervisor_cache_pathby driver name (docker-supervisorvspodman-supervisor)Commit 2: feat(driver-podman): add userns config with supervisor bind-mount fallback
usernsfield toPodmanComputeConfig(TOMLuserns, CLI--userns, envOPENSHELL_PODMAN_USERNS):into Podman APInsmode+valuefieldsidmappings.AutoUserNs = truewhen base mode isautoauto/keep-idaccept params,host/nomapreject themhost)copy_from_containerAPI method to PodmanClientTesting
mise run pre-commitpassesChecklist