| 1 | #![allow(dead_code)] |
| 2 | #![allow(non_camel_case_types)] |
| 3 | #![allow(clippy::upper_case_acronyms)] |
| 4 | |
| 5 | use pam::PamError; |
| 6 | use std::option::Option; |
| 7 | use std::os::raw::{c_char, c_int, c_void}; |
| 8 | use std::ptr::NonNull; |
| 9 | |
| 10 | pub type PamHandle = *const c_void; |
| 11 | |
| 12 | #[repr(C)] |
| 13 | pub enum PamMsgStyle { |
| 14 | PROMPT_ECHO_OFF = 1, /* Ask for password without echo */ |
| 15 | PROMPT_ECHO_ON = 2, /* Ask for password with echo */ |
| 16 | ERROR_MSG = 3, /* Display an error message */ |
| 17 | TEXT_INFO = 4, /* Display arbitrary text */ |
| 18 | // Linux extensions |
| 19 | PAM_MAX_NUM_MSG = 32, |
| 20 | PAM_RADIO_TYPE = 5, /* yes/no/maybe conditionals */ |
| 21 | PAM_BINARY_PROMPT = 7, |
| 22 | } |
| 23 | |
| 24 | #[repr(C)] |
| 25 | pub struct PamMessage { |
| 26 | pub msg_style: PamMsgStyle, |
| 27 | pub msg: *const c_char, |
| 28 | } |
| 29 | |
| 30 | #[repr(C)] |
| 31 | pub struct PamResponse { |
| 32 | pub resp: Option<NonNull<c_char>>, |
| 33 | pub resp_retcode: PamError, |
| 34 | } |
| 35 | |
| 36 | pub(crate) type PamConvCallback = extern "C" fn( |
| 37 | num_msg: c_int, |
| 38 | msg: *mut *const PamMessage, |
| 39 | resp: *mut *mut PamResponse, |
| 40 | appdata_ptr: *mut c_void, |
| 41 | ) -> c_int; |
| 42 | |
| 43 | #[repr(C)] |
| 44 | pub(crate) struct PamConv { |
| 45 | pub(crate) cb: Option<PamConvCallback>, |
| 46 | pub(crate) appdata_ptr: *mut c_void, |
| 47 | } |
| 48 | |
| 49 | #[repr(C)] |
| 50 | pub enum LogLvl { |
| 51 | EMERG = 0, /* system is unusable */ |
| 52 | ALERT = 1, /* action must be taken immediately */ |
| 53 | CRIT = 2, /* critical conditions */ |
| 54 | ERR = 3, /* error conditions */ |
| 55 | WARNING = 4, /* warning conditions */ |
| 56 | NOTICE = 5, /* normal but significant condition */ |
| 57 | INFO = 6, /* informational */ |
| 58 | DEBUG = 7, /* debug-level messages */ |
| 59 | } |
| 60 | |
| 61 | #[repr(C)] |
| 62 | pub enum PamItemType { |
| 63 | SERVICE = 1, /* The service name */ |
| 64 | USER = 2, /* The user name */ |
| 65 | TTY = 3, /* The tty name */ |
| 66 | RHOST = 4, /* The remote host name */ |
| 67 | CONV = 5, /* The pam_conv structure */ |
| 68 | AUTHTOK = 6, /* The authentication token (password) */ |
| 69 | OLDAUTHTOK = 7, /* The old authentication token */ |
| 70 | RUSER = 8, /* The remote user name */ |
| 71 | USER_PROMPT = 9, /* the prompt for getting a username */ |
| 72 | FAIL_DELAY = 10, /* app supplied function to override failure delays */ |
| 73 | XDISPLAY = 11, /* X display name */ |
| 74 | XAUTHDATA = 12, /* X server authentication data */ |
| 75 | AUTHTOK_TYPE = 13, /* The type for pam_get_authtok */ |
| 76 | } |