pub trait ConversationHandler {
    fn prompt_echo_on(&mut self, prompt: &CStr) -> Result<CString, ErrorCode>;
    fn prompt_echo_off(&mut self, prompt: &CStr) -> Result<CString, ErrorCode>;
    fn text_info(&mut self, msg: &CStr);
    fn error_msg(&mut self, msg: &CStr);

    fn init(&mut self, _default_user: Option<impl AsRef<str>>) { ... }
    fn radio_prompt(&mut self, prompt: &CStr) -> Result<bool, ErrorCode> { ... }
    fn binary_prompt(
        &mut self,
        _type: u8,
        _data: &[u8]
    ) -> Result<(u8, Vec<u8>), ErrorCode> { ... } }
Expand description

Trait for PAM conversation functions

Implement this for custom behaviour when a PAM module asks for usernames, passwords, etc. or wants to show a message to the user

Required Methods

Obtains a string whilst echoing text (e.g. username)

Errors

You should return one of the following error codes on failure.

Obtains a string without echoing any text (e.g. password)

Errors

You should return one of the following error codes on failure.

Displays some text.

Displays an error message.

Provided Methods

Called by Context directly after taking ownership of the handler.

May be called multiple times if Context::replace_conversation() is used. In this case it is called each time a context takes ownership and passed the current target username of that context (if any) as the argument.

The default implementation does nothing.

Obtains a yes/no answer (Linux specific).

The default implementation calls prompt_echo_on and maps any answer starting with ‘y’ or ‘j’ to “yes” and everything else to “no”.

Errors

You should return one of the following error codes on failure.

Exchanges binary data (Linux specific, experimental).

The default implementation returns a conversation error.

Errors

You should return one of the following error codes on failure.

Implementors