Skip to content

Commit

Permalink
v0.1.2 add ENOTSUP error
Browse files Browse the repository at this point in the history
  • Loading branch information
landhb committed Sep 26, 2022
1 parent fa816ae commit 8862e1c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "linux-keyutils"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["landhb <landhb@users.noreply.github.com>"]
description = """
Expand Down
3 changes: 2 additions & 1 deletion examples/keyctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn main() -> Result<(), Box<dyn Error>> {
// Obtain the default User keyring for the current UID/user
// See [KeyRingIdentifier] and `man 2 keyctl` for more information on default
// keyrings for processes.
let ring = KeyRing::get_persistent(KeyRingIdentifier::User)?;
let ring = KeyRing::from_special_id(KeyRingIdentifier::Session, false)?;

_ = match args.subcommand {
// Add a new key to the keyring
Expand Down Expand Up @@ -102,6 +102,7 @@ fn main() -> Result<(), Box<dyn Error>> {
Command::Invalidate { description } => {
let key = ring.search(&description)?;
key.invalidate()?;
println!("Removed key with ID {:?}", key.get_id());
}
};

Expand Down
4 changes: 4 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pub enum KeyError {
/// An invalid identifier was returned
InvalidIdentifier,

/// Operation not supported
OperationNotSupported,

/// Unknown - catch all, return this instead of panicing
Unknown(i32),
}
Expand Down Expand Up @@ -76,6 +79,7 @@ impl KeyError {
libc::EKEYREJECTED => KeyError::KeyRejected,
libc::ENOMEM => KeyError::OutOfMemory,
libc::ENOKEY => KeyError::KeyDoesNotExist,
libc::ENOTSUP => KeyError::OperationNotSupported,

// Unknown, provide error code for debugging
x => KeyError::Unknown(x),
Expand Down

0 comments on commit 8862e1c

Please sign in to comment.