sbuild::AuthConvTty Class Reference

Authentication conversation handler for terminal devices. More...

#include <sbuild-auth-conv-tty.h>

Inheritance diagram for sbuild::AuthConvTty:

Inheritance graph
[legend]
Collaboration diagram for sbuild::AuthConvTty:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 AuthConvTty ()
 The constructor.
virtual ~AuthConvTty ()
 The destructor.
virtual time_t get_warning_timeout ()
 Get the time at which the user will be warned.
virtual void set_warning_timeout (time_t timeout)
 Set the time at which the user will be warned.
virtual time_t get_fatal_timeout ()
 Get the time at which the conversation will be terminated with an error.
virtual void set_fatal_timeout (time_t timeout)
 Set the time at which the conversation will be terminated with an error.
virtual bool conversation (message_list &messages)

Private Member Functions

int get_delay ()
 Get the time delay before the next SIGALRM signal.
std::string * read_string (std::string message, bool echo)
 Read user input from standard input.

Private Attributes

time_t warning_timeout
 The time to warn at.
time_t fatal_timeout
 The time to end at.
time_t start_time
 The time the current delay was obtained at.

Detailed Description

Authentication conversation handler for terminal devices.

This class is an implementation of the AuthConv interface, and is used to interact with the user on a terminal (TTY) interface.

In order to implement timeouts, this class uses alarm(2). This has some important implications. Global state is modified by the object, so only one may be used at once in a single process. In addition, no other part of the process may set or unset the SIGALRM handlers and the alarm(2) timer during the time PAM authentication is proceeding.


Member Function Documentation

int AuthConvTty::get_delay  )  [private]
 

Get the time delay before the next SIGALRM signal.

If either the warning timeout or the fatal timeout have expired, a message to notify the user is printed to stderr.

Returns:
the delay in seconds, 0 if no delay is set, or -1 if the fatal timeout has expired.

time_t AuthConvTty::get_fatal_timeout  )  [virtual]
 

Get the time at which the conversation will be terminated with an error.

Returns:
the time.

Implements sbuild::AuthConv.

time_t AuthConvTty::get_warning_timeout  )  [virtual]
 

Get the time at which the user will be warned.

Returns:
the time.

Implements sbuild::AuthConv.

std::string * AuthConvTty::read_string std::string  message,
bool  echo
[private]
 

Read user input from standard input.

The prompt message is printed to prompt the user for input. If echo is true, the user input it echoed back to the terminal, but if false, echoing is suppressed using termios(3).

If the SIGALRM timer expires while waiting for input, this is handled by re-checking the delay time which will warn the user or cause the input routine to terminate if the fatal timeout has expired.

Parameters:
message the message to prompt the user for input.
echo echo user input to screen.
Returns:
a string, which is empty on failure.
Todo:
Throw an exception on failure.

Remove start_time.

void AuthConvTty::set_fatal_timeout time_t  timeout  )  [virtual]
 

Set the time at which the conversation will be terminated with an error.

Parameters:
timeout the time to set.

Implements sbuild::AuthConv.

void AuthConvTty::set_warning_timeout time_t  timeout  )  [virtual]
 

Set the time at which the user will be warned.

Parameters:
timeout the time to set.

Implements sbuild::AuthConv.


The documentation for this class was generated from the following files:
Generated on Thu Dec 29 17:20:04 2005 for schroot by  doxygen 1.4.5