Skip to content

Commit

Permalink
fix: unix socket listener may fail when path name is too long
Browse files Browse the repository at this point in the history
  • Loading branch information
jm33-m0 committed Dec 25, 2024
1 parent 9383321 commit d7c0e98
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/cmd/agent/util_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ func socketListen() {
log.Fatalf("Failed to delete socket: %v", err)
}
}
cwd, err := os.Getwd()
if err != nil {
log.Fatalf("Failed to get current working directory: %v", err)
}
os.Chdir(agent.RuntimeConfig.AgentRoot)
defer os.Chdir(cwd)

l, err := net.Listen("unix", agent.RuntimeConfig.SocketName)
// use basename to make sure the socket path is not too long (107), otherwise it will fail
l, err := net.Listen("unix", util.FileBaseName(agent.RuntimeConfig.SocketName))
if err != nil {
log.Fatalf("listen error: %v", err)
}
Expand Down

0 comments on commit d7c0e98

Please sign in to comment.