-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fsverity: introduce EnableVerifyError::FilesystemNotSupported error #68
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
Can you also add some .context()
at the spot where we enable fs-verity from Repository
? Maybe mentioning the repository path (or even complete path to the object file) would be helpful as well, at that point.
/// Enabling fsverity failed. | ||
#[derive(Error, Debug, PartialEq)] | ||
pub enum EnableVerifyError { | ||
#[error("Filesystem not supported by fs-verity")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd describe the situation with slightly different language: the filesystem doesn't support fs-verity. The enablement code is in the filesystem, not in fs-verity.
@@ -35,12 +44,16 @@ pub struct FsVerityEnableArg { | |||
// #define FS_IOC_ENABLE_VERITY _IOW('f', 133, struct fsverity_enable_arg) | |||
type FsIocEnableVerity = ioctl::WriteOpcode<b'f', 133, FsVerityEnableArg>; | |||
|
|||
// ENOTTY 25 Inappropriate ioctl for device | |||
// XXX: should we use an errno crate instead? | |||
static ENOTTY: i32 = 25; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we missing that in rustix::io::Errno
?
https://docs.rs/rustix/latest/rustix/io/struct.Errno.html#associatedconstant.NOTTY
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense, I removed this, I did missed this :/
@@ -53,7 +66,13 @@ pub fn fs_ioc_enable_verity<F: AsFd, H: FsVerityHashValue>(fd: F) -> std::io::Re | |||
sig_ptr: 0, | |||
__reserved2: [0; 11], | |||
}), | |||
)?; | |||
) { | |||
Err(e) if e.raw_os_error() == ENOTTY => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible to match directly on Err(rustix::io::Errno::ENOTTY)
here, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, silly me! Thanks and I simplified this now as suggested.
@@ -17,6 +17,15 @@ pub enum MeasureVerityError { | |||
InvalidDigestSize { expected: u16 }, | |||
} | |||
|
|||
/// Enabling fsverity failed. | |||
#[derive(Error, Debug, PartialEq)] | |||
pub enum EnableVerifyError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this might be a bit short-sighted. Currently this is no problem because it gets smoothed out by anyhow, but in the future if we want to start reporting errors from high-level operations on the repository, maybe we want some unified error type for that?
On the other hand, we already have MeasureVerityError and we can chain those things via #from
in the unified error type, I suppose.
Also: we never said we won't break API, anyway!
ede9fb9
to
5d04f74
Compare
This commit improves the UX of the error reporting when enabling fs-verity fails because the underlying filesystem does not support this. Here we currently just error with: ``` Inappropriate ioctl for device" ``` with the new code we error with: ``` Filesystem not supported by fs-verity ``` Note that the test relies on the fact that /dev/shm is not supported by fs-verity. Closes: containers#59 Signed-off-by: Michael Vogt <[email protected]>
5d04f74
to
ccfc88e
Compare
This commit improves the UX of the error reporting when enabling fs-verity fails because the underlying filesystem does not support this. Here we currently just error with:
with the new code we error with:
Note that the test relies on the fact that /dev/shm is not supported by fs-verity.
Closes: #59