Skip to content

Commit

Permalink
drivers: set world-readable permissions on copied resolv.conf (#11856)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tgross authored and lgfa29 committed Jan 17, 2022
1 parent e747045 commit ecca5d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/11856.txt
Original file line number Diff line number Diff line change
@@ -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
```
9 changes: 2 additions & 7 deletions drivers/shared/resolvconf/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit ecca5d7

Please sign in to comment.