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
9 changes: 7 additions & 2 deletions cmd/pilotctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2352,9 +2352,14 @@ func cmdDaemonStart(args []string) {
logFile.Close()
os.Rename(tmpLogPath, pidLogPath)
// Update pilot.log symlink to point at the current PID's log.
// Atomically replace via temp file to avoid TOCTOU race (the
// gap between Remove and Symlink is exploitable by a local
// attacker with write access to the config directory).
symPath := logFilePath()
os.Remove(symPath)
os.Symlink(pidLogPath, symPath)
tmpSymPath := symPath + ".tmp"
os.Remove(tmpSymPath) // clean stale temp from prior crash
os.Symlink(pidLogPath, tmpSymPath)
os.Rename(tmpSymPath, symPath)

if !jsonOutput {
fmt.Fprintf(os.Stderr, "starting daemon (pid %d, socket %s)...", pid, socketPath)
Expand Down
Loading