Mercurial > crates > nonstick
comparison src/libpam/question.rs @ 148:4b3a5095f68c
Move libpam-sys helpers into their own library.
- Renames libpam-sys-helpers to libpam-sys-consts.
- Moves libpam-sys-helpers::helpers into libpam-sys-helpers,
which moves them completely out of libpam-sys's dependency chain.
- Moves the aliases from libpam-sys into libpam-sys::aliases.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Mon, 07 Jul 2025 12:11:43 -0400 |
parents | ebb71a412b58 |
children | 4d11b2e7da83 |
comparison
equal
deleted
inserted
replaced
147:4d7333337569 | 148:4b3a5095f68c |
---|---|
3 use crate::conv::{ErrorMsg, Exchange, InfoMsg, MaskedQAndA, QAndA}; | 3 use crate::conv::{ErrorMsg, Exchange, InfoMsg, MaskedQAndA, QAndA}; |
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::memory as pam_mem; | 8 use libpam_sys_helpers as libpam_sys_helpers; |
9 use num_enum::{IntoPrimitive, TryFromPrimitive}; | 9 use num_enum::{IntoPrimitive, TryFromPrimitive}; |
10 use std::ffi::{c_int, c_void, CStr, OsStr}; | 10 use std::ffi::{c_int, c_void, CStr, OsStr}; |
11 use std::os::unix::ffi::OsStrExt; | 11 use std::os::unix::ffi::OsStrExt; |
12 use std::ptr::NonNull; | 12 use std::ptr::NonNull; |
13 | 13 |
79 | 79 |
80 /// Gets this message's data pointer as borrowed binary data. | 80 /// Gets this message's data pointer as borrowed binary data. |
81 unsafe fn binary_data(&self) -> (&[u8], u8) { | 81 unsafe fn binary_data(&self) -> (&[u8], u8) { |
82 self.data | 82 self.data |
83 .as_ref() | 83 .as_ref() |
84 .map(|data| pam_mem::BinaryPayload::contents(data.as_ptr().cast())) | 84 .map(|data| libpam_sys_helpers::BinaryPayload::contents(data.as_ptr().cast())) |
85 .unwrap_or_default() | 85 .unwrap_or_default() |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 impl TryFrom<&Exchange<'_>> for Question { | 89 impl TryFrom<&Exchange<'_>> for Question { |
133 let _ = match style { | 133 let _ = match style { |
134 #[cfg(feature = "linux-pam-ext")] | 134 #[cfg(feature = "linux-pam-ext")] |
135 Style::BinaryPrompt => self | 135 Style::BinaryPrompt => self |
136 .data | 136 .data |
137 .as_mut() | 137 .as_mut() |
138 .map(|p| pam_mem::BinaryPayload::zero(p.as_ptr().cast())), | 138 .map(|p| libpam_sys_helpers::BinaryPayload::zero(p.as_ptr().cast())), |
139 #[cfg(feature = "linux-pam-ext")] | 139 #[cfg(feature = "linux-pam-ext")] |
140 Style::RadioType => self | 140 Style::RadioType => self |
141 .data | 141 .data |
142 .as_mut() | 142 .as_mut() |
143 .map(|p| memory::CHeapString::zero(p.cast())), | 143 .map(|p| memory::CHeapString::zero(p.cast())), |
185 Ok(prompt) | 185 Ok(prompt) |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 #[cfg(feature = "linux-pam-ext")] | 189 #[cfg(feature = "linux-pam-ext")] |
190 impl From<pam_mem::TooBigError> for ErrorCode { | 190 impl From<libpam_sys_helpers::TooBigError> for ErrorCode { |
191 fn from(_: pam_mem::TooBigError) -> Self { | 191 fn from(_: libpam_sys_helpers::TooBigError) -> Self { |
192 ErrorCode::BufferError | 192 ErrorCode::BufferError |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 #[cfg(test)] | 196 #[cfg(test)] |