func writeEtcHosts() error {
	newEtcHosts, err := generateEtcHosts()
	if err != nil {
		return err
	}
	_ = os.Remove("/etc/hosts")
	if err := os.WriteFile("/etc/hosts", newEtcHosts, 0644); err != nil {
		return fmt.Errorf("writing /etc/hosts: %w", err)
	}
	return nil
}
writeEtcHosts is akin to writeResolvConf
TODO: dedupe
package child
import (
	"fmt"
	"os"
	"path/filepath"
	"golang.org/x/sys/unix"
)
func generateEtcHosts() ([]byte, error) {
	etcHosts, err := os.ReadFile("/etc/hosts")
	if err != nil {
		return nil, err
	}
	hostname, err := os.Hostname()
	if err != nil {
		return nil, err
	}
	s := fmt.Sprintf("%s\n127.0.0.1 %s\n::1 %s\n",
		string(etcHosts), hostname, hostname)
	return []byte(s), nil
}