Mercurial > crates > nonstick
view src/items.rs @ 72:47eb242a4f88
Fill out the PamHandle trait.
This updates the PamHandle trait to have methods for each Item,
and implements them on the LibPamHandle.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Wed, 04 Jun 2025 03:53:36 -0400 |
parents | a674799a5cd3 |
children |
line wrap: on
line source
//! Things that can be gotten with the `pam_get_item` function. use crate::constants::InvalidEnum; use num_derive::FromPrimitive; use num_traits::FromPrimitive; use std::ffi::c_int; /// Identifies what is being gotten or set with `pam_get_item` /// or `pam_set_item`. #[derive(FromPrimitive)] #[repr(i32)] #[non_exhaustive] // because C could give us anything! pub enum ItemType { /// The PAM service name. Service = 1, /// The user's login name. User = 2, /// The TTY name. Tty = 3, /// The remote host (if applicable). RemoteHost = 4, /// The conversation struct (not a CStr-based item). Conversation = 5, /// The authentication token (password). AuthTok = 6, /// The old authentication token (when changing passwords). OldAuthTok = 7, /// The remote user's name. RemoteUser = 8, /// The prompt shown when requesting a username. UserPrompt = 9, /// App-supplied function to override failure delays. FailDelay = 10, /// X display name. XDisplay = 11, /// X server authentication data. XAuthData = 12, /// The type of `pam_get_authtok`. AuthTokType = 13, } impl TryFrom<c_int> for ItemType { type Error = InvalidEnum<Self>; fn try_from(value: c_int) -> Result<Self, Self::Error> { Self::from_i32(value).ok_or(value.into()) } } impl From<ItemType> for c_int { fn from(val: ItemType) -> Self { val as Self } }