From 8715d9a33a8b33ce7951bb3a43aa85ff74754fb8 Mon Sep 17 00:00:00 2001 From: "Kirill A. Korinsky" Date: Thu, 8 Feb 2024 15:29:13 +0100 Subject: [PATCH] Avoid keeping @docker_cli_[UUID] files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seems that OpenBSD behaves like darwin and requires to unlink all socket, after it was used. Tested on OpenBSD 7.4 Signed-off-by: Kirill A. Korinsky (cherry picked from commit 2c214241fa2eb3b44d15d7aad587168d3bd70b48) Signed-off-by: Paweł Gronowski --- cli-plugins/socket/socket_nodarwin.go | 5 +++-- cli-plugins/socket/socket_openbsd.go | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 cli-plugins/socket/socket_openbsd.go diff --git a/cli-plugins/socket/socket_nodarwin.go b/cli-plugins/socket/socket_nodarwin.go index 893e465e4b..aa6065ecb4 100644 --- a/cli-plugins/socket/socket_nodarwin.go +++ b/cli-plugins/socket/socket_nodarwin.go @@ -1,4 +1,4 @@ -//go:build !darwin +//go:build !darwin && !openbsd package socket @@ -15,5 +15,6 @@ func listen(socketname string) (*net.UnixListener, error) { func onAccept(conn *net.UnixConn, listener *net.UnixListener) { // do nothing - // while on darwin we would unlink here; on non-darwin the socket is abstract and not present on the filesystem + // while on darwin and OpenBSD we would unlink here; + // on non-darwin the socket is abstract and not present on the filesystem } diff --git a/cli-plugins/socket/socket_openbsd.go b/cli-plugins/socket/socket_openbsd.go new file mode 100644 index 0000000000..17ab6aa69e --- /dev/null +++ b/cli-plugins/socket/socket_openbsd.go @@ -0,0 +1,19 @@ +package socket + +import ( + "net" + "os" + "path/filepath" + "syscall" +) + +func listen(socketname string) (*net.UnixListener, error) { + return net.ListenUnix("unix", &net.UnixAddr{ + Name: filepath.Join(os.TempDir(), socketname), + Net: "unix", + }) +} + +func onAccept(conn *net.UnixConn, listener *net.UnixListener) { + syscall.Unlink(listener.Addr().String()) +}