diff options
author | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-01-30 13:33:22 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tomasz@kramkow.ski> | 2023-01-30 18:41:42 +0000 |
commit | 6b89e0dcb0d3a513d548fb38c08d4b66a353f364 (patch) | |
tree | 57904b88909ba15bbca650d2116a1d91e7699086 /src/pam.rs | |
parent | daf57f99f22cd105bf274cb856ae8e198388748e (diff) | |
download | pam_usercg_rust-6b89e0dcb0d3a513d548fb38c08d4b66a353f364.tar.gz pam_usercg_rust-6b89e0dcb0d3a513d548fb38c08d4b66a353f364.tar.xz pam_usercg_rust-6b89e0dcb0d3a513d548fb38c08d4b66a353f364.zip |
Basic pam_syslog error reporting
Diffstat (limited to 'src/pam.rs')
-rw-r--r-- | src/pam.rs | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1,3 +1,4 @@ +use crate::syslog::Priority; use core::marker::{PhantomData, PhantomPinned}; use std::ffi::{c_char, c_int, CStr, CString}; @@ -17,6 +18,7 @@ extern "C" { user: &*const c_char, prompt: *const c_char, ) -> c_int; + fn pam_syslog(pamh: *const PAMHandle, priority: c_int, fmt: *const c_char, ...); } impl PAMHandle { @@ -37,4 +39,9 @@ impl PAMHandle { e => Err(e), } } + pub fn syslog<S: AsRef<CStr> + ?Sized>(&self, priority: Priority, entry: &S) { + let Ok(fmt) = CString::new("%s") else { return }; + let entry = entry.as_ref(); + unsafe { pam_syslog(self, priority.into(), fmt.as_ptr(), entry.as_ptr()) } + } } |