Skip to content

Commit

Permalink
testramfs: set umask to 0, restore it on exit
Browse files Browse the repository at this point in the history
testramfs needs a umask of 0, not whatever the user set.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
  • Loading branch information
rminnich authored and rjoleary committed Aug 8, 2018
1 parent 5d30eed commit d1c4dc3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/testramfs/testramfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"syscall"

flag "github.com/spf13/pflag"
"golang.org/x/sys/unix"

"github.com/u-root/u-root/pkg/cpio"
"github.com/u-root/u-root/pkg/pty"
Expand Down Expand Up @@ -57,6 +58,13 @@ func main() {
// - new PID namespace
// - archive/init actually runs as PID 1.

// Note this is basically a chroot and umask is inherited.
// The umask has to be zero else some creation will end
// up with incorrect permissions, a particular problem
// in device creation.
u := unix.Umask(0)
defer unix.Umask(u)

tempDir, err := ioutil.TempDir("", "u-root")
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit d1c4dc3

Please sign in to comment.