Mercurial > crates > nonstick
comparison src/libpam/answer.rs @ 80:5aa1a010f1e8
Start using PAM headers; improve owned/borrowed distinction.
- Uses bindgen to generate bindings (only if needed).
- Gets the story together on owned vs. borrowed handles.
- Reduces number of mutable borrows in handle operation
(since `PamHandle` is neither `Send` nor `Sync`,
we never have to worry about thread safety.
- Improves a bunch of macros so we don't have our own
special syntax for docs.
- Implement question indirection for standard XSSO PAM implementations.
| author | Paul Fisher <paul@pfish.zone> |
|---|---|
| date | Tue, 10 Jun 2025 01:09:30 -0400 |
| parents | 2128123b9406 |
| children | 05291b601f0a |
comparison
equal
deleted
inserted
replaced
| 79:2128123b9406 | 80:5aa1a010f1e8 |
|---|---|
| 1 //! Types used to communicate data from the application to the module. | 1 //! Types used to communicate data from the application to the module. |
| 2 | 2 |
| 3 use crate::libpam::conversation::OwnedMessage; | 3 use crate::libpam::conversation::OwnedMessage; |
| 4 use crate::libpam::memory; | 4 use crate::libpam::memory; |
| 5 use crate::libpam::memory::{CBinaryData, Immovable}; | 5 use crate::libpam::memory::CBinaryData; |
| 6 pub use crate::libpam::pam_ffi::Answer; | |
| 6 use crate::{ErrorCode, Result}; | 7 use crate::{ErrorCode, Result}; |
| 7 use std::ffi::{c_int, c_void, CStr}; | 8 use std::ffi::CStr; |
| 8 use std::ops::{Deref, DerefMut}; | 9 use std::ops::{Deref, DerefMut}; |
| 9 use std::{iter, mem, ptr, slice}; | 10 use std::{iter, mem, ptr, slice}; |
| 10 | 11 |
| 11 /// The corridor via which the answer to Messages navigate through PAM. | 12 /// The corridor via which the answer to Messages navigate through PAM. |
| 12 #[derive(Debug)] | 13 #[derive(Debug)] |
| 191 } | 192 } |
| 192 memory::free(self.0.data); | 193 memory::free(self.0.data); |
| 193 self.0.data = ptr::null_mut() | 194 self.0.data = ptr::null_mut() |
| 194 } | 195 } |
| 195 } | 196 } |
| 196 } | |
| 197 | |
| 198 /// Generic version of answer data. | |
| 199 /// | |
| 200 /// This has the same structure as [`BinaryAnswer`] | |
| 201 /// and [`TextAnswer`]. | |
| 202 #[repr(C)] | |
| 203 #[derive(Debug)] | |
| 204 pub struct Answer { | |
| 205 /// Pointer to the data returned in an answer. | |
| 206 /// For most answers, this will be a [`CStr`], but for answers to | |
| 207 /// [`MessageStyle::BinaryPrompt`]s, this will be [`CBinaryData`] | |
| 208 /// (a Linux-PAM extension). | |
| 209 data: *mut c_void, | |
| 210 /// Unused. | |
| 211 return_code: c_int, | |
| 212 _marker: Immovable, | |
| 213 } | 197 } |
| 214 | 198 |
| 215 impl Answer { | 199 impl Answer { |
| 216 /// Frees the contents of this answer. | 200 /// Frees the contents of this answer. |
| 217 /// | 201 /// |
