Skip to content

Commit

Permalink
drivers: set world-readable permissions on copied resolv.conf
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 committed Jan 14, 2022
1 parent 8f01d74 commit 50c4d4e
Showing 1 changed file with 2 additions and 7 deletions.
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 50c4d4e

Please sign in to comment.