Use url with scheme and path for the unix address

Shortcuts like unix:path and unix:/path do not work everywhere,
so make sure to use unix://path when quoting the url (or address)

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
This commit is contained in:
Anders F Björklund 2023-09-11 07:54:13 +02:00
parent 8acd66c115
commit 336055fe3b
7 changed files with 12 additions and 12 deletions

View File

@ -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\

View File

@ -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
}

View File

@ -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

View File

@ -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())
}

View File

@ -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

View File

@ -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++

View File

@ -18,10 +18,10 @@ function teardown() {
@test "podman system service <bad_scheme_uri> 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 containers survive service stop" {