rustjail: Wrap remaining nix errors with anyhow

Replace `Result` values that use a "bare" `nix` `Error` like this:

```rust
return Err(nix::Error::EINVAL.into());
```

... to the following which wraps the nix` error in an `anyhow` call for
consistency with the other errors returned by `rustjail`:

```rust
return Err(anyhow!(nix::Error::EINVAL));
```

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2021-11-30 13:24:04 +00:00
parent 30d6007893
commit aba572e01d
3 changed files with 5 additions and 5 deletions

View File

@ -174,7 +174,7 @@ impl CgroupManager for Manager {
freezer_controller.freeze()?;
}
_ => {
return Err(nix::Error::EINVAL.into());
return Err(anyhow!(nix::Error::EINVAL));
}
}

View File

@ -1388,13 +1388,13 @@ impl LinuxContainer {
.context(format!("cannot change onwer of container {} root", id))?;
if config.spec.is_none() {
return Err(nix::Error::EINVAL.into());
return Err(anyhow!(nix::Error::EINVAL));
}
let spec = config.spec.as_ref().unwrap();
if spec.linux.is_none() {
return Err(nix::Error::EINVAL.into());
return Err(anyhow!(nix::Error::EINVAL));
}
let linux = spec.linux.as_ref().unwrap();

View File

@ -999,7 +999,7 @@ pub fn finish_rootfs(cfd_log: RawFd, spec: &Spec, process: &Process) -> Result<(
fn mask_path(path: &str) -> Result<()> {
if !path.starts_with('/') || path.contains("..") {
return Err(nix::Error::EINVAL.into());
return Err(anyhow!(nix::Error::EINVAL));
}
match mount(
@ -1019,7 +1019,7 @@ fn mask_path(path: &str) -> Result<()> {
fn readonly_path(path: &str) -> Result<()> {
if !path.starts_with('/') || path.contains("..") {
return Err(nix::Error::EINVAL.into());
return Err(anyhow!(nix::Error::EINVAL));
}
if let Err(e) = mount(