sbuild-auth-pam-conv-tty.h

Go to the documentation of this file.
00001 /* Copyright © 2005-2007  Roger Leigh <rleigh@debian.org>
00002  *
00003  * schroot is free software: you can redistribute it and/or modify it
00004  * under the terms of the GNU General Public License as published by
00005  * the Free Software Foundation, either version 3 of the License, or
00006  * (at your option) any later version.
00007  *
00008  * schroot is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program.  If not, see
00015  * <http://www.gnu.org/licenses/>.
00016  *
00017  *********************************************************************/
00018 
00019 #ifndef SBUILD_AUTH_PAM_CONV_TTY_H
00020 #define SBUILD_AUTH_PAM_CONV_TTY_H
00021 
00022 #include <sbuild/sbuild-auth-pam-conv.h>
00023 #include <sbuild/sbuild-auth.h>
00024 #include <sbuild/sbuild-custom-error.h>
00025 
00026 #include <security/pam_appl.h>
00027 #include <security/pam_misc.h>
00028 
00029 namespace sbuild
00030 {
00045   class auth_pam_conv_tty : public auth_pam_conv
00046   {
00047   public:
00049     enum error_code
00050       {
00051         CTTY,            
00052         TIMEOUT,         
00053         TIMEOUT_PENDING, 
00054         TERMIOS,         
00055         CONV_TYPE        
00056       };
00057 
00059     typedef custom_error<error_code> error;
00060 
00061   private:
00068     auth_pam_conv_tty (auth_ptr auth);
00069 
00070   public:
00072     virtual ~auth_pam_conv_tty ();
00073 
00080     static ptr
00081     create (auth_ptr auth);
00082 
00083     virtual auth_ptr
00084     get_auth ();
00085 
00086     virtual void
00087     set_auth (auth_ptr auth);
00088 
00089     virtual time_t
00090     get_warning_timeout ();
00091 
00092     virtual void
00093     set_warning_timeout (time_t timeout);
00094 
00095     virtual time_t
00096     get_fatal_timeout ();
00097 
00098     virtual void
00099     set_fatal_timeout (time_t timeout);
00100 
00101     virtual void
00102     conversation (auth_pam_conv::message_list& messages);
00103 
00104   private:
00114     int get_delay ();
00115 
00132     std::string
00133     read_string (std::string message,
00134                  bool        echo);
00135 
00137     weak_auth_ptr  auth;
00139     time_t  warning_timeout;
00141     time_t  fatal_timeout;
00143     time_t  start_time;
00144   };
00145 
00146 }
00147 
00148 #endif /* SBUILD_AUTH_PAM_CONV_TTY_H */
00149 
00150 /*
00151  * Local Variables:
00152  * mode:C++
00153  * End:
00154  */