mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
Create the default root API address path
Fixes #8184 Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
This commit is contained in:
@ -12,8 +12,11 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultRootAPIAddress is the default address of the REST socket
|
// DefaultRootAPIPath is the default path of the REST socket
|
||||||
const DefaultRootAPIAddress = "unix:/run/podman/podman.sock"
|
const DefaultRootAPIPath = "/run/podman/podman.sock"
|
||||||
|
|
||||||
|
// DefaultRootAPIAddress is the default address of the REST socket with unix: prefix
|
||||||
|
const DefaultRootAPIAddress = "unix:" + DefaultRootAPIPath
|
||||||
|
|
||||||
// DefaultVarlinkAddress is the default address of the varlink socket
|
// DefaultVarlinkAddress is the default address of the varlink socket
|
||||||
const DefaultVarlinkAddress = "unix:/run/podman/io.podman"
|
const DefaultVarlinkAddress = "unix:/run/podman/io.podman"
|
||||||
|
@ -131,20 +131,17 @@ func resolveAPIURI(_url []string) (string, error) {
|
|||||||
if srvArgs.Varlink {
|
if srvArgs.Varlink {
|
||||||
socketName = "io.podman"
|
socketName = "io.podman"
|
||||||
}
|
}
|
||||||
socketDir := filepath.Join(xdg, "podman", socketName)
|
socketPath := filepath.Join(xdg, "podman", socketName)
|
||||||
if _, err := os.Stat(filepath.Dir(socketDir)); err != nil {
|
if err := os.MkdirAll(filepath.Dir(socketPath), 0700); err != nil {
|
||||||
if os.IsNotExist(err) {
|
return "", err
|
||||||
if err := os.Mkdir(filepath.Dir(socketDir), 0755); err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return "unix:" + socketDir, nil
|
return "unix:" + socketPath, nil
|
||||||
case srvArgs.Varlink:
|
case srvArgs.Varlink:
|
||||||
return registry.DefaultVarlinkAddress, nil
|
return registry.DefaultVarlinkAddress, nil
|
||||||
default:
|
default:
|
||||||
|
if err := os.MkdirAll(filepath.Dir(registry.DefaultRootAPIPath), 0700); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
return registry.DefaultRootAPIAddress, nil
|
return registry.DefaultRootAPIAddress, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user