diff src/libpam/items.rs @ 180:a1bb1d013567

Remove `syn` from the dependency tree by implementing our own num_enum.
author Paul Fisher <paul@pfish.zone>
date Wed, 30 Jul 2025 18:22:16 -0400
parents a75a66cb4181
children
line wrap: on
line diff
--- a/src/libpam/items.rs	Wed Jul 30 18:07:51 2025 -0400
+++ b/src/libpam/items.rs	Wed Jul 30 18:22:16 2025 -0400
@@ -1,12 +1,49 @@
 use crate::constants::ErrorCode;
 use crate::constants::Result;
 use crate::items::{Items, ItemsMut};
-use crate::libpam::handle::ItemType;
 use crate::libpam::handle::LibPamHandle;
 use crate::libpam::memory;
 use std::ffi::{c_int, OsStr, OsString};
 use std::ptr;
 
+memory::num_enum! {
+    /// Identifies what is being gotten or set with `pam_get_item`
+    /// or `pam_set_item`.
+    #[non_exhaustive]
+    pub enum ItemType(i32) {
+        /// The PAM service name.
+        Service = libpam_sys::PAM_SERVICE,
+        /// The user's login name.
+        User = libpam_sys::PAM_USER,
+        /// The TTY name.
+        Tty = libpam_sys::PAM_TTY,
+        /// The remote host (if applicable).
+        RemoteHost = libpam_sys::PAM_RHOST,
+        /// The conversation struct (not a CStr-based item).
+        Conversation = libpam_sys::PAM_CONV,
+        /// The authentication token (password).
+        AuthTok = libpam_sys::PAM_AUTHTOK,
+        /// The old authentication token (when changing passwords).
+        OldAuthTok = libpam_sys::PAM_OLDAUTHTOK,
+        /// The remote user's name.
+        RemoteUser = libpam_sys::PAM_RUSER,
+        /// The prompt shown when requesting a username.
+        UserPrompt = libpam_sys::PAM_USER_PROMPT,
+        #[cfg(feature = "linux-pam-ext")]
+        /// App-supplied function to override failure delays.
+        FailDelay = libpam_sys::PAM_FAIL_DELAY,
+        #[cfg(feature = "linux-pam-ext")]
+        /// X display name.
+        XDisplay = libpam_sys::PAM_XDISPLAY,
+        #[cfg(feature = "linux-pam-ext")]
+        /// X server authentication data.
+        XAuthData = libpam_sys::PAM_XAUTHDATA,
+        #[cfg(feature = "linux-pam-ext")]
+        /// The type of `pam_get_authtok`.
+        AuthTokType = libpam_sys::PAM_AUTHTOK_TYPE,
+    }
+}
+
 pub struct LibPamItems<'a>(pub &'a LibPamHandle);
 pub struct LibPamItemsMut<'a>(pub &'a mut LibPamHandle);