summaryrefslogtreecommitdiffstats
path: root/src/pam.rs
diff options
context:
space:
mode:
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()) }
+ }
}