You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wait for admin goroutine to create control socket before changing user
Otherwise the main goroutine races dropping privileges races against
those carrying out privileges tasks at startup.
Reproducible at least on OpenBSD/amd64 7.6-current, where it (expectedly)
fails to create a UNIX socket in `0755 root:wheel /var/run/` *after*
calling setuid(2) to `nobody`:
```
# yggdrasil -autoconf -user nobody
2024/11/03 21:15:27 Build name: yggdrasil-go
2024/11/03 21:15:27 Build version: 0.5.9
...
2024/11/03 21:15:27 Admin socket failed to listen: listen unix /var/run/yggdrasil.sock: bind: permission denied
```
Rerun, now the order is flipped:
```
# yggdrasil -autoconf -user nobody
2024/11/03 21:15:34 Build name: yggdrasil-go
2024/11/03 21:15:34 Build version: 0.5.9
[...]
2024/11/03 21:15:34 UNIX admin socket listening on /var/run/yggdrasil.sock
[...]
```
The `AdminSocket`s `done` channel is insufficient to sync here, waiting
for `n.admin.IsStarted()` does not guarantee socket creation, so export
a simple boolean instead.
This is a minimal fix to prevent startup failure; TUN interface and
raw socket creation (to manage routes) might suffer the same problem,
but I have not seem them fail yet.
Fixesyggdrasil-network#927.
0 commit comments