Mercurial > crates > nonstick
comparison 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 | fb8b547b36b7 |
comparison
equal
deleted
inserted
replaced
179:dba9c1f40883 | 180:a1bb1d013567 |
---|---|
1 use crate::constants::ErrorCode; | 1 use crate::constants::ErrorCode; |
2 use crate::constants::Result; | 2 use crate::constants::Result; |
3 use crate::items::{Items, ItemsMut}; | 3 use crate::items::{Items, ItemsMut}; |
4 use crate::libpam::handle::ItemType; | |
5 use crate::libpam::handle::LibPamHandle; | 4 use crate::libpam::handle::LibPamHandle; |
6 use crate::libpam::memory; | 5 use crate::libpam::memory; |
7 use std::ffi::{c_int, OsStr, OsString}; | 6 use std::ffi::{c_int, OsStr, OsString}; |
8 use std::ptr; | 7 use std::ptr; |
8 | |
9 memory::num_enum! { | |
10 /// Identifies what is being gotten or set with `pam_get_item` | |
11 /// or `pam_set_item`. | |
12 #[non_exhaustive] | |
13 pub enum ItemType(i32) { | |
14 /// The PAM service name. | |
15 Service = libpam_sys::PAM_SERVICE, | |
16 /// The user's login name. | |
17 User = libpam_sys::PAM_USER, | |
18 /// The TTY name. | |
19 Tty = libpam_sys::PAM_TTY, | |
20 /// The remote host (if applicable). | |
21 RemoteHost = libpam_sys::PAM_RHOST, | |
22 /// The conversation struct (not a CStr-based item). | |
23 Conversation = libpam_sys::PAM_CONV, | |
24 /// The authentication token (password). | |
25 AuthTok = libpam_sys::PAM_AUTHTOK, | |
26 /// The old authentication token (when changing passwords). | |
27 OldAuthTok = libpam_sys::PAM_OLDAUTHTOK, | |
28 /// The remote user's name. | |
29 RemoteUser = libpam_sys::PAM_RUSER, | |
30 /// The prompt shown when requesting a username. | |
31 UserPrompt = libpam_sys::PAM_USER_PROMPT, | |
32 #[cfg(feature = "linux-pam-ext")] | |
33 /// App-supplied function to override failure delays. | |
34 FailDelay = libpam_sys::PAM_FAIL_DELAY, | |
35 #[cfg(feature = "linux-pam-ext")] | |
36 /// X display name. | |
37 XDisplay = libpam_sys::PAM_XDISPLAY, | |
38 #[cfg(feature = "linux-pam-ext")] | |
39 /// X server authentication data. | |
40 XAuthData = libpam_sys::PAM_XAUTHDATA, | |
41 #[cfg(feature = "linux-pam-ext")] | |
42 /// The type of `pam_get_authtok`. | |
43 AuthTokType = libpam_sys::PAM_AUTHTOK_TYPE, | |
44 } | |
45 } | |
9 | 46 |
10 pub struct LibPamItems<'a>(pub &'a LibPamHandle); | 47 pub struct LibPamItems<'a>(pub &'a LibPamHandle); |
11 pub struct LibPamItemsMut<'a>(pub &'a mut LibPamHandle); | 48 pub struct LibPamItemsMut<'a>(pub &'a mut LibPamHandle); |
12 | 49 |
13 /// Macro to implement getting/setting a CStr-based item. | 50 /// Macro to implement getting/setting a CStr-based item. |