diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-20 16:17:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-20 16:17:42 -0400 |
commit | 37365b166d30d7da108d4ce79a76bbae787e4219 (patch) | |
tree | cb534f24aa7ff1204a6b431d143d264ec4957d6b /cmd/podman | |
parent | 354088a94b5dbbf2c4bf3315077fd89d98faebb5 (diff) | |
parent | 405e39b0d67947bd459d6d63555fb5f0e55e7a4e (diff) | |
download | podman-37365b166d30d7da108d4ce79a76bbae787e4219.tar.gz podman-37365b166d30d7da108d4ce79a76bbae787e4219.tar.bz2 podman-37365b166d30d7da108d4ce79a76bbae787e4219.zip |
Merge pull request #5901 from jwhonce/wip/service
V2 Remove existing unix domain socket on startup
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/system/service.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cmd/podman/system/service.go b/cmd/podman/system/service.go index 6522a45f8..e09107b53 100644 --- a/cmd/podman/system/service.go +++ b/cmd/podman/system/service.go @@ -2,8 +2,10 @@ package system import ( "fmt" + "net/url" "os" "path/filepath" + "syscall" "time" "github.com/containers/libpod/cmd/podman/registry" @@ -59,6 +61,23 @@ func service(cmd *cobra.Command, args []string) error { } logrus.Infof("using API endpoint: '%s'", apiURI) + // Clean up any old existing unix domain socket + if len(apiURI) > 0 { + uri, err := url.Parse(apiURI) + if err != nil { + return err + } + + // socket activation uses a unix:// socket in the shipped unit files but apiURI is coded as "" at this layer. + if "unix" == uri.Scheme && !registry.IsRemote() { + if err := syscall.Unlink(uri.Path); err != nil && !os.IsNotExist(err) { + return err + } + mask := syscall.Umask(0177) + defer syscall.Umask(mask) + } + } + opts := entities.ServiceOptions{ URI: apiURI, Timeout: time.Duration(srvArgs.Timeout) * time.Second, |