From 80bd507ccd13434ae2f6d5b6b6e0228f8eab3d6e Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 05 Apr 2025 23:02:02 +0800 Subject: [PATCH] Hooks: Fix for non-Linux systems --- git_hooks_handle_other.go | 11 +++++++---- diff --git a/git_hooks_handle_other.go b/git_hooks_handle_other.go index f125ecbf556dde1bb3a0f59e0df0edd971f78512..6fe6d9ef26c06d7f123cc1be3870a5f5acc1ca82 100644 --- a/git_hooks_handle_other.go +++ b/git_hooks_handle_other.go @@ -25,11 +25,14 @@ "go.lindenii.runxiyu.org/forge/internal/ansiec" "go.lindenii.runxiyu.org/forge/internal/misc" ) -var errGetFD = errors.New("unable to get file descriptor") +var ( + errGetFD = errors.New("unable to get file descriptor") + errGetUcred = errors.New("failed getsockopt") +) // hooksHandler handles a connection from hookc via the // unix socket. -func (s *server) hooksHandler(conn net.Conn) { +func (s *Server) hooksHandler(conn net.Conn) { var ctx context.Context var cancel context.CancelFunc var err error @@ -42,7 +45,7 @@ defer conn.Close() ctx, cancel = context.WithCancel(context.Background()) defer cancel() - // TODO: Validate that the connection is from the right user. + // TODO: ucred-like checks cookie = make([]byte, 64) if _, err = conn.Read(cookie); err != nil { @@ -320,7 +323,7 @@ // serveGitHooks handles connections on the specified network listener and // treats incoming connections as those from git hook handlers by spawning // sessions. The listener must be a SOCK_STREAM UNIX domain socket. The // function itself blocks. -func (s *server) serveGitHooks(listener net.Listener) error { +func (s *Server) serveGitHooks(listener net.Listener) error { for { conn, err := listener.Accept() if err != nil { -- 2.48.1