sbuild-session.h

00001 /* Copyright © 2005  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 2 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, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00016  * MA  02111-1307  USA
00017  *
00018  *********************************************************************/
00019 
00020 #ifndef SBUILD_SESSION_H
00021 #define SBUILD_SESSION_H
00022 
00023 #include <string>
00024 
00025 #include <sys/types.h>
00026 #include <sys/wait.h>
00027 #include <grp.h>
00028 #include <pwd.h>
00029 #include <unistd.h>
00030 
00031 #include "sbuild-auth.h"
00032 #include "sbuild-config.h"
00033 #include "sbuild-error.h"
00034 
00035 namespace sbuild
00036 {
00037 
00049   class Session : public Auth
00050   {
00051   public:
00053     enum Operation
00054       {
00055         OPERATION_AUTOMATIC, 
00056         OPERATION_BEGIN,     
00057         OPERATION_RECOVER,   
00058         OPERATION_END,       
00059         OPERATION_RUN        
00060       };
00061 
00063     typedef runtime_error_custom<Session> error;
00064 
00066     typedef std::tr1::shared_ptr<Config> config_ptr;
00067 
00076     Session (const std::string& service,
00077              config_ptr&        config,
00078              Operation          operation,
00079              string_list        chroots);
00080 
00082     virtual ~Session();
00083 
00089     config_ptr&
00090     get_config ();
00091 
00097     void
00098     set_config (config_ptr& config);
00099 
00105     const string_list&
00106     get_chroots () const;
00107 
00113     void
00114     set_chroots (const string_list& chroots);
00115 
00121     Operation
00122     get_operation () const;
00123 
00129     void
00130     set_operation (Operation operation);
00131 
00138     const std::string&
00139     get_session_id () const;
00140 
00147     void
00148     set_session_id (const std::string& session_id);
00149 
00155     bool
00156     get_force () const;
00157 
00163     void
00164     set_force (bool force);
00165 
00172     int
00173     get_child_status () const;
00174 
00179     virtual sbuild::Auth::Status
00180     get_auth_status () const;
00181 
00189     virtual void
00190     run_impl ();
00191 
00192   private:
00203     int
00204     exec (const std::string& file,
00205           const string_list& command,
00206           const env_list& env);
00220     void
00221     setup_chroot (Chroot&           session_chroot,
00222                   Chroot::SetupType setup_type);
00223 
00232     void
00233     run_chroot (Chroot& session_chroot);
00234 
00243     void
00244     run_child (Chroot& session_chroot);
00245 
00254     void
00255     wait_for_child (int  pid,
00256                     int& child_status);
00257 
00259     config_ptr  config;
00261     string_list chroots;
00264     int         child_status;
00266     Operation   operation;
00268     std::string session_id;
00270     bool        force;
00271   };
00272 
00273 }
00274 
00275 #endif /* SBUILD_SESSION_H */
00276 
00277 /*
00278  * Local Variables:
00279  * mode:C++
00280  * End:
00281  */

Generated on Thu Dec 29 17:20:02 2005 for schroot by  doxygen 1.4.5