aboutsummaryrefslogtreecommitdiff
path: root/git_hooks_handle_other.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 23:02:02 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 23:02:02 +0800
commit80bd507ccd13434ae2f6d5b6b6e0228f8eab3d6e (patch)
tree6bf5fd8c9ee23bb3c6bbd6bbc6776d0938c1417b /git_hooks_handle_other.go
parentCSS: README line height 1.3 (diff)
downloadforge-80bd507ccd13434ae2f6d5b6b6e0228f8eab3d6e.tar.gz
forge-80bd507ccd13434ae2f6d5b6b6e0228f8eab3d6e.tar.zst
forge-80bd507ccd13434ae2f6d5b6b6e0228f8eab3d6e.zip
Hooks: Fix for non-Linux systems
Diffstat (limited to 'git_hooks_handle_other.go')
-rw-r--r--git_hooks_handle_other.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/git_hooks_handle_other.go b/git_hooks_handle_other.go
index f125ecb..6fe6d9e 100644
--- a/git_hooks_handle_other.go
+++ b/git_hooks_handle_other.go
@@ -25,11 +25,14 @@ import (
"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 @@ func (s *server) hooksHandler(conn net.Conn) {
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 @@ func (s *server) hooksHandler(conn net.Conn) {
// 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 {