netconfig: move /tmp/resolv.conf symlink out of the way
Commit 0f75b1cbef6d0ec4853a6a02d96d4b57ce478769 was incomplete.
This commit is contained in:
parent
0f75b1cbef
commit
13e1c1bbb4
@ -441,8 +441,17 @@ func createResolvConfIfMissing(root, contents string) error {
|
|||||||
// Explicitly check for the file's existance
|
// Explicitly check for the file's existance
|
||||||
// just so that we can avoid printing an error
|
// just so that we can avoid printing an error
|
||||||
// in the normal case (file exists).
|
// in the normal case (file exists).
|
||||||
if _, err := os.Stat(fn); err == nil {
|
st, err := os.Lstat(fn)
|
||||||
return nil // file already exists, do not overwrite
|
if err == nil {
|
||||||
|
if st.Mode()&os.ModeSymlink != 0 {
|
||||||
|
// File is a symbolic link (at boot, gokrazy links /tmp/resolv.conf to /proc/net/pnp).
|
||||||
|
// Delete the link and fallthrough to create the file.
|
||||||
|
if err := os.Remove(fn); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil // regular file already exists, do not overwrite
|
||||||
|
}
|
||||||
} else if !os.IsNotExist(err) {
|
} else if !os.IsNotExist(err) {
|
||||||
return err // unexpected error
|
return err // unexpected error
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user