summaryrefslogtreecommitdiffstats
path: root/src/pam.rs
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2023-01-30 13:33:22 +0000
committerTomasz Kramkowski <tomasz@kramkow.ski>2023-01-30 18:41:42 +0000
commit6b89e0dcb0d3a513d548fb38c08d4b66a353f364 (patch)
tree57904b88909ba15bbca650d2116a1d91e7699086 /src/pam.rs
parentdaf57f99f22cd105bf274cb856ae8e198388748e (diff)
downloadpam_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.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/pam.rs b/src/pam.rs
index 81d543e..7905a92 100644
--- a/src/pam.rs
+++ b/src/pam.rs
@@ -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()) }
+ }
}