Mercurial > crates > nonstick
comparison src/libpam/handle.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 | 0730f5f2ee2a |
| children | 4f46681b3f54 |
comparison
equal
deleted
inserted
replaced
| 179:dba9c1f40883 | 180:a1bb1d013567 |
|---|---|
| 4 use crate::conv::Exchange; | 4 use crate::conv::Exchange; |
| 5 use crate::environ::EnvironMapMut; | 5 use crate::environ::EnvironMapMut; |
| 6 use crate::handle::PamShared; | 6 use crate::handle::PamShared; |
| 7 use crate::items::{Items, ItemsMut}; | 7 use crate::items::{Items, ItemsMut}; |
| 8 use crate::libpam::environ::{LibPamEnviron, LibPamEnvironMut}; | 8 use crate::libpam::environ::{LibPamEnviron, LibPamEnvironMut}; |
| 9 use crate::libpam::items::{LibPamItems, LibPamItemsMut}; | 9 use crate::libpam::items::{ItemType, LibPamItems, LibPamItemsMut}; |
| 10 use crate::libpam::{items, memory}; | 10 use crate::libpam::{items, memory}; |
| 11 use crate::logging::{Level, Location, Logger}; | 11 use crate::logging::{Level, Location, Logger}; |
| 12 use crate::{AuthnFlags, AuthtokFlags, Conversation, EnvironMap, ModuleClient, Transaction}; | 12 use crate::{AuthnFlags, AuthtokFlags, Conversation, EnvironMap, ModuleClient, Transaction}; |
| 13 use num_enum::{IntoPrimitive, TryFromPrimitive}; | |
| 14 use std::any::TypeId; | 13 use std::any::TypeId; |
| 15 use std::cell::Cell; | 14 use std::cell::Cell; |
| 16 use std::ffi::{c_char, c_int, c_void, CString, OsStr, OsString}; | 15 use std::ffi::{c_char, c_int, c_void, CString, OsStr, OsString}; |
| 17 use std::os::unix::ffi::OsStrExt; | 16 use std::os::unix::ffi::OsStrExt; |
| 18 use std::ptr::NonNull; | 17 use std::ptr::NonNull; |
| 522 // SAFETY: We got this result from PAM, and we're checking if it's null. | 521 // SAFETY: We got this result from PAM, and we're checking if it's null. |
| 523 unsafe { output.as_ref() }.ok_or(ErrorCode::ConversationError) | 522 unsafe { output.as_ref() }.ok_or(ErrorCode::ConversationError) |
| 524 } | 523 } |
| 525 } | 524 } |
| 526 | 525 |
| 527 /// Identifies what is being gotten or set with `pam_get_item` | |
| 528 /// or `pam_set_item`. | |
| 529 #[derive(Clone, Copy, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)] | |
| 530 #[repr(i32)] | |
| 531 #[non_exhaustive] // because C could give us anything! | |
| 532 pub enum ItemType { | |
| 533 /// The PAM service name. | |
| 534 Service = libpam_sys::PAM_SERVICE, | |
| 535 /// The user's login name. | |
| 536 User = libpam_sys::PAM_USER, | |
| 537 /// The TTY name. | |
| 538 Tty = libpam_sys::PAM_TTY, | |
| 539 /// The remote host (if applicable). | |
| 540 RemoteHost = libpam_sys::PAM_RHOST, | |
| 541 /// The conversation struct (not a CStr-based item). | |
| 542 Conversation = libpam_sys::PAM_CONV, | |
| 543 /// The authentication token (password). | |
| 544 AuthTok = libpam_sys::PAM_AUTHTOK, | |
| 545 /// The old authentication token (when changing passwords). | |
| 546 OldAuthTok = libpam_sys::PAM_OLDAUTHTOK, | |
| 547 /// The remote user's name. | |
| 548 RemoteUser = libpam_sys::PAM_RUSER, | |
| 549 /// The prompt shown when requesting a username. | |
| 550 UserPrompt = libpam_sys::PAM_USER_PROMPT, | |
| 551 #[cfg(feature = "linux-pam-ext")] | |
| 552 /// App-supplied function to override failure delays. | |
| 553 FailDelay = libpam_sys::PAM_FAIL_DELAY, | |
| 554 #[cfg(feature = "linux-pam-ext")] | |
| 555 /// X display name. | |
| 556 XDisplay = libpam_sys::PAM_XDISPLAY, | |
| 557 #[cfg(feature = "linux-pam-ext")] | |
| 558 /// X server authentication data. | |
| 559 XAuthData = libpam_sys::PAM_XAUTHDATA, | |
| 560 #[cfg(feature = "linux-pam-ext")] | |
| 561 /// The type of `pam_get_authtok`. | |
| 562 AuthTokType = libpam_sys::PAM_AUTHTOK_TYPE, | |
| 563 } |
