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:
Tim Gross
2022-01-14 12:25:23 -05:00
committed by GitHub
parent 8f01d74f70
commit 77287b0bfc
2 changed files with 5 additions and 7 deletions

3
.changelog/11856.txt Normal file
View File

@@ -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
```

View File

@@ -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)
}