[PATCH v1] wg-quick: allow to switch sudo implementation with $SUDO

Daniel Gröber dxld at darkboxed.org
Sun Apr 6 09:52:45 UTC 2025


Hi Achill,

I forgot to mention on IRC you should still try to keep Jason and the main
ML in CC, just in case it happens to be working today.

On Sat, Apr 05, 2025 at 11:00:50PM +0200, Achill Gilgenast wrote:
> Some distributions like Alpine Linux or Chimera Linux ship other
> privilege escalation helpers like doas by default, instead of sudo.
> 
> We're shipping the patch since Dec 2024 in Alpine Linux and had no
> issues noticed.
> 
> Signed-off-by: Achill Gilgenast <fossdd at pwned.life>
> ---
>  src/wg-quick/linux.bash | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/wg-quick/linux.bash b/src/wg-quick/linux.bash
> index 4193ce5..7795c0b 100755
> --- a/src/wg-quick/linux.bash
> +++ b/src/wg-quick/linux.bash
> @@ -82,7 +82,7 @@ read_bool() {
>  }
>  
>  auto_su() {
> -	[[ $UID == 0 ]] || exec sudo -p "$PROGRAM must be run as root. Please enter the password for %u to continue: " -- "$BASH" -- "$SELF" "${ARGS[@]}"
> +	[[ $UID == 0 ]] || exec "${SUDO:-sudo}" "$BASH" -- "$SELF" "${ARGS[@]}"

Who sets $SUDO in your setup?

Have you considered runtime probing for available "sudo" impls. using, say
`command -v`, with a pre-defined priority order instead? Seems more
supportable.

What other programs have already adopted $SUDO already?
Eg. sources.debian.org has a large corpous.

Either way this should really be extended to all shell based
implementations (linux, darwin, freebsd).

>  }
>  
>  add_if() {
> 
> base-commit: 13f4ac4cb74b5a833fa7f825ba785b1e5774e84f
> -- 
> 2.49.0


More information about the WireGuard mailing list