Skip to content

Commit

Permalink
Merge pull request #11320 from GlenPickle/master
Browse files Browse the repository at this point in the history
osutil/mkfs: Expose more fakeroot flags
  • Loading branch information
mvo5 authored Feb 7, 2022
2 parents a2169a4 + 9242b0b commit 05eadd8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions osutil/mkfs/mkfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/snapcore/snapd/gadget/quantity"
"github.com/snapcore/snapd/osutil"
"github.com/snapcore/snapd/strutil/shlex"
)

// MakeFunc defines a function signature that is used by all of the mkfs.<filesystem>
Expand Down Expand Up @@ -106,11 +107,18 @@ func mkfsExt4(img, label, contentsRootDir string, deviceSize, sectorSize quantit
var cmd *exec.Cmd
if os.Geteuid() != 0 {
// run through fakeroot so that files are owned by root
fakerootLib := os.Getenv("FAKEROOT_LIB")
if fakerootLib != "" {
fakerootFlags := os.Getenv("FAKEROOT_FLAGS")
if fakerootFlags != "" {
// When executing fakeroot from a classic confinement snap the location of
// libfakeroot must be specified, or else it will be loaded from the host system
mkfsArgs = append([]string{"--lib", fakerootLib, "--"}, mkfsArgs...)
flags, err := shlex.Split(fakerootFlags)
if err != nil {
return fmt.Errorf("cannot split fakeroot command: %v", err)
}
if len(fakerootFlags) > 0 {
fakerootArgs := append(flags, "--")
mkfsArgs = append(fakerootArgs, mkfsArgs...)
}
}
cmd = exec.Command("fakeroot", mkfsArgs...)
} else {
Expand Down

0 comments on commit 05eadd8

Please sign in to comment.