Mercurial > crates > nonstick
comparison src/conv.rs @ 51:9d1160b02d2c
Safety and doc fixes:
- Don't panic when given a string with a null character;
instead return `PAM_CONV_ERR`.
- Improve pattern matching and use ?s where appropriate.
- Format etc.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sat, 03 May 2025 18:41:25 -0400 |
parents | a921b72743e4 |
children |
comparison
equal
deleted
inserted
replaced
50:171fb1171053 | 51:9d1160b02d2c |
---|---|
17 struct PamResponse { | 17 struct PamResponse { |
18 resp: *const c_char, | 18 resp: *const c_char, |
19 resp_retcode: libc::c_int, // Unused - always zero | 19 resp_retcode: libc::c_int, // Unused - always zero |
20 } | 20 } |
21 | 21 |
22 /// `PamConv` acts as a channel for communicating with user. | |
23 /// | |
24 /// Communication is mediated by the pam client (the application that invoked | |
25 /// pam). Messages sent will be relayed to the user by the client, and response | |
26 /// will be relayed back. | |
27 #[repr(C)] | 22 #[repr(C)] |
28 pub struct Inner { | 23 pub struct Inner { |
29 conv: extern "C" fn( | 24 conv: extern "C" fn( |
30 num_msg: c_int, | 25 num_msg: c_int, |
31 pam_message: &&PamMessage, | 26 pam_message: &&PamMessage, |
33 appdata_ptr: *const libc::c_void, | 28 appdata_ptr: *const libc::c_void, |
34 ) -> PamResultCode, | 29 ) -> PamResultCode, |
35 appdata_ptr: *const libc::c_void, | 30 appdata_ptr: *const libc::c_void, |
36 } | 31 } |
37 | 32 |
33 /// A `Conv`ersation channel with the user. | |
34 /// | |
35 /// Communication is mediated by the PAM client (the application that invoked | |
36 /// pam). Messages sent will be relayed to the user by the client, and response | |
37 /// will be relayed back. | |
38 pub struct Conv<'a>(&'a Inner); | 38 pub struct Conv<'a>(&'a Inner); |
39 | 39 |
40 impl Conv<'_> { | 40 impl Conv<'_> { |
41 /// Sends a message to the pam client. | 41 /// Sends a message to the pam client. |
42 /// | 42 /// |