make binaries cope with Squashfs root

This commit is contained in:
Michael Stapelberg 2018-06-22 17:59:23 +02:00
parent 5e11eae951
commit 37bf17e1b7
4 changed files with 9 additions and 5 deletions

View File

@ -58,7 +58,7 @@ func logic() error {
if err := ioutil.WriteFile(ackFn, c.Ack, 0644); err != nil {
return fmt.Errorf("persisting DHCPACK to %s: %v", ackFn, err)
}
if err := notify.Process("/user/netconfi", syscall.SIGUSR1); err != nil {
if err := notify.Process("/user/netconfigd", syscall.SIGUSR1); err != nil {
log.Printf("notifying netconfig: %v", err)
}
select {

View File

@ -51,7 +51,7 @@ func logic() error {
if err := ioutil.WriteFile(configPath, b, 0644); err != nil {
return err
}
if err := notify.Process("/user/netconfi", syscall.SIGUSR1); err != nil {
if err := notify.Process("/user/netconfigd", syscall.SIGUSR1); err != nil {
log.Printf("notifying netconfig: %v", err)
}
if err := notify.Process("/user/radvd", syscall.SIGUSR1); err != nil {

View File

@ -108,6 +108,10 @@ func TestNetconfig(t *testing.T) {
t.Fatal(err)
}
if err := os.MkdirAll(filepath.Join(tmp, "root", "tmp"), 0755); err != nil {
t.Fatal(err)
}
if err := netconfig.Apply(tmp, filepath.Join(tmp, "root")); err != nil {
t.Fatalf("netconfig.Apply: %v", err)
}
@ -119,12 +123,12 @@ func TestNetconfig(t *testing.T) {
t.Fatalf("netconfig.Apply: %v", err)
}
b, err := ioutil.ReadFile(filepath.Join(tmp, "root", "etc", "resolv.conf"))
b, err := ioutil.ReadFile(filepath.Join(tmp, "root", "tmp", "resolv.conf"))
if err != nil {
t.Fatal(err)
}
if got, want := strings.TrimSpace(string(b)), "nameserver 192.168.42.1"; got != want {
t.Errorf("/etc/resolv.conf: got %q, want %q", got, want)
t.Errorf("/tmp/resolv.conf: got %q, want %q", got, want)
}
return

View File

@ -257,7 +257,7 @@ func applyInterfaces(dir, root string) error {
if details.Name == "lan0" {
b := []byte("nameserver " + addr.IP.String() + "\n")
fn := filepath.Join(root, "etc", "resolv.conf")
fn := filepath.Join(root, "tmp", "resolv.conf")
if err := os.Remove(fn); err != nil && !os.IsNotExist(err) {
return err
}