Mercurial > crates > nonstick
comparison src/libpam/question.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 | dba9c1f40883 |
children | fb8b547b36b7 |
comparison
equal
deleted
inserted
replaced
179:dba9c1f40883 | 180:a1bb1d013567 |
---|---|
4 use crate::libpam::conversation::OwnedExchange; | 4 use crate::libpam::conversation::OwnedExchange; |
5 use crate::libpam::memory; | 5 use crate::libpam::memory; |
6 use crate::ErrorCode; | 6 use crate::ErrorCode; |
7 use crate::Result; | 7 use crate::Result; |
8 use libpam_sys_helpers; | 8 use libpam_sys_helpers; |
9 use num_enum::{IntoPrimitive, TryFromPrimitive}; | |
10 use std::ffi::{c_int, c_void, CStr, OsStr}; | 9 use std::ffi::{c_int, c_void, CStr, OsStr}; |
11 use std::os::unix::ffi::OsStrExt; | 10 use std::os::unix::ffi::OsStrExt; |
12 use std::ptr::NonNull; | 11 use std::ptr::NonNull; |
13 | 12 |
14 /// The C enum values for messages shown to the user. | 13 memory::num_enum! { |
15 #[derive(Debug, PartialEq, TryFromPrimitive, IntoPrimitive)] | 14 /// The C enum values for messages shown to the user. |
16 #[repr(i32)] | 15 enum Style(i32) { |
17 enum Style { | 16 /// Requests information from the user; will be masked when typing. |
18 /// Requests information from the user; will be masked when typing. | 17 PromptEchoOff = libpam_sys::PAM_PROMPT_ECHO_OFF, |
19 PromptEchoOff = libpam_sys::PAM_PROMPT_ECHO_OFF, | 18 /// Requests information from the user; will not be masked. |
20 /// Requests information from the user; will not be masked. | 19 PromptEchoOn = libpam_sys::PAM_PROMPT_ECHO_ON, |
21 PromptEchoOn = libpam_sys::PAM_PROMPT_ECHO_ON, | 20 /// An error message. |
22 /// An error message. | 21 ErrorMsg = libpam_sys::PAM_ERROR_MSG, |
23 ErrorMsg = libpam_sys::PAM_ERROR_MSG, | 22 /// An informational message. |
24 /// An informational message. | 23 TextInfo = libpam_sys::PAM_TEXT_INFO, |
25 TextInfo = libpam_sys::PAM_TEXT_INFO, | 24 /// Yes/No/Maybe conditionals. A Linux-PAM extension. |
26 /// Yes/No/Maybe conditionals. A Linux-PAM extension. | 25 #[cfg(feature = "linux-pam-ext")] |
27 #[cfg(feature = "linux-pam-ext")] | 26 RadioType = libpam_sys::PAM_RADIO_TYPE, |
28 RadioType = libpam_sys::PAM_RADIO_TYPE, | 27 /// For server–client non-human interaction. |
29 /// For server–client non-human interaction. | 28 /// |
30 /// | 29 /// NOT part of the X/Open PAM specification. |
31 /// NOT part of the X/Open PAM specification. | 30 /// A Linux-PAM extension. |
32 /// A Linux-PAM extension. | 31 #[cfg(feature = "linux-pam-ext")] |
33 #[cfg(feature = "linux-pam-ext")] | 32 BinaryPrompt = libpam_sys::PAM_BINARY_PROMPT, |
34 BinaryPrompt = libpam_sys::PAM_BINARY_PROMPT, | 33 } |
35 } | 34 } |
36 | 35 |
37 /// A question sent by PAM or a module to an application. | 36 /// A question sent by PAM or a module to an application. |
38 /// | 37 /// |
39 /// PAM refers to this as a "message", but we call it a question | 38 /// PAM refers to this as a "message", but we call it a question |