summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2013-04-07 21:26:36 +0100
committerRoger Leigh <rleigh@debian.org>2013-04-09 22:36:44 +0100
commite28c28d884dc376d0c78ce64875f6fdcbbb5c54b (patch)
treecec59a27f72af12c2bd863968061387c0d3afb0d /lib
parenta2394ed28bfa35b8e0ea0f74b8f2d5372d48ac15 (diff)
downloadschroot-e28c28d884dc376d0c78ce64875f6fdcbbb5c54b.tar.gz
sbuild: Move chroot-facet-personality to namespace chroot::facet
Diffstat (limited to 'lib')
-rw-r--r--lib/sbuild/Makefile.am4
-rw-r--r--lib/sbuild/chroot-facet-personality.cc115
-rw-r--r--lib/sbuild/chroot-facet-personality.h113
-rw-r--r--lib/sbuild/chroot/chroot.cc4
-rw-r--r--lib/sbuild/chroot/facet/personality.cc126
-rw-r--r--lib/sbuild/chroot/facet/personality.h119
-rw-r--r--lib/sbuild/session.cc6
7 files changed, 252 insertions, 235 deletions
diff --git a/lib/sbuild/Makefile.am b/lib/sbuild/Makefile.am
index fb1d5dd0..c89d6382 100644
--- a/lib/sbuild/Makefile.am
+++ b/lib/sbuild/Makefile.am
@@ -27,7 +27,7 @@ lib_sbuild_public_h_sources = \
lib/sbuild/chroot/directory-base.h \
lib/sbuild/chroot/facet/facet.h \
lib/sbuild/chroot/facet/mountable.h \
- lib/sbuild/chroot-facet-personality.h \
+ lib/sbuild/chroot/facet/personality.h \
lib/sbuild/chroot-facet-session.h \
lib/sbuild/chroot-facet-session-clonable.h \
lib/sbuild/chroot-facet-source.h \
@@ -111,7 +111,7 @@ lib_sbuild_public_cc_sources = \
lib/sbuild/chroot/directory.cc \
lib/sbuild/chroot/directory-base.cc \
lib/sbuild/chroot/facet/mountable.cc \
- lib/sbuild/chroot-facet-personality.cc \
+ lib/sbuild/chroot/facet/personality.cc \
lib/sbuild/chroot-facet-session.cc \
lib/sbuild/chroot-facet-session-clonable.cc \
lib/sbuild/chroot-facet-source.cc \
diff --git a/lib/sbuild/chroot-facet-personality.cc b/lib/sbuild/chroot-facet-personality.cc
deleted file mode 100644
index ad7202f6..00000000
--- a/lib/sbuild/chroot-facet-personality.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Copyright © 2005-2013 Roger Leigh <rleigh@debian.org>
- *
- * schroot is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * schroot is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- *********************************************************************/
-
-#include <config.h>
-
-#include <sbuild/chroot/chroot.h>
-#include "chroot-facet-personality.h"
-
-#include <boost/format.hpp>
-
-using boost::format;
-using namespace sbuild;
-
-chroot_facet_personality::chroot_facet_personality ():
- chroot::facet::facet(),
- persona()
-{
-}
-
-chroot_facet_personality::~chroot_facet_personality ()
-{
-}
-
-chroot_facet_personality::ptr
-chroot_facet_personality::create ()
-{
- return ptr(new chroot_facet_personality());
-}
-
-chroot::facet::facet::ptr
-chroot_facet_personality::clone () const
-{
- return ptr(new chroot_facet_personality(*this));
-}
-
-std::string const&
-chroot_facet_personality::get_name () const
-{
- static const std::string name("personality");
-
- return name;
-}
-
-personality const&
-chroot_facet_personality::get_persona () const
-{
- return this->persona;
-}
-
-void
-chroot_facet_personality::set_persona (personality const& persona)
-{
- this->persona = persona;
-}
-
-void
-chroot_facet_personality::setup_env (chroot::chroot const& chroot,
- environment& env) const
-{
-}
-
-chroot::chroot::session_flags
-chroot_facet_personality::get_session_flags (chroot::chroot const& chroot) const
-{
- return chroot::chroot::SESSION_NOFLAGS;
-}
-
-void
-chroot_facet_personality::get_details (chroot::chroot const& chroot,
- format_detail& detail) const
-{
- // TRANSLATORS: "Personality" is the Linux kernel personality
- // (process execution domain). See schroot.conf(5).
- detail.add(_("Personality"), get_persona().get_name());
-}
-
-void
-chroot_facet_personality::get_used_keys (string_list& used_keys) const
-{
- used_keys.push_back("personality");
-}
-
-void
-chroot_facet_personality::get_keyfile (chroot::chroot const& chroot,
- keyfile& keyfile) const
-{
- // Only set if defined.
- if (get_persona().get_name() != "undefined")
- keyfile::set_object_value(*this, &chroot_facet_personality::get_persona,
- keyfile, chroot.get_name(), "personality");
-}
-
-void
-chroot_facet_personality::set_keyfile (chroot::chroot& chroot,
- keyfile const& keyfile)
-{
- keyfile::get_object_value(*this, &chroot_facet_personality::set_persona,
- keyfile, chroot.get_name(), "personality",
- keyfile::PRIORITY_OPTIONAL);
-}
diff --git a/lib/sbuild/chroot-facet-personality.h b/lib/sbuild/chroot-facet-personality.h
deleted file mode 100644
index 91ed48d1..00000000
--- a/lib/sbuild/chroot-facet-personality.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Copyright © 2005-2013 Roger Leigh <rleigh@debian.org>
- *
- * schroot is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * schroot is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- *********************************************************************/
-
-#ifndef SBUILD_CHROOT_FACET_PERSONALITY_H
-#define SBUILD_CHROOT_FACET_PERSONALITY_H
-
-#include <sbuild/chroot/facet/facet.h>
-#include <sbuild/personality.h>
-
-namespace sbuild
-{
-
- /**
- * Chroot support for kernel personalities (execution domains).
- */
- class chroot_facet_personality : public chroot::facet::facet
- {
- public:
- /// A shared_ptr to a chroot facet object.
- typedef std::shared_ptr<chroot_facet_personality> ptr;
-
- /// A shared_ptr to a const chroot facet object.
- typedef std::shared_ptr<const chroot_facet_personality> const_ptr;
-
- private:
- /// The constructor.
- chroot_facet_personality ();
-
- public:
- /// The destructor.
- virtual ~chroot_facet_personality ();
-
- /**
- * Create a chroot facet.
- *
- * @returns a shared_ptr to the new chroot facet.
- */
- static ptr
- create ();
-
- virtual facet::ptr
- clone () const;
-
- virtual std::string const&
- get_name () const;
-
- /**
- * Get the process execution domain for the chroot.
- *
- * @returns the personality.
- */
- personality const&
- get_persona () const;
-
- /**
- * Set the process execution domain for the chroot.
- *
- * @param persona the personality.
- */
- void
- set_persona (personality const& persona);
-
- virtual void
- setup_env (chroot::chroot const& chroot,
- environment& env) const;
-
- virtual chroot::chroot::session_flags
- get_session_flags (chroot::chroot const& chroot) const;
-
- virtual void
- get_details (chroot::chroot const& chroot,
- format_detail& detail) const;
-
- virtual void
- get_used_keys (string_list& used_keys) const;
-
- virtual void
- get_keyfile (chroot::chroot const& chroot,
- keyfile& keyfile) const;
-
- virtual void
- set_keyfile (chroot::chroot& chroot,
- keyfile const& keyfile);
-
- private:
- /// Process execution domain (Linux only).
- personality persona;
- };
-
-}
-
-#endif /* SBUILD_CHROOT_FACET_PERSONALITY_H */
-
-/*
- * Local Variables:
- * mode:C++
- * End:
- */
diff --git a/lib/sbuild/chroot/chroot.cc b/lib/sbuild/chroot/chroot.cc
index cfc59f33..d5e37cd4 100644
--- a/lib/sbuild/chroot/chroot.cc
+++ b/lib/sbuild/chroot/chroot.cc
@@ -37,7 +37,7 @@
#include <sbuild/chroot/btrfs-snapshot.h>
#endif // SBUILD_FEATURE_BTRFSSNAP
#include <sbuild/chroot/facet/facet.h>
-#include "chroot-facet-personality.h"
+#include <sbuild/chroot/facet/personality.h>
#include "chroot-facet-session.h"
#include "chroot-facet-session-clonable.h"
#include "chroot-facet-source.h"
@@ -117,7 +117,7 @@ namespace sbuild
message_verbosity(VERBOSITY_NORMAL),
facets()
{
- add_facet(chroot_facet_personality::create());
+ add_facet(facet::personality::create());
#ifdef SBUILD_FEATURE_UNSHARE
add_facet(chroot_facet_unshare::create());
#endif // SBUILD_FEATURE_UNSHARE
diff --git a/lib/sbuild/chroot/facet/personality.cc b/lib/sbuild/chroot/facet/personality.cc
new file mode 100644
index 00000000..0730f2a1
--- /dev/null
+++ b/lib/sbuild/chroot/facet/personality.cc
@@ -0,0 +1,126 @@
+/* Copyright © 2005-2013 Roger Leigh <rleigh@debian.org>
+ *
+ * schroot is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * schroot is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ *********************************************************************/
+
+#include <config.h>
+
+#include <sbuild/chroot/chroot.h>
+#include <sbuild/chroot/facet/personality.h>
+
+#include <boost/format.hpp>
+
+using boost::format;
+using namespace sbuild;
+
+namespace sbuild
+{
+ namespace chroot
+ {
+ namespace facet
+ {
+
+ personality::personality ():
+ facet(),
+ persona()
+ {
+ }
+
+ personality::~personality ()
+ {
+ }
+
+ personality::ptr
+ personality::create ()
+ {
+ return ptr(new personality());
+ }
+
+ facet::ptr
+ personality::clone () const
+ {
+ return ptr(new personality(*this));
+ }
+
+ std::string const&
+ personality::get_name () const
+ {
+ static const std::string name("personality");
+
+ return name;
+ }
+
+ sbuild::personality const&
+ personality::get_persona () const
+ {
+ return this->persona;
+ }
+
+ void
+ personality::set_persona (sbuild::personality const& persona)
+ {
+ this->persona = persona;
+ }
+
+ void
+ personality::setup_env (chroot const& chroot,
+ environment& env) const
+ {
+ }
+
+ chroot::session_flags
+ personality::get_session_flags (chroot const& chroot) const
+ {
+ return chroot::SESSION_NOFLAGS;
+ }
+
+ void
+ personality::get_details (chroot const& chroot,
+ format_detail& detail) const
+ {
+ // TRANSLATORS: "Personality" is the Linux kernel personality
+ // (process execution domain). See schroot.conf(5).
+ detail.add(_("Personality"), get_persona().get_name());
+ }
+
+ void
+ personality::get_used_keys (string_list& used_keys) const
+ {
+ used_keys.push_back("personality");
+ }
+
+ void
+ personality::get_keyfile (chroot const& chroot,
+ keyfile& keyfile) const
+ {
+ // Only set if defined.
+ if (get_persona().get_name() != "undefined")
+ keyfile::set_object_value(*this, &personality::get_persona,
+ keyfile, chroot.get_name(), "personality");
+ }
+
+ void
+ personality::set_keyfile (chroot& chroot,
+ keyfile const& keyfile)
+ {
+ keyfile::get_object_value(*this, &personality::set_persona,
+ keyfile, chroot.get_name(), "personality",
+ keyfile::PRIORITY_OPTIONAL);
+ }
+
+ }
+ }
+}
diff --git a/lib/sbuild/chroot/facet/personality.h b/lib/sbuild/chroot/facet/personality.h
new file mode 100644
index 00000000..5b727da7
--- /dev/null
+++ b/lib/sbuild/chroot/facet/personality.h
@@ -0,0 +1,119 @@
+/* Copyright © 2005-2013 Roger Leigh <rleigh@debian.org>
+ *
+ * schroot is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * schroot is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ *********************************************************************/
+
+#ifndef SBUILD_CHROOT_FACET_PERSONALITY_H
+#define SBUILD_CHROOT_FACET_PERSONALITY_H
+
+#include <sbuild/chroot/facet/facet.h>
+#include <sbuild/personality.h>
+
+namespace sbuild
+{
+ namespace chroot
+ {
+ namespace facet
+ {
+
+ /**
+ * Chroot support for kernel personalities (execution domains).
+ */
+ class personality : public facet
+ {
+ public:
+ /// A shared_ptr to a chroot facet object.
+ typedef std::shared_ptr<personality> ptr;
+
+ /// A shared_ptr to a const chroot facet object.
+ typedef std::shared_ptr<const personality> const_ptr;
+
+ private:
+ /// The constructor.
+ personality ();
+
+ public:
+ /// The destructor.
+ virtual ~personality ();
+
+ /**
+ * Create a chroot facet.
+ *
+ * @returns a shared_ptr to the new chroot facet.
+ */
+ static ptr
+ create ();
+
+ virtual facet::ptr
+ clone () const;
+
+ virtual std::string const&
+ get_name () const;
+
+ /**
+ * Get the process execution domain for the chroot.
+ *
+ * @returns the personality.
+ */
+ sbuild::personality const&
+ get_persona () const;
+
+ /**
+ * Set the process execution domain for the chroot.
+ *
+ * @param persona the personality.
+ */
+ void
+ set_persona (sbuild::personality const& persona);
+
+ virtual void
+ setup_env (chroot const& chroot,
+ environment& env) const;
+
+ virtual chroot::session_flags
+ get_session_flags (chroot const& chroot) const;
+
+ virtual void
+ get_details (chroot const& chroot,
+ format_detail& detail) const;
+
+ virtual void
+ get_used_keys (string_list& used_keys) const;
+
+ virtual void
+ get_keyfile (chroot const& chroot,
+ keyfile& keyfile) const;
+
+ virtual void
+ set_keyfile (chroot& chroot,
+ keyfile const& keyfile);
+
+ private:
+ /// Process execution domain (Linux only).
+ sbuild::personality persona;
+ };
+
+ }
+ }
+}
+
+#endif /* SBUILD_CHROOT_FACET_PERSONALITY_H */
+
+/*
+ * Local Variables:
+ * mode:C++
+ * End:
+ */
diff --git a/lib/sbuild/session.cc b/lib/sbuild/session.cc
index 3d2db248..603056a1 100644
--- a/lib/sbuild/session.cc
+++ b/lib/sbuild/session.cc
@@ -19,7 +19,7 @@
#include <config.h>
#include <sbuild/chroot/chroot.h>
-#include "chroot-facet-personality.h"
+#include <sbuild/chroot/facet/personality.h>
#include "chroot-facet-session.h"
#include "chroot-facet-session-clonable.h"
#ifdef SBUILD_FEATURE_UNSHARE
@@ -1284,8 +1284,8 @@ session::run_child (chroot::chroot::ptr& session_chroot)
/* Set the process execution domain. */
/* Will throw on failure. */
- chroot_facet_personality::const_ptr pfac =
- session_chroot->get_facet<chroot_facet_personality>();
+ chroot::facet::personality::const_ptr pfac =
+ session_chroot->get_facet<chroot::facet::personality>();
if (pfac)
{
pfac->get_persona().set();