Skip to content

Commit

Permalink
wait for admin goroutine regardless of -user
Browse files Browse the repository at this point in the history
If configured, always wait for the control socket to be created before
potentially dropping to a different user.

Another pending patch of mine using pledge(2) to drop privileges and
thus also depends on this sync mechanism, so reduce diff churn.
  • Loading branch information
klemensn committed Nov 3, 2024
1 parent 6ae62f0 commit 2e1b896
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmd/yggdrasil/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,13 @@ func main() {
<-done
})

// Wait for other goroutines to finish potentially privileged tasks before dropping privileges.
if n.admin != nil {
n.admin.Created.Wait()
}

// Change user if requested
if *chuserto != "" {
// Wait for other goroutines to finish potentially privileged tasks before dropping privileges.
if n.admin != nil {
// control socket: UNIX requires filesystem permissions, TCP may use a low privileged port.
n.admin.Created.Wait()
}

err = chuser(*chuserto)
if err != nil {
panic(err)
Expand Down

0 comments on commit 2e1b896

Please sign in to comment.