1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
From: Andreas Henriksson <andreas@fatal.se>
Date: Wed, 30 Jan 2019 22:14:56 +0100
Subject: Use full path for tools found in /sbin
This hopefully fixes the failing autopkgtest and should also
help users which doesn't have /sbin in their PATH when using the
affected mender-artifact sub-commands.
This should be considered a workaround, until upstream has a proper
solution. See: https://tracker.mender.io/browse/MEN-2180
---
cli/mender-artifact/artifacts.go | 4 ++--
cli/mender-artifact/copy_test.go | 4 ++--
cli/mender-artifact/debugfs.go | 6 +++---
cli/mender-artifact/partition.go | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/cli/mender-artifact/artifacts.go b/cli/mender-artifact/artifacts.go
index fff5fe8..cb6a836 100644
--- a/cli/mender-artifact/artifacts.go
+++ b/cli/mender-artifact/artifacts.go
@@ -257,9 +257,9 @@ func repackArtifact(artifact, rootfs, key, newName string) error {
}
func processSdimg(image string) ([]partition, error) {
- out, err := exec.Command("parted", image, "unit s", "print").Output()
+ out, err := exec.Command("/sbin/parted", image, "unit s", "print").Output()
if err != nil {
- return nil, errors.Wrap(err, "can not execute `parted` command or image is broken; "+
+ return nil, errors.Wrap(err, "can not execute `/sbin/parted` command or image is broken; "+
"make sure parted is available in your system and is in the $PATH")
}
diff --git a/cli/mender-artifact/copy_test.go b/cli/mender-artifact/copy_test.go
index 51d1857..3a118e2 100644
--- a/cli/mender-artifact/copy_test.go
+++ b/cli/mender-artifact/copy_test.go
@@ -244,13 +244,13 @@ func TestCopy(t *testing.T) {
switch pf.(type) {
case *artifactExtFile:
imgpath := pf.(*artifactExtFile).path
- cmd := exec.Command("debugfs", "-R", "stat /etc/mender/testkey.key", imgpath)
+ cmd := exec.Command("/sbin/debugfs", "-R", "stat /etc/mender/testkey.key", imgpath)
out, err := cmd.CombinedOutput()
require.Nil(t, err)
require.True(t, strings.Contains(string(out), "Mode: 0600"))
case sdimgFile:
imgpath := pf.(sdimgFile)[0].(*extFile).path
- cmd := exec.Command("debugfs", "-R", "stat /etc/mender/testkey.key", imgpath)
+ cmd := exec.Command("/sbin/debugfs", "-R", "stat /etc/mender/testkey.key", imgpath)
out, err := cmd.CombinedOutput()
require.Nil(t, err)
require.True(t, strings.Contains(string(out), "Mode: 0600"))
diff --git a/cli/mender-artifact/debugfs.go b/cli/mender-artifact/debugfs.go
index c9ce15e..5400285 100644
--- a/cli/mender-artifact/debugfs.go
+++ b/cli/mender-artifact/debugfs.go
@@ -39,7 +39,7 @@ import (
// 32 Checking canceled by user request
// 128 Shared-library error
func debugfsRunFsck(image string) error {
- cmd := exec.Command("fsck.ext4", "-a", image)
+ cmd := exec.Command("/sbin/fsck.ext4", "-a", image)
if err := cmd.Run(); err != nil {
// try to get the exit code
if exitError, ok := err.(*exec.ExitError); ok {
@@ -62,7 +62,7 @@ func debugfsCopyFile(file, image string) (string, error) {
dumpCmd := fmt.Sprintf("dump %s %s", file,
filepath.Join(tmpDir, filepath.Base(file)))
- cmd := exec.Command("debugfs", "-R", dumpCmd, image)
+ cmd := exec.Command("/sbin/debugfs", "-R", dumpCmd, image)
ep, err := cmd.StderrPipe()
if err != nil {
return "", errors.Wrap(err, "failed to open stderr pipe of command")
@@ -125,7 +125,7 @@ func executeCommand(cmdstr, image string) error {
if err = scr.Close(); err != nil {
return errors.Wrap(err, "debugfs: close sync script")
}
- cmd := exec.Command("debugfs", "-w", "-f", scr.Name(), image)
+ cmd := exec.Command("/sbin/debugfs", "-w", "-f", scr.Name(), image)
ep, _ := cmd.StderrPipe()
if err = cmd.Start(); err != nil {
return errors.Wrap(err, "debugfs: run debugfs script")
diff --git a/cli/mender-artifact/partition.go b/cli/mender-artifact/partition.go
index 3b422e1..ecf3767 100644
--- a/cli/mender-artifact/partition.go
+++ b/cli/mender-artifact/partition.go
@@ -172,11 +172,11 @@ const (
// imgFilesystemtype returns the filesystem type of a partition.
// Currently only distinguishes ext from fat.
func imgFilesystemType(imgpath string) (int, error) {
- cmd := exec.Command("blkid", "-s", "TYPE", imgpath)
+ cmd := exec.Command("/sbin/blkid", "-s", "TYPE", imgpath)
buf := bytes.NewBuffer(nil)
cmd.Stdout = buf
if err := cmd.Run(); err != nil {
- return unsupported, errors.Wrap(err, "imgFilesystemType: blkid command failed")
+ return unsupported, errors.Wrap(err, "imgFilesystemType: /sbin/blkid command failed")
}
if strings.Contains(buf.String(), `TYPE="vfat"`) {
return fat, nil
|