tun: OpenBSD: remove ifconfig fallback

Start by deleting stuff we will not need or want in the end.
This also seems to be the only code doing execve(2), which is best
to be prevented from ever being called via pledge(2), but that is another
story (I am already running yggdrasil with pledge(2) and unveil(2)).
This commit is contained in:
Klemens Nanni 2024-09-29 23:21:11 +03:00
parent 2c7e7be036
commit 32b4c58f74
No known key found for this signature in database

View file

@ -6,7 +6,6 @@ package tun
import ( import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"os/exec"
"strconv" "strconv"
"strings" "strings"
"syscall" "syscall"
@ -96,15 +95,6 @@ func (tun *TunAdapter) setupAddress(addr string) error {
if _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(sfd), uintptr(SIOCSIFADDR_IN6), uintptr(unsafe.Pointer(&ar))); errno != 0 { if _, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(sfd), uintptr(SIOCSIFADDR_IN6), uintptr(unsafe.Pointer(&ar))); errno != 0 {
err = errno err = errno
tun.log.Errorf("Error in SIOCSIFADDR_IN6: %v", errno) tun.log.Errorf("Error in SIOCSIFADDR_IN6: %v", errno)
// Fall back to ifconfig to set the address
cmd := exec.Command("ifconfig", tun.Name(), "inet6", addr)
tun.log.Warnf("Using ifconfig as fallback: %v", strings.Join(cmd.Args, " "))
output, err := cmd.CombinedOutput()
if err != nil {
tun.log.Errorf("SIOCSIFADDR_IN6 fallback failed: %v.", err)
tun.log.Traceln(string(output))
}
} }
return nil return nil