summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2010-07-05 22:11:34 +0100
committerRoger Leigh <rleigh@debian.org>2010-07-05 22:50:46 +0100
commit1414347e9283b44992fba16081b2565cd7b8d4cb (patch)
tree2feea78932b4870f59a3f712fb88e44cf4150e07
parentf7bb21b327691330ffda6f8adea1cbf6cf2ff070 (diff)
downloadschroot-1414347e9283b44992fba16081b2565cd7b8d4cb.tar.gz
sbuild::session: Don't allow running or ending a new session
It doesn't make sense to run or end a new session unless also beginning with SESSION_AUTOMATIC.
-rw-r--r--sbuild/sbuild-session.cc11
-rw-r--r--sbuild/sbuild-session.h2
2 files changed, 10 insertions, 3 deletions
diff --git a/sbuild/sbuild-session.cc b/sbuild/sbuild-session.cc
index 8a1643bf..71a5bf03 100644
--- a/sbuild/sbuild-session.cc
+++ b/sbuild/sbuild-session.cc
@@ -82,9 +82,9 @@ namespace
// TRANSLATORS: %1% = chroot name
emap(session::CHROOT_ALIAS, N_("No chroot found matching name or alias '%1%'")),
emap(session::CHROOT_LOCK, N_("Failed to lock chroot")),
+ emap(session::CHROOT_NOTFOUND,N_("%1%: Chroot not found")),
emap(session::CHROOT_SETUP, N_("Chroot setup failed")),
// TRANSLATORS: %1% = chroot name
- emap(session::CHROOT_UNKNOWN, N_("Failed to find chroot '%1%'")),
emap(session::CHROOT_UNLOCK, N_("Failed to unlock chroot")),
// TRANSLATORS: %1% = command
emap(session::COMMAND_ABS, N_("Command \"%1%\" must have an absolute path")),
@@ -638,7 +638,14 @@ session::run_impl ()
const chroot::ptr ch = this->config->find_alias(*cur);
if (!ch) // Should never happen, but cater for it anyway.
- throw error(*cur, CHROOT_UNKNOWN);
+ throw error(*cur, CHROOT_NOTFOUND);
+
+ // TODO: Make chroot/session selection automatically fail
+ // if no session exists earlier on when selecting chroots.
+ if (ch->get_session_flags() & chroot::SESSION_CREATE &&
+ (this->session_operation != OPERATION_AUTOMATIC &&
+ this->session_operation != OPERATION_BEGIN))
+ throw error(*cur, CHROOT_NOTFOUND);
// For now, use a copy of the chroot; if we create a session
// later, we will replace it.
diff --git a/sbuild/sbuild-session.h b/sbuild/sbuild-session.h
index 18052755..664714a4 100644
--- a/sbuild/sbuild-session.h
+++ b/sbuild/sbuild-session.h
@@ -69,8 +69,8 @@ namespace sbuild
CHROOT, ///< Failed to change root to directory.
CHROOT_ALIAS, ///< No chroot found matching alias.
CHROOT_LOCK, ///< Failed to lock chroot.
+ CHROOT_NOTFOUND,///< Chroot not found.
CHROOT_SETUP, ///< Setup failed.
- CHROOT_UNKNOWN, ///< Failed to find chroot.
CHROOT_UNLOCK, ///< Failed to unlock chroot.
COMMAND_ABS, ///< Command must have an absolute path.
EXEC, ///< Failed to execute.