Skip to content

Commit

Permalink
osutil/mkfs: Expose more fakeroot flags
Browse files Browse the repository at this point in the history
  • Loading branch information
jawn-smith committed Jan 28, 2022
1 parent 67c83f7 commit 7014cd1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions osutil/mkfs/mkfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/snapcore/snapd/gadget/quantity"
"github.com/snapcore/snapd/osutil"
Expand Down Expand Up @@ -106,11 +107,12 @@ 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...)
fakerootArgs := append(strings.Split(fakerootFlags, " "), "--")
mkfsArgs = append(fakerootArgs, mkfsArgs...)
}
cmd = exec.Command("fakeroot", mkfsArgs...)
} else {
Expand Down

0 comments on commit 7014cd1

Please sign in to comment.