sbuild
1.4.26
|
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 00081 static ptr 00082 create (auth_ptr auth); 00083 00084 virtual auth_ptr 00085 get_auth (); 00086 00087 virtual void 00088 set_auth (auth_ptr auth); 00089 00090 virtual time_t 00091 get_warning_timeout (); 00092 00093 virtual void 00094 set_warning_timeout (time_t timeout); 00095 00096 virtual time_t 00097 get_fatal_timeout (); 00098 00099 virtual void 00100 set_fatal_timeout (time_t timeout); 00101 00102 virtual void 00103 conversation (auth_pam_conv::message_list& messages); 00104 00105 private: 00115 int get_delay (); 00116 00133 std::string 00134 read_string (std::string message, 00135 bool echo); 00136 00138 weak_auth_ptr auth; 00140 time_t warning_timeout; 00142 time_t fatal_timeout; 00144 time_t start_time; 00145 }; 00146 00147 } 00148 00149 #endif /* SBUILD_AUTH_PAM_CONV_TTY_H */ 00150 00151 /* 00152 * Local Variables: 00153 * mode:C++ 00154 * End: 00155 */