1
/* Copyright © 2005-2006 Roger Leigh <rleigh@debian.org>
3
* schroot is free software; you can redistribute it and/or modify it
4
* under the terms of the GNU General Public License as published by
5
* the Free Software Foundation; either version 2 of the License, or
6
* (at your option) any later version.
8
* schroot is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18
*********************************************************************/
22
#include "dchroot-dsa-session.h"
35
#include <boost/format.hpp>
37
#include <uuid/uuid.h>
42
using sbuild::string_list;
43
using namespace dchroot_dsa;
45
session::session (std::string const& service,
48
string_list const& chroots,
50
dchroot::session_base(service, config, operation, chroots, compat)
59
session::get_chroot_auth_status (sbuild::auth::status status,
60
sbuild::chroot::ptr const& chroot) const
62
/* DSA dchroot checks for a valid user in the groups list, unless
63
the groups lists is empty in which case there are no
64
restrictions. This only applies if not switching users (dchroot
65
does not support user switching) */
67
if (get_compat() == true)
69
string_list const& users = chroot->get_users();
70
string_list const& groups = chroot->get_groups();
72
if (this->get_ruid() == this->get_uid() &&
73
users.empty() && groups.empty())
74
status = change_auth(status, auth::STATUS_NONE);
76
status = change_auth(status,
77
sbuild::session::get_chroot_auth_status(status,
80
else // schroot compatibility
82
status = change_auth(status,
83
sbuild::session::get_chroot_auth_status(status,
91
session::get_login_directories () const
95
ret.push_back(get_home());
97
// Final fallback to root.
98
if (std::find(ret.begin(), ret.end(), "/") == ret.end())
105
session::get_user_command (sbuild::chroot::ptr& session_chroot,
107
string_list& command) const
109
std::string programstring = command[0];
110
file = programstring;
112
if (!sbuild::is_absname(file))
113
throw error(file, COMMAND_ABS);
115
std::string commandstring = sbuild::string_list_to_string(command, " ");
116
sbuild::log_debug(sbuild::DEBUG_NOTICE)
117
<< format("Running command: %1%") % commandstring << endl;
118
syslog(LOG_USER|LOG_NOTICE, "[%s chroot] (%s->%s) Running command: \"%s\"",
119
session_chroot->get_name().c_str(), get_ruser().c_str(), get_user().c_str(), commandstring.c_str());
121
if (get_verbosity() != auth::VERBOSITY_QUIET)
123
std::string format_string;
124
format_string = (_("[%1% chroot] Running command: \"%2%\""));
126
format fmt(format_string);
127
fmt % session_chroot->get_name()
129
sbuild::log_info() << fmt << endl;