Skip to content

fix: clearer error publishing a privileged port to a specific IP on macOS#28982

Open
stefan8 wants to merge 1 commit into
podman-container-tools:mainfrom
stefan8:fix/gvproxy-privileged-port-error
Open

fix: clearer error publishing a privileged port to a specific IP on macOS#28982
stefan8 wants to merge 1 commit into
podman-container-tools:mainfrom
stefan8:fix/gvproxy-privileged-port-error

Conversation

@stefan8

@stefan8 stefan8 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Publishing a privileged port to a specific IP with podman machine on macOS failed with an opaque error. gvproxy binds the port on the host and runs unprivileged, and macOS rejects binding a < 1024 port to a specific IP. This returns a clearer error for that case and adds unit tests.

Checklist

  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all commits (git commit -s).
  • Referenced issues using Fixes: #28009 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

Publishing a privileged port (< 1024) to a specific IP address with `podman machine` on macOS now returns a clearer error explaining that gvproxy binds the port on the host.

@Luap99 Luap99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note https://github.com/podman-container-tools/podman/blob/main/CONTRIBUTING.md https://github.com/podman-container-tools/podman/blob/main/LLM_POLICY.md

It would be good if you can follow our contributing guidelines and follow the PR template instead of this AI summary format which is way to verbose.
Mentioning which file you changes is pointless as anyone can see that in the diff.

Also I see you opened many PRs in very short time, so I kindly would ask you to stop that as new contributor. That means we need to explain the some guidelines all these PRs many times and also practically exhaust our review capacity.

Comment thread libpod/networking_machine_test.go Outdated
Comment on lines +61 to +71
err := annotateGvproxyResponseError(strings.NewReader(tt.body), machineExpose{Local: tt.local})
if err == nil {
t.Fatal("expected an error, got nil")
}
if gotHint := strings.Contains(err.Error(), "gvproxy"); gotHint != tt.wantHint {
t.Fatalf("gvproxy hint = %v, want %v (err: %q)", gotHint, tt.wantHint, err.Error())
}
// The raw gvproxy response body is always preserved for debugging.
if !strings.Contains(err.Error(), tt.body) {
t.Fatalf("error %q should contain the original response body %q", err.Error(), tt.body)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using we are using github.com/stretchr/testify/assert /github.com/stretchr/testify/require in the repo already which produces better errors and reduces the boilerplate so please use them instead

i.e. require.NoError() assert.Equal()/Contains()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and sorry for the noise. I've switched the test to require/assert and trimmed the PR descriptions down to the template.

@stefan8 stefan8 force-pushed the fix/gvproxy-privileged-port-error branch 2 times, most recently from 41ab92a to 241712b Compare June 19, 2026 10:17
@packit-as-a-service

Copy link
Copy Markdown

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

With podman machine, gvproxy forwards published ports by binding them on
the host (not inside the VM) and runs unprivileged. macOS refuses to bind
a privileged port (< 1024) to a specific IP for a normal user, even though
binding all interfaces is fine, so publishing e.g. -p 127.0.0.1:80:80 used
to fail with an opaque "something went wrong with the request".

Pass the published ip:port into the gvproxy error helper and, when the body
says "permission denied" for a < 1024 port on a specific IP, return an
error that explains gvproxy binds on the host and suggests dropping the
host IP or using a port >= 1024. The raw body is kept for every other case.
Add unit tests for the helper.

Fixes: podman-container-tools#28009

Signed-off-by: Grzegorz Szczepanczyk <g.szczepanczyk@getprintbox.com>
@stefan8 stefan8 force-pushed the fix/gvproxy-privileged-port-error branch from 49533e9 to 697fa0c Compare June 19, 2026 11:25
@stefan8 stefan8 requested a review from Luap99 June 19, 2026 11:59

@Luap99 Luap99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants