aboutsummaryrefslogtreecommitdiff
path: root/keyring/fs_keyring.go
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2020-05-09 15:27:24 -0700
committerGitHub <noreply@github.com>2020-05-09 15:27:24 -0700
commitd4d28232d32bfb3f4827fcb79bd5043e1932ae66 (patch)
treedda5a65b2d8c157e03d3d35f3442547dafd51e4c /keyring/fs_keyring.go
parent1cdefc21b8b07aad7aafeefd05d3124cf93b9216 (diff)
parent181600d6327ed34a3f62eda0dd03a6d2ae49e5f9 (diff)
Merge pull request #219 from ebiggers/improve-errors
Improve error messages and suggestions
Diffstat (limited to 'keyring/fs_keyring.go')
-rw-r--r--keyring/fs_keyring.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/keyring/fs_keyring.go b/keyring/fs_keyring.go
index 262e0e5..9b949b9 100644
--- a/keyring/fs_keyring.go
+++ b/keyring/fs_keyring.go
@@ -203,7 +203,9 @@ func fsAddEncryptionKey(key *crypto.Key, descriptor string,
log.Printf("FS_IOC_ADD_ENCRYPTION_KEY(%q, %s, <raw>) = %v", mount.Path, descriptor, errno)
if errno != 0 {
- return errors.Wrap(ErrKeyAdd, errno.Error())
+ return errors.Wrapf(errno,
+ "error adding key with descriptor %s to filesystem %s",
+ descriptor, mount.Path)
}
if descriptor, err = validateKeyDescriptor(&arg.Key_spec, descriptor); err != nil {
fsRemoveEncryptionKey(descriptor, mount, user)
@@ -266,7 +268,9 @@ func fsRemoveEncryptionKey(descriptor string, mount *filesystem.Mount,
}
return ErrKeyNotPresent
default:
- return errors.Wrap(ErrKeyRemove, errno.Error())
+ return errors.Wrapf(errno,
+ "error removing key with descriptor %s from filesystem %s",
+ descriptor, mount.Path)
}
}
@@ -298,7 +302,10 @@ func fsGetEncryptionKeyStatus(descriptor string, mount *filesystem.Mount,
log.Printf("FS_IOC_GET_ENCRYPTION_KEY_STATUS(%q, %s) = %v, status=%d, status_flags=0x%x",
mount.Path, descriptor, errno, arg.Status, arg.Status_flags)
if errno != 0 {
- return KeyStatusUnknown, errors.Wrap(ErrKeySearch, errno.Error())
+ return KeyStatusUnknown,
+ errors.Wrapf(errno,
+ "error getting status of key with descriptor %s on filesystem %s",
+ descriptor, mount.Path)
}
switch arg.Status {
case unix.FSCRYPT_KEY_STATUS_ABSENT:
@@ -313,6 +320,7 @@ func fsGetEncryptionKeyStatus(descriptor string, mount *filesystem.Mount,
return KeyAbsentButFilesBusy, nil
default:
return KeyStatusUnknown,
- errors.Wrapf(ErrKeySearch, "unknown key status (%d)", arg.Status)
+ errors.Errorf("unknown key status (%d) for key with descriptor %s on filesystem %s",
+ arg.Status, descriptor, mount.Path)
}
}