sbuild-session.h

Go to the documentation of this file.
00001 /* Copyright © 2005-2006  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-chroot-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<chroot_config> config_ptr;
00067 
00069     typedef std::tr1::shared_ptr<session> ptr;
00070 
00079     session (std::string const& service,
00080              config_ptr&        config,
00081              operation          operation,
00082              string_list const& chroots);
00083 
00085     virtual ~session ();
00086 
00092     config_ptr&
00093     get_config ();
00094 
00100     void
00101     set_config (config_ptr& config);
00102 
00108     string_list const&
00109     get_chroots () const;
00110 
00116     void
00117     set_chroots (string_list const& chroots);
00118 
00124     operation
00125     get_operation () const;
00126 
00132     void
00133     set_operation (operation operation);
00134 
00141     std::string const&
00142     get_session_id () const;
00143 
00150     void
00151     set_session_id (std::string const& session_id);
00152 
00158     bool
00159     get_force () const;
00160 
00166     void
00167     set_force (bool force);
00168 
00175     int
00176     get_child_status () const;
00177 
00182     virtual sbuild::auth::status
00183     get_auth_status () const;
00184 
00192     virtual void
00193     run_impl ();
00194 
00195   private:
00206     int
00207     exec (std::string const& file,
00208           string_list const& command,
00209           environment const& env);
00223     void
00224     setup_chroot (chroot::ptr&       session_chroot,
00225                   chroot::setup_type setup_type);
00226 
00235     void
00236     run_chroot (chroot::ptr& session_chroot);
00237 
00246     void
00247     run_child (chroot::ptr& session_chroot);
00248 
00257     void
00258     wait_for_child (int  pid,
00259                     int& child_status);
00260 
00266     void
00267     set_sighup_handler ();
00268 
00272     void
00273     clear_sighup_handler ();
00274 
00276     config_ptr       config;
00278     string_list      chroots;
00280     int              chroot_status;
00282     int              child_status;
00284     operation        session_operation;
00286     std::string      session_id;
00288     bool             force;
00290     struct sigaction saved_signals;
00291   };
00292 
00293 }
00294 
00295 #endif /* SBUILD_SESSION_H */
00296 
00297 /*
00298  * Local Variables:
00299  * mode:C++
00300  * End:
00301  */

Generated on Sun Mar 19 12:07:48 2006 for schroot by  doxygen 1.4.6