drivers: set world-readable permissions on copied resolv.conf (#11856)
When we copy the system DNS to a task's `resolv.conf`, we should set the permissions as world-readable so that unprivileged users within the task can read it.
This commit is contained in:
parent
c2412a890d
commit
73d0779858
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
drivers: Fixed a bug where the `resolv.conf` copied from the system was not readable to unprivileged processes within the task
|
||||
```
|
|
@ -69,15 +69,10 @@ func copySystemDNS(dest string) error {
|
|||
}
|
||||
defer in.Close()
|
||||
|
||||
out, err := os.Create(dest)
|
||||
content, err := io.ReadAll(in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
out.Sync()
|
||||
out.Close()
|
||||
}()
|
||||
|
||||
_, err = io.Copy(out, in)
|
||||
return err
|
||||
return os.WriteFile(dest, content, 0644)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue