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

Generated on Mon Jan 21 00:38:28 2008 for schroot by  doxygen 1.5.4