Commit Graph

1054 Commits

Author SHA1 Message Date
Jan Rodák
f1d0ded43c Convert if/else to switch for transport name comparison
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-06-12 10:12:49 +02:00
Jan Rodák
b294a92a25 Add reasons to all staticcheck suppressions
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-06-12 10:12:40 +02:00
crawfordxx
d0f97989ad machine: escape % as %% in proxy values written to systemd unit conf
systemd interprets % as specifier characters in unit configuration files
(e.g. %H, %u, %40). Proxy environment variable values that contain
percent-encoded URL characters (such as %40 for @ in usernames) cause
systemd to emit warnings and fail to parse the generated
/etc/systemd/system.conf.d/default-env.conf:

  system.conf.d/default-env.conf:2: Failed to resolve specifiers in
  HTTP_PROXY=http://user%40example.com@proxy:3128

Fix by adding a bash variable substitution that doubles every % to %%
before writing to the systemd unit conf files. The profile.d and
environment.d destinations do not need this escaping and continue to
use the original value.

Fixes #28698

Signed-off-by: crawfordxx <crawfordxx@users.noreply.github.com>
2026-06-06 12:04:48 +08:00
Nicola Sella
d6cf6e8495 machine: share virtiofs systemd unit generation
Make GenerateSystemDFilesForVirtiofsMounts an agnostic function
and move the code from apple to pkg/machine/volume_systemd.go

MountVolumesToVM  is now a no-op matching the AppleHV and
LibKrun behaviour.

Continues from PR: https://github.com/podman-container-tools/podman/pull/28736

Fixes: https://redhat.atlassian.net/browse/RUN-4742

Signed-off-by: Nicola Sella <nsella@redhat.com>
2026-06-02 14:47:08 +02:00
Brent Baude
e581ddc253 Merge pull request #28731 from lstocchi/hyperv_enhancements
Fixes for Hyper-V user experience
2026-05-26 10:30:18 -05:00
Paul Holzinger
22c5f3fa55 Merge pull request #28527 from vyasgun/pr/krunkit-timesync
machine: add vfkit timesync device for Apple VMs
2026-05-26 12:23:04 +02:00
lstocchi
f96cbda1b0 hyperv: propagate detailed error from Hyper-V permission checks
Change isHyperVAdminMember from returning a bool to returning an error so that callers surface the specific failure reason — particularly distinguishing "not in the group" from "in the group but session not updated" (new ErrHypervUserSessionNotUpdated sentinel). This gives users actionable guidance instead of a generic permission error.

Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-05-25 00:10:18 +02:00
Kir Kolyshkin
d4f60b5826 libpod: some modernize fixes for freebsd and darwin
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-05-22 14:15:49 -07:00
Gunjan Vyas
250e5f9914 use constant for timesync port and update mac_env.sh to print krunkit version
Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
2026-05-20 12:56:50 +05:30
Gunjan Vyas
e5bef8b124 machine: add vfkit timesync device for Apple VMs
Fixes: #28345

Signed-off-by: Gunjan Vyas <vyasgun20@gmail.com>
2026-05-19 13:23:01 +05:30
Sebastien Tardif
846d1a1b05 Close leaked file handles in container config, CRIU stats, and playbook read
Add missing defer Close() calls in four locations:

- libpod/container.go: specFromState() opens the container config file
  but never closes it after reading, leaking one fd per call.

- libpod/container_internal_common.go: checkpoint() and restore() each
  open the bundle directory for CRIU statistics but never close it,
  leaking one fd per checkpoint/restore operation.

- pkg/machine/shim/host.go: Init() opens the playbook file but never
  closes it after ReadAll, leaking one fd per machine init.

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
2026-05-17 16:09:56 -07:00
Maya Chen
2f17614d0e fix: duplicated words in decompress.go log message and annotations.go comment
Signed-off-by: Maya Chen <275405107+otjdiepluong@users.noreply.github.com>
2026-05-14 05:08:45 +00:00
Paul Holzinger
a6e58ea101 wsl: remove custom registries.conf
This is already part of the base machine image, also with the overmount
of /etc/containers this would no loner be read anyway.

The machine-os update for this is here:
https://github.com/containers/podman-machine-os/pull/239

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
93b615c1f2 machine: move marker file to /etc/podman-machine
Matches changes from https://github.com/containers/container-libs/pull/779

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
e34f3bce0c machine: remove SSL_CERT_DIR/SSL_CERT_FILE copy
With podman 6 we have a --import-native-ca option that handles the
copying of certs much better.

As such remove our old legacy way of copying files these envs and also
the static certs.d dir. Since we now mount the full containers config
dir the certs from the cert.d are mounted already.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
b14e833ef6 machine: add test to check config mount
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
5e193ce96a wsl: mount config home dir like on other providers
The other providers use the volume mounts from containers.conf which
should take care of it. But because WSL is not using this we need to
hard code this ourselves.

Add a new custom unit to make systemd mount the path like we do for
podman socket mounts.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
41adad8ce9 machine test: combine three test cases
Each machine init boot takes a while, we can easily do this as part of
one test run to speed the overall machine test time up.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-11 15:58:03 +02:00
Paul Holzinger
d54f1eb6fe machine/wsl: remove some dead code
The config.go file has a build tag that was never used. Also remove
unused functions from other files.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-05-07 13:34:06 +02:00
Paul Holzinger
8c9f530cb3 Merge pull request #28621 from l0rd/import-certs-darwin-linux
Import host trusted certificates into the guest machine - macOS and Linux
2026-05-05 13:10:57 +02:00
Mario Loriedo
3f883706ba Import local certificates to machines on macOS and Linux
This is a follow up of https://github.com/containers/podman/pull/28336 where we
implemented the import of the certificates on Windows. This PR implements the
same feature on macOS and Linux.

Fixes https://redhat.atlassian.net/browse/RUN-4552

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-05-01 00:42:52 +02:00
Mario Loriedo
15c9ca130f Add command podman system hyperv-prep
Introducing a new `podmand system` subcommand to prepare a Windows host
to run Hyper-V based Podman machines: `hyperv-prep`.

When executed it:
- creates of the registry keys for VSocks
- adds the current user to the Hyper-V administrators group

This command requires an administrator terminal.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-04-29 23:00:29 +02:00
Mario Loriedo
92d186f20d Hyperv machine init/rm: skip win registry operations when possible
Hyper-V VMs require some specific Windows registry keys to allow the
communication between the host and the guest. Creating these registry
keys require elevated privileges.

These keys were created during the first Podman `machine init` and
removed when the last Podman machine is removed.

In this commit we skip the creation of the keys if they already exist in
the registry. So that admin privileges aren't required anymore, even for
the creation of the first Podman machine.

In other words, if the keys are pre-created by an administrator, user
will be able to create and remove machines without requiring to run any
elevated command. Even for the first podman machine.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-04-29 23:00:29 +02:00
Mario Loriedo
f6b6bce745 Minor hyperv stubber.go and vsock.go refactoring
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-04-29 23:00:29 +02:00
jait jacob
efc6ddfcc4 cleanup: run go fix on pkg/machine for windows
Signed-off-by: jait jacob <jai8.jacob@gmail.com>
2026-04-29 13:56:01 +05:30
Brent Baude
2cc3be7332 RUN-4539: Change podman module paths
The podman module paths are moving from github.com/containers/podman to
go.podman.io/podman.  This will help with future mobility.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2026-04-22 14:02:25 -05:00
Matt Heon
3279767614 Merge pull request #28336 from l0rd/import_native_ca
Import host trusted certificates into the guest machine - Windows part
2026-04-22 13:04:55 -04:00
Brent Baude
9ac300c6af Merge pull request #28535 from lstocchi/i25037
auto-add user to Hyper-V Administrators group
2026-04-22 10:31:55 -05:00
lstocchi
57eeb47143 auto-add user to Hyper-V Administrators group
Currently, running Podman on Hyper-V as a non-administrator requires the user to be a member of the "Hyper-V Administrators" local group. If they are not, various WMI calls fail with access denied.

This commit automates the permission setup.
1. During podman machine init, if Podman is running with elevated privileges (required for registry/networking setup anyway), it will now automatically add the current user to the localized "Hyper-V Administrators" group
2. If a user is added to the group, the change is not reflected until the next login. We now detect this state and explicitly instruct the user to log out and back in.
3. Modified the Hyper-V stubber to handle permission checks at the method level rather than the provider selection level (GetAll). This allows init to continue far enough to perform the elevation and setting.

Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-04-22 11:03:37 +02:00
Brent Baude
2e6f29a2df RUN-4538: Fix buildah vendoring
This PR reflects the upstream change of moving the buildah module from
github.com/containers/buildah to go.podman.io/buildah.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2026-04-21 14:27:58 -05:00
Jan Kaluza
54d61c2f02 trust: switch policy.json lookup to configfile
Use shared configfile instead of custom policy.json path handling.
This updates ocipull to rely on signature.DefaultPolicy(), removes
explicit SignaturePolicyPath, and replaces trust's custom default-policy
path logic with common configfile code.

Replace hidden `--policypath` with --signature-policy` and require
it for `trust set` command instead of path resolution based on
configfile.

For `trust get`, the `--signature-policy` is optional.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2026-04-20 15:11:22 +02:00
Matthew Heon
5e94c95ad0 Move to deterministic network setup order
This was implemented by containers/netavark #1369; this commit
completes the process by wiring it into Podman. We now respect
the CLI order for configured networks - if a user passes
`--net net1,net2` we guarantee that net1 will be configured
before net2.

For containers created before this patch, we don't retain enough
information to configure networks in CLI order, so we use
alphabetical order instead to still guarantee consistency.

No breaking API changes have been made, but we do add a new
field to supplement the existing map to (optionally) provide
ordering information. The Podman CLI will always pass this.
Existing applications that do not will, again, receive]
deterministic ordering based on an alphabetical sort of network
names.

This requires the latest version of Netavark to work properly.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2026-04-17 10:00:32 -04:00
Mario Loriedo
f7dd6156d3 Import host certificates at machine startup on Windows
Implements the feature introduced in the design
document added with commit 4bdc1d37

Fixes https://redhat.atlassian.net/browse/RUN-4260

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-04-16 13:35:40 +02:00
Paul Holzinger
571c842bd3 hyperV: fix powershell path escape
To avoid special chars from being interpreted.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-04-13 19:01:49 +02:00
lstocchi
a9a9eda883 rename ErrRelaunchAttempt to ErrRelaunchSucceeded and fix elevated error handling
The old ErrRelaunchAttempt name was ambiguous — it reads as though the
relaunch attempt failed, when it actually signals success. Rename to
ErrRelaunchSucceeded and update comments at every call site to clarify
that this is not a real error but a sentinel indicating the elevated
child process completed the operation successfully.

Also fix a bug in WSL's launchElevate where a failed elevated process
was incorrectly wrapped with the sentinel, causing callers to treat the
failure as success and print "Machine init complete."

Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-04-03 18:37:24 +02:00
lstocchi
8e5fde01c6 propose running init/rm command on hyperv machine in elevated mode
This commit adds automatic UAC elevation prompts for HyperV machine
init/rm actions when administrator privileges are required.
Previously, users had to manually run Podman as administrator
when creating the first machine or removing the last machine, which
requires Windows Registry modifications.

When the HyperV command gets relaunched as elevated, the error of the
elevated process is saved on a file to be displayed by the caller. The
implementation is the same as that used by WSL.

Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-04-03 18:37:08 +02:00
lstocchi
5b0ec91c54 move wsl' util_windows to windows package so it can be reused by hyperv
Signed-off-by: lstocchi <lstocchi@redhat.com>
2026-04-03 14:32:09 +02:00
Mario Loriedo
24ee5aec48 Add new flag --import-native-ca for machine init/set
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-04-01 14:12:30 +02:00
Mario Loriedo
4bba8c267a Extract function LocalhostSSHCopy to make it visible from other packages too
This will be useful when importing host certificates and the certificates file
isn't mounted in the guest.

Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
2026-04-01 14:12:30 +02:00
Tom Sweeney
8c3af49bef Merge pull request #28347 from Honny1/machine-cpu-limits
Reject `--cpus` above host CPU count on podman machine init and set
2026-03-25 11:05:37 -04:00
Jan Rodák
bb4dda4855 Reject --cpus above host CPU count on podman machine init and set
Fixes: https://github.com/containers/podman/issues/28322

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-03-23 18:22:14 +01:00
Brent Baude
48d36932e2 Error on WSL machine os apply|upgrade
Given that apply and upgrade do not work on WSL, we should error out
with an error as such.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2026-03-23 10:01:53 -05:00
Tim Zhou
0904bab01e add trailing newline to subgid due to shadow-utils 4.19.0 regression
Fedora 44 come with shadow-utils 4.19.0, This is a POSIX compliance fix - text files need end with a newline.
1. https://github.com/containers/podman-machine-os/issues/226
2. https://github.com/shadow-maint/shadow/issues/1581

Signed-off-by: Tim Zhou <tizhou@redhat.com>
2026-03-12 09:49:44 -04:00
Paul Holzinger
4f1d4ae8a0 fix new lint issues from prealloc
Fix a few new issues reported by the linter update.

There is no need to copy the capAdd/capDrop slice in the compat create
endpoint as they are only read and not modified.
For the other code preallocate the slices so we safe memory allocations.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-03-10 19:45:35 +01:00
Jan Kaluza
56e555bfc2 api/compat: switch to moby/moby
Replace github.com/docker/docker API imports with github.com/moby/moby
across compat handlers, swagger models, and tests to align with upstream
type definitions.

Fixes: #27536.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2026-03-09 11:09:23 +01:00
Paul Holzinger
afab7a444d Merge pull request #27412 from dvorst/fix/rootless-podman-in-podman-on-wsl
Fix: Rootless Podman-in-Podman on WSL
2026-03-03 21:04:12 +01:00
Miloslav Trmač
a37bf83dfc Also set DestinationCtx in a copy
It shouldn't actually affect anything, but it's easier
to set it than worry.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2026-03-02 23:17:13 +01:00
Miloslav Trmač
fd86c3c25f Use pullOptions.systemContext in getDestArtifact
Right now, this correctly handles pullOptions.credentials
which were ignored previously (admittedly that field is never set
by anything...); in the future, it will ensure the two c/image users
won't get out of sync again.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2026-03-02 23:17:12 +01:00
Miloslav Trmač
5946f7afcf Factor out pullOptions.systemContext from pull
We will add another user.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2026-03-02 23:17:12 +01:00
Miloslav Trmač
e807ae4350 Make ocipull.Pull and PullOptions private
There are no external users, so make that clearer.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2026-03-02 23:17:12 +01:00