Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/bootstrap/app_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ func (app *BootstrapApp) Setup() error {
}

tlog.App.Info().Msgf("Starting server on unix socket %s", app.config.Server.SocketPath)
go func() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think umask would be the more correct approach here, rather than chmod.

// Ensure processes running as a different user can access the socket.
if err := os.Chmod(app.config.Server.SocketPath, 0770); err != nil {
tlog.App.Fatal().Err(err).Msg("Failed to update UNIX socket permissions")
}
}()
Comment on lines +218 to +223
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Apply the chmod after the socket is bound, not in a fire-and-forget goroutine.

os.Chmod can run before router.RunUnix(...) creates the socket, which makes startup nondeterministic: the goroutine may hit ENOENT and fatal the process even on a healthy boot. It also leaves a window where the socket still has the old permissions.

Please move the permission update into the unix-socket startup path so it runs once the socket exists and before connections are accepted.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/bootstrap/app_bootstrap.go` around lines 218 - 223, The os.Chmod
call for app.config.Server.SocketPath must be moved out of the fire-and-forget
goroutine and executed immediately after the UNIX socket is created in the
unix-socket startup path (i.e., after router.RunUnix(...) or the call that
binds/creates the socket) so it runs deterministically once the socket exists
and before accepting connections; remove the goroutine, call
os.Chmod(app.config.Server.SocketPath, 0770) right after the successful bind in
the same control flow, and keep the current error handling (use
tlog.App.Fatal().Err(err).Msg(...)) if Chmod fails so startup fails fast on
permission issues.

if err := router.RunUnix(app.config.Server.SocketPath); err != nil {
tlog.App.Fatal().Err(err).Msg("Failed to start server")
}
Expand Down