diff --git a/Makefile b/Makefile index 35dc21a024f7..4aca6840cf4b 100644 --- a/Makefile +++ b/Makefile @@ -637,7 +637,7 @@ remotesystem: rc=0;\ if timeout -v 1 true; then \ SOCK_FILE=$(shell mktemp --dry-run --tmpdir podman_tmp_XXXX);\ - export PODMAN_SOCKET=unix:$$SOCK_FILE; \ + export PODMAN_SOCKET=unix://$$SOCK_FILE; \ ./bin/podman system service --timeout=0 $$PODMAN_SOCKET > $(if $(PODMAN_SERVER_LOG),$(PODMAN_SERVER_LOG),/dev/null) 2>&1 & \ retry=5;\ while [ $$retry -ge 0 ]; do\ diff --git a/cmd/podman/registry/registry.go b/cmd/podman/registry/registry.go index c643a320f541..b45a34ff1740 100644 --- a/cmd/podman/registry/registry.go +++ b/cmd/podman/registry/registry.go @@ -12,8 +12,8 @@ import ( "github.com/spf13/cobra" ) -// DefaultRootAPIAddress is the default address of the REST socket with unix: prefix -const DefaultRootAPIAddress = "unix:" + DefaultRootAPIPath +// DefaultRootAPIAddress is the default path of the REST socket with unix:// prefix +const DefaultRootAPIAddress = "unix://" + DefaultRootAPIPath type CliCommand struct { Command *cobra.Command @@ -104,7 +104,7 @@ func DefaultAPIAddress() string { logrus.Warnf("Failed to get rootless runtime dir for DefaultAPIAddress: %s", err) return DefaultRootAPIAddress } - return "unix:" + filepath.Join(xdg, "podman", "podman.sock") + return "unix://" + filepath.Join(xdg, "podman", "podman.sock") } return DefaultRootAPIAddress } diff --git a/cmd/podman/system/service.go b/cmd/podman/system/service.go index 53572234a87a..c2b017e8b3d0 100644 --- a/cmd/podman/system/service.go +++ b/cmd/podman/system/service.go @@ -140,7 +140,7 @@ func resolveAPIURI(uri []string) (string, error) { if err := os.MkdirAll(filepath.Dir(socketPath), 0700); err != nil { return "", err } - return "unix:" + socketPath, nil + return "unix://" + socketPath, nil default: if err := os.MkdirAll(filepath.Dir(registry.DefaultRootAPIPath), 0700); err != nil { return "", err diff --git a/cmd/podman/system/service_abi.go b/cmd/podman/system/service_abi.go index 6c2d9bf44b44..50bf809c3d40 100644 --- a/cmd/podman/system/service_abi.go +++ b/cmd/podman/system/service_abi.go @@ -97,7 +97,7 @@ func restService(flags *pflag.FlagSet, cfg *entities.PodmanConfig, opts entities return fmt.Errorf("unable to create socket %v: %w", host, err) } default: - return fmt.Errorf("API Service endpoint scheme %q is not supported. Try tcp://%s or unix:/%s", uri.Scheme, opts.URI, opts.URI) + return fmt.Errorf("API Service endpoint scheme %q is not supported. Try tcp://%s or unix://%s", uri.Scheme, opts.URI, opts.URI) } libpodRuntime.SetRemoteURI(uri.String()) } diff --git a/hack/podman-socat b/hack/podman-socat index 28fbb6864c2e..ec5a57bc2229 100755 --- a/hack/podman-socat +++ b/hack/podman-socat @@ -107,16 +107,16 @@ PODMAN_HOST="${TMPDIR}/podman/podman-socat.sock" SOCAT_HOST="${TMPDIR}/podman/podman.sock" cat <<-EOT -Podman service running at unix:$SOCAT_HOST +Podman service running at unix://$SOCAT_HOST See /tmp/podman-socat.log for API stream capture See /tmp/podman-service.log for service logging -usage: sudo bin/podman-remote --url unix:$SOCAT_HOST images +usage: sudo bin/podman-remote --url unix://$SOCAT_HOST images ^C to exit EOT -$PODMAN system service --timeout=0 "unix:$PODMAN_HOST" >/tmp/podman-service.log 2>&1 & +$PODMAN system service --timeout=0 "unix://$PODMAN_HOST" >/tmp/podman-service.log 2>&1 & REAP_PIDS=$! socat -v "UNIX-LISTEN:$SOCAT_HOST",fork,reuseaddr,unlink-early "UNIX-CONNECT:$PODMAN_HOST" >/tmp/podman-socat.log 2>&1 diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go index b19d5bb06d43..4c13a45407e5 100644 --- a/test/e2e/common_test.go +++ b/test/e2e/common_test.go @@ -366,7 +366,7 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration { if err == nil { lockFile.Close() p.RemoteSocketLock = lockPath - p.RemoteSocket = fmt.Sprintf("unix:%s-%s.sock", pathPrefix, uuid) + p.RemoteSocket = fmt.Sprintf("unix://%s-%s.sock", pathPrefix, uuid) break } tries++ diff --git a/test/system/251-system-service.bats b/test/system/251-system-service.bats index 4ad2cd031127..6048ed5353d0 100644 --- a/test/system/251-system-service.bats +++ b/test/system/251-system-service.bats @@ -18,10 +18,24 @@ function teardown() { @test "podman system service returns error" { skip_if_remote "podman system service unavailable over remote" run_podman 125 system service localhost:9292 - is "$output" "Error: API Service endpoint scheme \"localhost\" is not supported. Try tcp://localhost:9292 or unix:/localhost:9292" + is "$output" "Error: API Service endpoint scheme \"localhost\" is not supported. Try tcp://localhost:9292 or unix://localhost:9292" run_podman 125 system service myunix.sock - is "$output" "Error: API Service endpoint scheme \"\" is not supported. Try tcp://myunix.sock or unix:/myunix.sock" + is "$output" "Error: API Service endpoint scheme \"\" is not supported. Try tcp://myunix.sock or unix://myunix.sock" +} + +@test "podman system service unix: without two slashes still works" { + skip_if_remote "podman system service unavailable over remote" + URL=unix:$PODMAN_TMPDIR/myunix.sock + + systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0 + wait_for_file $PODMAN_TMPDIR/myunix.sock + + run_podman --host $URL info --format '{{.Host.RemoteSocket.Path}}' + is "$output" "$URL" "RemoteSocket.Path using unix:" + + systemctl stop $SERVICE_NAME + rm -f $PODMAN_TMPDIR/myunix.sock } @test "podman-system-service containers survive service stop" {