Mercurial > crates > nonstick
changeset 55:676675c3d434
Make PamResultCode implement Error.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sun, 04 May 2025 00:58:04 -0400 |
parents | 0f1dcf5607e0 |
children | daa2cde64601 |
files | Cargo.toml src/constants.rs |
diffstat | 2 files changed, 37 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Cargo.toml Sat May 03 18:42:11 2025 -0400 +++ b/Cargo.toml Sun May 04 00:58:04 2025 -0400 @@ -11,3 +11,4 @@ [dependencies] libc = "0.2.97" +thiserror = "2.0.12"
--- a/src/constants.rs Sat May 03 18:42:11 2025 -0400 +++ b/src/constants.rs Sun May 04 00:58:04 2025 -0400 @@ -25,42 +25,75 @@ pub const PAM_RADIO_TYPE: PamMessageStyle = 5; pub const PAM_BINARY_PROMPT: PamMessageStyle = 7; -// The Linux-PAM return values -// see /usr/include/security/_pam_types.h +/// The Linux-PAM return values. +/// For more detailed information, see +/// /usr/include/security/_pam_types.h #[allow(non_camel_case_types, dead_code)] -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, thiserror::Error)] #[repr(C)] pub enum PamResultCode { + #[error("Not an error")] PAM_SUCCESS = 0, + #[error("dlopen() failure when dynamically loading a service module")] PAM_OPEN_ERR = 1, + #[error("symbol not found")] PAM_SYMBOL_ERR = 2, + #[error("error in service module")] PAM_SERVICE_ERR = 3, + #[error("system error")] PAM_SYSTEM_ERR = 4, + #[error("memory buffer error")] PAM_BUF_ERR = 5, + #[error("permission denied")] PAM_PERM_DENIED = 6, + #[error("authentication failure")] PAM_AUTH_ERR = 7, + #[error("cannot access authentication data due to insufficient credentials")] PAM_CRED_INSUFFICIENT = 8, + #[error("underlying authentication service cannot retrieve authentication information")] PAM_AUTHINFO_UNAVAIL = 9, + #[error("user not known to the underlying authentication module")] PAM_USER_UNKNOWN = 10, + #[error("retry limit reached; do not attempt further")] PAM_MAXTRIES = 11, + #[error("new authentication token required")] PAM_NEW_AUTHTOK_REQD = 12, + #[error("user account has expired")] PAM_ACCT_EXPIRED = 13, + #[error("cannot make/remove an entry for the specified session")] PAM_SESSION_ERR = 14, + #[error("underlying authentication service cannot retrieve user credentials")] PAM_CRED_UNAVAIL = 15, + #[error("user credentials expired")] PAM_CRED_EXPIRED = 16, + #[error("failure setting user credentials")] PAM_CRED_ERR = 17, + #[error("no module-specific data is present")] PAM_NO_MODULE_DATA = 18, + #[error("conversation error")] PAM_CONV_ERR = 19, + #[error("authentication token manipulation error")] PAM_AUTHTOK_ERR = 20, + #[error("authentication information cannot be recovered")] PAM_AUTHTOK_RECOVERY_ERR = 21, + #[error("authentication token lock busy")] PAM_AUTHTOK_LOCK_BUSY = 22, + #[error("authentication token aging disabled")] PAM_AUTHTOK_DISABLE_AGING = 23, + #[error("preliminary check by password service")] PAM_TRY_AGAIN = 24, + #[error("ignore underlying account module, regardless of control flag")] PAM_IGNORE = 25, + #[error("critical error; this module should fail now")] PAM_ABORT = 26, + #[error("authentication token has expired")] PAM_AUTHTOK_EXPIRED = 27, + #[error("module is not known")] PAM_MODULE_UNKNOWN = 28, + #[error("bad item passed to pam_[whatever]_item")] PAM_BAD_ITEM = 29, + #[error("conversation function is event-driven and data is not available yet")] PAM_CONV_AGAIN = 30, + #[error("call this function again to complete authentication stack")] PAM_INCOMPLETE = 31, }