Skip to content

Commit

Permalink
Expose set_item()
Browse files Browse the repository at this point in the history
Signed-off-by: fufesou <[email protected]>
  • Loading branch information
fufesou committed May 18, 2022
1 parent c75c23f commit 10da2cb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct Client<'a, C: conv::Conversation> {
is_authenticated: bool,
has_open_session: bool,
last_code: PamReturnCode,
items_holder: Vec<Vec<u8>>,
}

impl<'a> Client<'a, conv::PasswordConv> {
Expand All @@ -60,6 +61,7 @@ impl<'a, C: conv::Conversation> Client<'a, C> {
is_authenticated: false,
has_open_session: false,
last_code: PamReturnCode::Success,
items_holder: Vec::new(),
})
}

Expand Down Expand Up @@ -91,6 +93,16 @@ impl<'a, C: conv::Conversation> Client<'a, C> {
Ok(())
}

pub fn set_item(&mut self, item_type: PamItemType, item: &str) -> PamResult<()> {
let mut item = item.as_bytes().to_owned();
item.push(0);
set_item(self.handle, item_type, unsafe {
(item.as_ptr() as *const libc::c_void).as_ref().unwrap()
})?;
self.items_holder.push(item);
Ok(())
}

/// Open a session for a previously authenticated user and
/// initialize the environment appropriately (in PAM and regular enviroment variables).
pub fn open_session(&mut self) -> PamResult<()> {
Expand Down

0 comments on commit 10da2cb

Please sign in to comment.