Skip to content

Commit

Permalink
Use strutil.shlex rather than strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jawn-smith committed Jan 31, 2022
1 parent 7014cd1 commit 9242b0b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions osutil/mkfs/mkfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import (
"os"
"os/exec"
"path/filepath"
"strings"

"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 @@ -111,8 +111,14 @@ func mkfsExt4(img, label, contentsRootDir string, deviceSize, sectorSize quantit
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
fakerootArgs := append(strings.Split(fakerootFlags, " "), "--")
mkfsArgs = append(fakerootArgs, 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 9242b0b

Please sign in to comment.