Skip to content

Commit 8862e1c

Browse files
committed
v0.1.2 add ENOTSUP error
1 parent fa816ae commit 8862e1c

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "linux-keyutils"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
authors = ["landhb <landhb@users.noreply.github.com>"]
66
description = """

examples/keyctl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn main() -> Result<(), Box<dyn Error>> {
5959
// Obtain the default User keyring for the current UID/user
6060
// See [KeyRingIdentifier] and `man 2 keyctl` for more information on default
6161
// keyrings for processes.
62-
let ring = KeyRing::get_persistent(KeyRingIdentifier::User)?;
62+
let ring = KeyRing::from_special_id(KeyRingIdentifier::Session, false)?;
6363

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

src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ pub enum KeyError {
4848
/// An invalid identifier was returned
4949
InvalidIdentifier,
5050

51+
/// Operation not supported
52+
OperationNotSupported,
53+
5154
/// Unknown - catch all, return this instead of panicing
5255
Unknown(i32),
5356
}
@@ -76,6 +79,7 @@ impl KeyError {
7679
libc::EKEYREJECTED => KeyError::KeyRejected,
7780
libc::ENOMEM => KeyError::OutOfMemory,
7881
libc::ENOKEY => KeyError::KeyDoesNotExist,
82+
libc::ENOTSUP => KeyError::OperationNotSupported,
7983

8084
// Unknown, provide error code for debugging
8185
x => KeyError::Unknown(x),

0 commit comments

Comments
 (0)