Skip to content

Commit 2e1b896

Browse files
committed
wait for admin goroutine regardless of -user
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.
1 parent 6ae62f0 commit 2e1b896

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

cmd/yggdrasil/main.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,13 @@ func main() {
282282
<-done
283283
})
284284

285+
// Wait for other goroutines to finish potentially privileged tasks before dropping privileges.
286+
if n.admin != nil {
287+
n.admin.Created.Wait()
288+
}
289+
285290
// Change user if requested
286291
if *chuserto != "" {
287-
// Wait for other goroutines to finish potentially privileged tasks before dropping privileges.
288-
if n.admin != nil {
289-
// control socket: UNIX requires filesystem permissions, TCP may use a low privileged port.
290-
n.admin.Created.Wait()
291-
}
292-
293292
err = chuser(*chuserto)
294293
if err != nil {
295294
panic(err)

0 commit comments

Comments
 (0)