dchroot-session-base.cc

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 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 #include <config.h>
00021 
00022 #include "dchroot-session-base.h"
00023 
00024 #include <cassert>
00025 #include <cerrno>
00026 #include <cstdlib>
00027 #include <cstring>
00028 #include <iostream>
00029 #include <memory>
00030 
00031 #include <unistd.h>
00032 
00033 #include <syslog.h>
00034 
00035 #include <boost/format.hpp>
00036 
00037 #include <uuid/uuid.h>
00038 
00039 using std::cout;
00040 using std::endl;
00041 using sbuild::_;
00042 using boost::format;
00043 using namespace dchroot;
00044 
00045 session_base::session_base (std::string const&  service,
00046                             config_ptr&         config,
00047                             operation           operation,
00048                             sbuild::string_list const& chroots,
00049                             bool                compat):
00050   sbuild::session(service, config, operation, chroots),
00051   compat(compat)
00052 {
00053 }
00054 
00055 session_base::~session_base ()
00056 {
00057 }
00058 
00059 bool
00060 session_base::get_compat () const
00061 {
00062   return this->compat;
00063 }
00064 
00065 void
00066 session_base::set_compat (bool state)
00067 {
00068   this->compat = state;
00069 }
00070 
00071 void
00072 session_base::run_impl ()
00073 {
00074   if (get_ruid() != get_uid())
00075     throw error(get_ruser(), get_user(), USER_SWITCH,
00076                 _("dchroot session restriction"));
00077 
00078   sbuild::session::run_impl();
00079 }
00080 
00081 sbuild::string_list
00082 session_base::get_command_directories () const
00083 {
00084   // dchroot does not treat logins differently from commands with
00085   // respect to the cwd inside the chroot.
00086   return get_login_directories();
00087 }

Generated on Thu May 10 23:11:36 2007 for schroot by  doxygen 1.5.2