1 | /* Copyright © 2005-2007 Roger Leigh <rleigh@debian.org> |
---|
2 | * |
---|
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 3 of the License, or |
---|
6 | * (at your option) any later version. |
---|
7 | * |
---|
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. |
---|
12 | * |
---|
13 | * You should have received a copy of the GNU General Public License |
---|
14 | * along with this program. If not, see |
---|
15 | * <http://www.gnu.org/licenses/>. |
---|
16 | * |
---|
17 | *********************************************************************/ |
---|
18 | |
---|
19 | #include <config.h> |
---|
20 | |
---|
21 | #include "dchroot-dsa-main.h" |
---|
22 | #include "dchroot-dsa-chroot-config.h" |
---|
23 | #include "dchroot-dsa-session.h" |
---|
24 | |
---|
25 | #include <cstdlib> |
---|
26 | #include <iostream> |
---|
27 | #include <locale> |
---|
28 | |
---|
29 | #include <sys/types.h> |
---|
30 | #include <sys/stat.h> |
---|
31 | #include <termios.h> |
---|
32 | #include <unistd.h> |
---|
33 | |
---|
34 | #include <boost/format.hpp> |
---|
35 | |
---|
36 | using std::endl; |
---|
37 | using sbuild::_; |
---|
38 | using boost::format; |
---|
39 | using namespace dchroot_dsa; |
---|
40 | |
---|
41 | main::main (schroot::options_base::ptr& options): |
---|
42 | main_base("dchroot-dsa", |
---|
43 | // TRANSLATORS: '...' is an ellipsis e.g. U+2026, and '-' |
---|
44 | // is an em-dash. |
---|
45 | _("[OPTION...] chroot [COMMAND] - run command or shell in a chroot"), |
---|
46 | options) |
---|
47 | { |
---|
48 | } |
---|
49 | |
---|
50 | main::~main () |
---|
51 | { |
---|
52 | } |
---|
53 | |
---|
54 | void |
---|
55 | main::load_config () |
---|
56 | { |
---|
57 | check_dchroot_conf(); |
---|
58 | |
---|
59 | if (this->use_dchroot_conf) |
---|
60 | { |
---|
61 | this->config = |
---|
62 | sbuild::chroot_config::ptr(new dchroot_dsa::chroot_config); |
---|
63 | if (this->options->load_chroots == true) |
---|
64 | this->config->add(DCHROOT_CONF, false); |
---|
65 | } |
---|
66 | else |
---|
67 | { |
---|
68 | schroot::main_base::load_config(); |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | void |
---|
73 | main::create_session(sbuild::session::operation sess_op) |
---|
74 | { |
---|
75 | sbuild::log_debug(sbuild::DEBUG_INFO) |
---|
76 | << "Creating dchroot-dsa session" << endl; |
---|
77 | |
---|
78 | // Using dchroot.conf implies using dchroot_session_base, which does |
---|
79 | // not require user or group access. |
---|
80 | this->session = sbuild::session::ptr |
---|
81 | (new dchroot_dsa::session("schroot", |
---|
82 | this->config, |
---|
83 | sess_op, |
---|
84 | this->chroots, |
---|
85 | this->use_dchroot_conf)); |
---|
86 | } |
---|