From 40abf968eddd54b6c03ac064d6e42cc6f1083146 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 2 Sep 2024 16:31:23 +0200 Subject: ctlsocksrv: move Listen() call here Prep for solving https://github.com/rfjakob/gocryptfs/issues/776 --- internal/ctlsocksrv/ctlsock_listen.go | 9 +++++++++ mount.go | 8 +++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 internal/ctlsocksrv/ctlsock_listen.go diff --git a/internal/ctlsocksrv/ctlsock_listen.go b/internal/ctlsocksrv/ctlsock_listen.go new file mode 100644 index 0000000..1db9cbc --- /dev/null +++ b/internal/ctlsocksrv/ctlsock_listen.go @@ -0,0 +1,9 @@ +package ctlsocksrv + +import ( + "net" +) + +func Listen(path string) (net.Listener, error) { + return net.Listen("unix", path) +} diff --git a/mount.go b/mount.go index ea0281a..61079a9 100644 --- a/mount.go +++ b/mount.go @@ -5,7 +5,6 @@ import ( "log" "log/syslog" "math" - "net" "os" "os/exec" "os/signal" @@ -91,16 +90,15 @@ func doMount(args *argContainer) { // We must use an absolute path because we cd to / when daemonizing. // This messes up the delete-on-close logic in the unix socket object. args.ctlsock, _ = filepath.Abs(args.ctlsock) - var sock net.Listener - sock, err = net.Listen("unix", args.ctlsock) + + args._ctlsockFd, err = ctlsocksrv.Listen(args.ctlsock) if err != nil { tlog.Fatal.Printf("ctlsock: %v", err) os.Exit(exitcodes.CtlSock) } - args._ctlsockFd = sock // Close also deletes the socket file defer func() { - err = sock.Close() + err = args._ctlsockFd.Close() if err != nil { tlog.Warn.Printf("ctlsock close: %v", err) } -- cgit v1.2.3