diff --git a/util/util.go b/util/util.go index 9fbdf9e..a7075b4 100644 --- a/util/util.go +++ b/util/util.go @@ -5,7 +5,6 @@ import ( "os" "path/filepath" - "github.com/bitfield/script" "github.com/go-errors/errors" "golang.org/x/text/cases" "golang.org/x/text/language" @@ -104,17 +103,14 @@ func ReadCredentialFile(uuid string, dirs []string) (string, error) { return string(keyText), nil } +// This has to be refactored at some point... func isPgpEncrypted(path string) (bool, error) { - output, err := RunCommand("file", nil, path) - if err != nil { - return false, errors.Wrap(err, 0) - } - l, err := script.Echo(string(output)).Match("PGP").Match("encrypted").CountLines() - return l > 0, err + _, err := RunCommand("gpg2", nil, "--list-only", "--list-packets", path) + return err == nil, nil } func readPgpEncryptedFile(path string) ([]byte, error) { - output, err := RunCommand("gpg", nil, "--decrypt", path) + output, err := RunCommand("gpg2", nil, "--decrypt", path) if err != nil { return nil, errors.WrapPrefix(err, fmt.Sprintf("failed to read pgp encrypted file %q", path), 0) } diff --git a/zfs/zfs.go b/zfs/zfs.go index 77ade1e..f1c0c4d 100644 --- a/zfs/zfs.go +++ b/zfs/zfs.go @@ -75,10 +75,10 @@ func (d *Dataset) loadPermissions() error { return errors.WrapPrefix(err, fmt.Sprintf("cannot obtain permission list for zfs dataset %s", d.Name), 0) } pattern := regexp.MustCompile(`^\s*user ` + currentUser.Username + ` ([\w-]+(,[\w-]+)*)$`) - script.Echo(string(output)).FilterLine(func(line string) string { + _ = script.Echo(string(output)).FilterLine(func(line string) string { match := pattern.FindStringSubmatch(line) if match != nil { - for _, perm := range strings.Split(match[1], ",") { + for perm := range strings.SplitSeq(match[1], ",") { switch perm { case "mount": permissions.Mount = true