aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-03 00:20:41 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-03 00:20:41 +0100
commit77f9ca11a1c69224a9c83c90f1dec3cb7afaa36e (patch)
tree178817edd0395f5849bcb1ef98840752b38d3d2f
parente710a8015607d6c9404acc001312a5d82e436d8e (diff)
downloadpaludis-77f9ca11a1c69224a9c83c90f1dec3cb7afaa36e.tar.gz
paludis-77f9ca11a1c69224a9c83c90f1dec3cb7afaa36e.tar.xz
exdirectory
-rw-r--r--paludis/repositories/e/Makefile.am2
-rw-r--r--paludis/repositories/e/do_fetch_action.cc3
-rw-r--r--paludis/repositories/e/do_info_action.cc2
-rw-r--r--paludis/repositories/e/do_install_action.cc6
-rw-r--r--paludis/repositories/e/do_pretend_action.cc4
-rw-r--r--paludis/repositories/e/e_installed_repository.cc3
-rw-r--r--paludis/repositories/e/e_repository.cc1
-rw-r--r--paludis/repositories/e/e_repository_TEST_exheres_0.cc63
-rwxr-xr-xpaludis/repositories/e/e_repository_TEST_exheres_0_setup.sh62
-rw-r--r--paludis/repositories/e/ebuild.cc7
-rw-r--r--paludis/repositories/e/ebuild.hh4
-rw-r--r--paludis/repositories/e/ebuild/exheres-0/output_functions.bash9
-rw-r--r--paludis/repositories/e/ebuild_id.cc1
-rw-r--r--paludis/repositories/e/exndbam_repository.cc1
-rw-r--r--paludis/repositories/e/permitted_directories-fwd.hh31
-rw-r--r--paludis/repositories/e/permitted_directories.cc63
-rw-r--r--paludis/repositories/e/permitted_directories.hh47
-rw-r--r--paludis/repositories/e/pipe_command_handler.cc42
-rw-r--r--paludis/repositories/e/pipe_command_handler.hh2
-rw-r--r--paludis/repositories/e/vdb_repository.cc1
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc2
21 files changed, 347 insertions, 9 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 7eb0888..035eb62 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -85,6 +85,7 @@ noinst_HEADERS = \
parse_plain_text_label.hh \
parse_uri_label.hh \
pbin_merger.hh \
+ permitted_directories.hh permitted_directories-fwd.hh \
pipe_command_handler.hh \
profile.hh \
required_use_verifier.hh \
@@ -164,6 +165,7 @@ libpaludiserepository_la_SOURCES = \
parse_plain_text_label.cc \
parse_uri_label.cc \
pbin_merger.cc \
+ permitted_directories.cc \
pipe_command_handler.cc \
profile.cc \
registration.cc \
diff --git a/paludis/repositories/e/do_fetch_action.cc b/paludis/repositories/e/do_fetch_action.cc
index 9c790c2..c263184 100644
--- a/paludis/repositories/e/do_fetch_action.cc
+++ b/paludis/repositories/e/do_fetch_action.cc
@@ -36,6 +36,7 @@
#include <paludis/util/wrapped_output_iterator.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/join.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/metadata_key.hh>
@@ -189,6 +190,7 @@ paludis::erepository::do_fetch_action(
n::maybe_output_manager() = output_manager,
n::package_builddir() = package_builddir,
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() =
(repo->params().master_repositories() && ! repo->params().master_repositories()->empty()) ?
(*repo->params().master_repositories()->begin())->params().location() : repo->params().location(),
@@ -236,6 +238,7 @@ paludis::erepository::do_fetch_action(
n::maybe_output_manager() = output_manager,
n::package_builddir() = repo->params().builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version()) + "-nofetch"),
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() = (repo->params().master_repositories() && ! repo->params().master_repositories()->empty()) ?
(*repo->params().master_repositories()->begin())->params().location() : repo->params().location(),
n::root() = "/",
diff --git a/paludis/repositories/e/do_info_action.cc b/paludis/repositories/e/do_info_action.cc
index d037375..addfd70 100644
--- a/paludis/repositories/e/do_info_action.cc
+++ b/paludis/repositories/e/do_info_action.cc
@@ -28,6 +28,7 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/join.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/action.hh>
@@ -99,6 +100,7 @@ paludis::erepository::do_info_action(
n::maybe_output_manager() = output_manager,
n::package_builddir() = repo->params().builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version()) + "-info"),
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() =
(repo->params().master_repositories() && ! repo->params().master_repositories()->empty()) ?
(*repo->params().master_repositories()->begin())->params().location() : repo->params().location(),
diff --git a/paludis/repositories/e/do_install_action.cc b/paludis/repositories/e/do_install_action.cc
index 19c6466..ae3ab0c 100644
--- a/paludis/repositories/e/do_install_action.cc
+++ b/paludis/repositories/e/do_install_action.cc
@@ -29,6 +29,7 @@
#include <paludis/repositories/e/e_stripper.hh>
#include <paludis/repositories/e/ebuild.hh>
#include <paludis/repositories/e/make_archive_strings.hh>
+#include <paludis/repositories/e/permitted_directories.hh>
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/accept_visitor.hh>
@@ -195,6 +196,8 @@ paludis::erepository::do_install_action(
std::string used_config_protect;
auto merged_entries(std::make_shared<FSPathSet>());
+ auto permitted_directories(std::make_shared<PermittedDirectories>());
+
auto choices(id->choices_key()->parse_value());
std::shared_ptr<const ChoiceValue> preserve_work_choice(choices->find_by_name_with_prefix(ELikePreserveWorkChoiceValue::canonical_name_with_prefix()));
@@ -263,7 +266,7 @@ paludis::erepository::do_install_action(
n::output_manager() = output_manager,
n::package_id() = id,
n::perform_uninstall() = install_action.options.perform_uninstall(),
- n::permit_destination() = std::bind(return_literal_function(true)),
+ n::permit_destination() = std::bind(&PermittedDirectories::permit, permitted_directories, std::placeholders::_1),
n::replacing() = install_action.options.replacing(),
n::used_this_for_config_protect() = std::bind(
&used_this_for_config_protect, std::ref(used_config_protect), std::placeholders::_1)
@@ -347,6 +350,7 @@ paludis::erepository::do_install_action(
n::maybe_output_manager() = output_manager,
n::package_builddir() = package_builddir,
n::package_id() = id,
+ n::permitted_directories() = permitted_directories,
n::portdir() =
(repo->params().master_repositories() && ! repo->params().master_repositories()->empty()) ?
(*repo->params().master_repositories()->begin())->params().location() : repo->params().location(),
diff --git a/paludis/repositories/e/do_pretend_action.cc b/paludis/repositories/e/do_pretend_action.cc
index f514e52..d0c8abe 100644
--- a/paludis/repositories/e/do_pretend_action.cc
+++ b/paludis/repositories/e/do_pretend_action.cc
@@ -31,6 +31,7 @@
#include <paludis/util/make_named_values.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/join.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/metadata_key.hh>
@@ -116,6 +117,7 @@ paludis::erepository::do_pretend_action(
n::maybe_output_manager() = output_manager,
n::package_builddir() = repo->params().builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version()) + "-bad_options"),
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() =
(repo->params().master_repositories() && ! repo->params().master_repositories()->empty()) ?
(*repo->params().master_repositories()->begin())->params().location() : repo->params().location(),
@@ -177,6 +179,7 @@ paludis::erepository::do_pretend_action(
n::maybe_output_manager() = output_manager,
n::package_builddir() = repo->params().builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version()) + "-bad_options"),
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() =
(repo->params().master_repositories() && ! repo->params().master_repositories()->empty()) ?
(*repo->params().master_repositories()->begin())->params().location() : repo->params().location(),
@@ -236,6 +239,7 @@ paludis::erepository::do_pretend_action(
n::maybe_output_manager() = output_manager,
n::package_builddir() = repo->params().builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version()) + "-pretend"),
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() =
(repo->params().master_repositories() && ! repo->params().master_repositories()->empty()) ?
(*repo->params().master_repositories()->begin())->params().location() : repo->params().location(),
diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc
index 96b6680..7d8ebff 100644
--- a/paludis/repositories/e/e_installed_repository.cc
+++ b/paludis/repositories/e/e_installed_repository.cc
@@ -42,6 +42,7 @@
#include <paludis/util/fs_stat.hh>
#include <paludis/util/join.hh>
#include <paludis/util/is_file_with_extension.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/action.hh>
#include <paludis/package_id.hh>
@@ -267,6 +268,7 @@ EInstalledRepository::perform_config(
n::maybe_output_manager() = output_manager,
n::package_builddir() = _imp->params.builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version()) + "-config"),
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() = ver_dir,
n::root() = stringify(_imp->params.root()),
n::sandbox() = phase->option("sandbox"),
@@ -374,6 +376,7 @@ EInstalledRepository::perform_info(
n::maybe_output_manager() = output_manager,
n::package_builddir() = _imp->params.builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version()) + "-info"),
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() = ver_dir,
n::root() = stringify(_imp->params.root()),
n::sandbox() = phase->option("sandbox"),
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 7621639..3322420 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -1669,6 +1669,7 @@ ERepository::get_environment_variable(
n::maybe_output_manager() = make_null_shared_ptr(),
n::package_builddir() = _imp->params.builddir() / (stringify(id->name().category()) + "-" + stringify(id->name().package()) + "-" + stringify(id->version()) + "-variable"),
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() =
(_imp->params.master_repositories() && ! _imp->params.master_repositories()->empty()) ?
(*_imp->params.master_repositories()->begin())->params().location() : _imp->params.location(),
diff --git a/paludis/repositories/e/e_repository_TEST_exheres_0.cc b/paludis/repositories/e/e_repository_TEST_exheres_0.cc
index b170394..01202e2 100644
--- a/paludis/repositories/e/e_repository_TEST_exheres_0.cc
+++ b/paludis/repositories/e/e_repository_TEST_exheres_0.cc
@@ -20,8 +20,8 @@
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/e_repository_exceptions.hh>
#include <paludis/repositories/e/e_repository_id.hh>
-#include <paludis/repositories/e/vdb_repository.hh>
#include <paludis/repositories/e/eapi.hh>
+#include <paludis/repositories/e/exndbam_repository.hh>
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
@@ -590,3 +590,64 @@ TEST(ERepository, InstallExheres0)
}
}
+TEST(ERepository, ReallyInstallExheres0)
+{
+ TestEnvironment env;
+ auto keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "e_repository_TEST_exheres_0_dir" / "repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_exheres_0_dir" / "repo/profiles/profile"));
+ keys->insert("layout", "exheres");
+ keys->insert("eapi_when_unknown", "exheres-0");
+ keys->insert("eapi_when_unspecified", "exheres-0");
+ keys->insert("profile_eapi_when_unspecified", "exheres-0");
+ keys->insert("distdir", stringify(FSPath::cwd() / "e_repository_TEST_exheres_0_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_exheres_0_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ auto i_keys(std::make_shared<Map<std::string, std::string>>());
+ i_keys->insert("format", "exndbam");
+ i_keys->insert("names_cache", "/var/empty");
+ i_keys->insert("location", stringify(FSPath::cwd() / "e_repository_TEST_exheres_0_dir" / "instrepo"));
+ i_keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_exheres_0_dir" / "build"));
+ i_keys->insert("root", stringify(FSPath::cwd() / "e_repository_TEST_exheres_0_dir" / "root"));
+ std::shared_ptr<Repository> i_repo(ExndbamRepository::repository_factory_create(&env,
+ std::bind(from_keys, i_keys, std::placeholders::_1)));
+ env.add_repository(1, i_repo);
+
+ InstallAction action(make_named_values<InstallActionOptions>(
+ n::destination() = i_repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &cannot_uninstall,
+ n::replacing() = std::make_shared<PackageIDSequence>(),
+ n::want_phase() = &want_all_phases
+ ));
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/exdirectory-phase-1",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/exdirectory-forbid-1",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/exdirectory-allow-1",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ id->perform_action(action);
+ }
+}
+
diff --git a/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh b/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh
index 489fc6c..b3619a9 100755
--- a/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh
+++ b/paludis/repositories/e/e_repository_TEST_exheres_0_setup.sh
@@ -6,8 +6,7 @@ cd e_repository_TEST_exheres_0_dir || exit 1
mkdir -p root/etc
-mkdir -p vdb
-touch vdb/THISISTHEVDB
+mkdir -p instrepo
mkdir -p build
ln -s build symlinked_build
@@ -1131,6 +1130,65 @@ pkg_setup() {
expecting_tests --expensive
}
END
+mkdir -p "packages/cat/exdirectory-phase"
+cat <<'END' > packages/cat/exdirectory-phase/exdirectory-phase-1.ebuild || exit 1
+DESCRIPTION="The Long Description"
+SUMMARY="The Short Description"
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS="spork"
+LICENCES="GPL-2"
+PLATFORMS="test"
+WORK="${WORKBASE}"
+
+src_install() {
+ exdirectory --allow /stuff
+}
+END
+mkdir -p "packages/cat/exdirectory-forbid"
+cat <<'END' > packages/cat/exdirectory-forbid/exdirectory-forbid-1.ebuild || exit 1
+DESCRIPTION="The Long Description"
+SUMMARY="The Short Description"
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS="spork"
+LICENCES="GPL-2"
+PLATFORMS="test"
+WORK="${WORKBASE}"
+
+pkg_setup() {
+ exdirectory --forbid /usr
+}
+
+src_install() {
+ herebin stuff <<EOT
+EOT
+}
+END
+mkdir -p "packages/cat/exdirectory-allow"
+cat <<'END' > packages/cat/exdirectory-allow/exdirectory-allow-1.ebuild || exit 1
+DESCRIPTION="The Long Description"
+SUMMARY="The Short Description"
+HOMEPAGE="http://example.com/"
+DOWNLOADS=""
+SLOT="0"
+MYOPTIONS="spork"
+LICENCES="GPL-2"
+PLATFORMS="test"
+WORK="${WORKBASE}"
+
+pkg_setup() {
+ exdirectory --allow /stuff
+}
+
+src_install() {
+ insinto /stuff
+ hereins it <<EOT
+EOT
+}
+END
cd ..
diff --git a/paludis/repositories/e/ebuild.cc b/paludis/repositories/e/ebuild.cc
index 8300dd4..f5a788b 100644
--- a/paludis/repositories/e/ebuild.cc
+++ b/paludis/repositories/e/ebuild.cc
@@ -40,6 +40,7 @@
#include <paludis/util/indirect_iterator-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/util/env_var_names.hh>
+#include <paludis/util/make_null_shared_ptr.hh>
#include <paludis/about.hh>
#include <paludis/environment.hh>
@@ -146,7 +147,7 @@ EbuildCommand::operator() ()
using namespace std::placeholders;
process.pipe_command_handler("PALUDIS_PIPE_COMMAND", std::bind(&pipe_command_handler, params.environment(),
- params.package_id(), in_metadata_generation(), _1, params.maybe_output_manager()));
+ params.package_id(), params.permitted_directories(), in_metadata_generation(), _1, params.maybe_output_manager()));
std::shared_ptr<const FSPathSequence> syncers_dirs(params.environment()->syncers_dirs());
std::shared_ptr<const FSPathSequence> bashrc_files(params.environment()->bashrc_files());
@@ -1051,7 +1052,7 @@ WriteVDBEntryCommand::operator() ()
.setenv("PALUDIS_PIPE_COMMANDS_SUPPORTED", "yes")
.setenv("PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED", "yes")
.pipe_command_handler("PALUDIS_PIPE_COMMAND", std::bind(&pipe_command_handler, params.environment(),
- params.package_id(), false, _1, params.maybe_output_manager()));
+ params.package_id(), make_null_shared_ptr(), false, _1, params.maybe_output_manager()));
if (! params.package_id()->eapi()->supported()->ebuild_metadata_variables()->iuse_effective()->name().empty())
if (params.package_id()->raw_iuse_effective_key())
@@ -1306,7 +1307,7 @@ WriteBinaryEbuildCommand::operator() ()
.setenv("PALUDIS_PIPE_COMMANDS_SUPPORTED", "yes")
.setenv("PALUDIS_PIPE_COMMANDS_STATUS_SUPPORTED", "yes")
.pipe_command_handler("PALUDIS_PIPE_COMMAND", std::bind(&pipe_command_handler, params.environment(),
- params.package_id(), false, _1, params.maybe_output_manager()));
+ params.package_id(), make_null_shared_ptr(), false, _1, params.maybe_output_manager()));
if (! params.package_id()->eapi()->supported()->ebuild_metadata_variables()->scm_revision()->name().empty())
if (params.package_id()->scm_revision_key())
diff --git a/paludis/repositories/e/ebuild.hh b/paludis/repositories/e/ebuild.hh
index 57259c3..c400a21 100644
--- a/paludis/repositories/e/ebuild.hh
+++ b/paludis/repositories/e/ebuild.hh
@@ -20,6 +20,8 @@
#ifndef PALUDIS_GUARD_PALUDIS_EBUILD_HH
#define PALUDIS_GUARD_PALUDIS_EBUILD_HH 1
+#include <paludis/repositories/e/permitted_directories-fwd.hh>
+
#include <paludis/util/attributes.hh>
#include <paludis/util/map-fwd.hh>
#include <paludis/util/process-fwd.hh>
@@ -83,6 +85,7 @@ namespace paludis
typedef Name<struct name_output_directory> output_directory;
typedef Name<struct name_package_builddir> package_builddir;
typedef Name<struct name_package_id> package_id;
+ typedef Name<struct name_permitted_directories> permitted_directories;
typedef Name<struct name_portdir> portdir;
typedef Name<struct name_profiles> profiles;
typedef Name<struct name_profiles_with_parents> profiles_with_parents;
@@ -128,6 +131,7 @@ namespace paludis
NamedValue<n::maybe_output_manager, std::shared_ptr<OutputManager> > maybe_output_manager;
NamedValue<n::package_builddir, FSPath> package_builddir;
NamedValue<n::package_id, std::shared_ptr<const erepository::ERepositoryID> > package_id;
+ NamedValue<n::permitted_directories, std::shared_ptr<erepository::PermittedDirectories> > permitted_directories;
NamedValue<n::portdir, FSPath> portdir;
NamedValue<n::root, std::string> root;
NamedValue<n::sandbox, bool> sandbox;
diff --git a/paludis/repositories/e/ebuild/exheres-0/output_functions.bash b/paludis/repositories/e/ebuild/exheres-0/output_functions.bash
index 5aa237e..9308508 100644
--- a/paludis/repositories/e/ebuild/exheres-0/output_functions.bash
+++ b/paludis/repositories/e/ebuild/exheres-0/output_functions.bash
@@ -40,3 +40,12 @@ exsetscmrevision()
paludis_pipe_command SET_SCM_REVISION "$EAPI" "$@" >/dev/null
}
+exdirectory()
+{
+ [[ "${!PALUDIS_EBUILD_PHASE_VAR}" == "setup" ]] || \
+ die "exdirectory must be called in pkg_setup"
+
+ paludis_pipe_command PERMIT_DIRECTORY "$EAPI" "$@" >/dev/null
+}
+
+
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 7ca7239..135be59 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -320,6 +320,7 @@ EbuildID::need_non_xml_keys_added() const
n::maybe_output_manager() = make_null_shared_ptr(),
n::package_builddir() = e_repo->params().builddir() / (stringify(name().category()) + "-" + stringify(name().package()) + "-" + stringify(version()) + "-metadata"),
n::package_id() = shared_from_this(),
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() =
(e_repo->params().master_repositories() && ! e_repo->params().master_repositories()->empty()) ?
(*e_repo->params().master_repositories()->begin())->params().location() : e_repo->params().location(),
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index a7ba233..11f0eee 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -608,6 +608,7 @@ ExndbamRepository::perform_uninstall(
n::maybe_output_manager() = output_manager,
n::package_builddir() = package_builddir,
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() = _imp->params.location(),
n::root() = stringify(_imp->params.root()),
n::sandbox() = phase->option("sandbox"),
diff --git a/paludis/repositories/e/permitted_directories-fwd.hh b/paludis/repositories/e/permitted_directories-fwd.hh
new file mode 100644
index 0000000..1d38743
--- /dev/null
+++ b/paludis/repositories/e/permitted_directories-fwd.hh
@@ -0,0 +1,31 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PERMITTED_DIRECTORIES_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PERMITTED_DIRECTORIES_FWD_HH 1
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class PermittedDirectories;
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/permitted_directories.cc b/paludis/repositories/e/permitted_directories.cc
new file mode 100644
index 0000000..bb2d76f
--- /dev/null
+++ b/paludis/repositories/e/permitted_directories.cc
@@ -0,0 +1,63 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/repositories/e/permitted_directories.hh>
+#include <paludis/util/pimp-impl.hh>
+
+#include <list>
+#include <string>
+
+using namespace paludis;
+using namespace paludis::erepository;
+
+namespace paludis
+{
+ template <>
+ struct Imp<PermittedDirectories>
+ {
+ std::list<std::pair<FSPath, bool> > rules;
+ };
+}
+
+PermittedDirectories::PermittedDirectories() :
+ _imp()
+{
+}
+
+PermittedDirectories::~PermittedDirectories() = default;
+
+void
+PermittedDirectories::add(const FSPath & p, bool b)
+{
+ _imp->rules.push_back(std::make_pair(p, b));
+}
+
+bool
+PermittedDirectories::permit(const FSPath & p) const
+{
+ bool result(true);
+
+ for (auto r(_imp->rules.begin()), r_end(_imp->rules.end()) ;
+ r != r_end ; ++r)
+ if (p.starts_with(r->first))
+ result = r->second;
+
+ return result;
+}
+
diff --git a/paludis/repositories/e/permitted_directories.hh b/paludis/repositories/e/permitted_directories.hh
new file mode 100644
index 0000000..fd013b7
--- /dev/null
+++ b/paludis/repositories/e/permitted_directories.hh
@@ -0,0 +1,47 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis 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, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PERMITTED_DIRECTORIES_HH
+#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PERMITTED_DIRECTORIES_HH 1
+
+#include <paludis/repositories/e/permitted_directories-fwd.hh>
+#include <paludis/util/pimp.hh>
+#include <paludis/util/fs_path.hh>
+
+namespace paludis
+{
+ namespace erepository
+ {
+ class PermittedDirectories
+ {
+ private:
+ Pimp<PermittedDirectories> _imp;
+
+ public:
+ PermittedDirectories();
+ ~PermittedDirectories();
+
+ void add(const FSPath &, bool);
+
+ bool permit(const FSPath &) const;
+ };
+ }
+}
+
+#endif
diff --git a/paludis/repositories/e/pipe_command_handler.cc b/paludis/repositories/e/pipe_command_handler.cc
index 85979b3..07af1ec 100644
--- a/paludis/repositories/e/pipe_command_handler.cc
+++ b/paludis/repositories/e/pipe_command_handler.cc
@@ -24,6 +24,7 @@
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/e/spec_tree_pretty_printer.hh>
#include <paludis/repositories/e/e_repository_id.hh>
+#include <paludis/repositories/e/permitted_directories.hh>
#include <paludis/util/log.hh>
#include <paludis/util/join.hh>
@@ -177,7 +178,9 @@ namespace
std::string
paludis::erepository::pipe_command_handler(const Environment * const environment,
- const std::shared_ptr<const ERepositoryID> & package_id, bool in_metadata_generation,
+ const std::shared_ptr<const ERepositoryID> & package_id,
+ const std::shared_ptr<PermittedDirectories> & maybe_permitted_directories,
+ bool in_metadata_generation,
const std::string & s, const std::shared_ptr<OutputManager> & maybe_output_manager)
{
Context context("In ebuild pipe command handler:");
@@ -524,6 +527,43 @@ paludis::erepository::pipe_command_handler(const Environment * const environment
return "O1;";
}
}
+ else if (tokens[0] == "PERMIT_DIRECTORY")
+ {
+ if (tokens.size() != 4)
+ {
+ Log::get_instance()->message("e.pipe_commands.permit_directory.bad", ll_warning, lc_context) << "Got bad PERMIT_DIRECTORY pipe command";
+ return "Ebad PERMIT_DIRECTORY command";
+ }
+
+ bool permit(true);
+ if (tokens[2] == "--allow")
+ permit = true;
+ else if (tokens[2] == "--forbid")
+ permit = false;
+ else
+ {
+ Log::get_instance()->message("e.pipe_commands.permit_directory.bad_argument", ll_warning, lc_context)
+ << "Got bad PERMIT_DIRECTORY pipe command argument";
+ return "Ebad PERMIT_DIRECTORY command argument";
+ }
+
+ if (! maybe_permitted_directories)
+ {
+ Log::get_instance()->message("e.pipe_commands.permit_directory.not_allowed", ll_warning, lc_context)
+ << "Got bad PERMIT_DIRECTORY pipe command: not allowed here";
+ return "Ebad PERMIT_DIRECTORY command: not allowed here";
+ }
+
+ if (0 != tokens[3].compare(0, 1, "/", 0, 1))
+ {
+ Log::get_instance()->message("e.pipe_commands.permit_directory.bad_argument", ll_warning, lc_context)
+ << "Got bad PERMIT_DIRECTORY pipe command argument";
+ return "Ebad PERMIT_DIRECTORY command argument";
+ }
+
+ maybe_permitted_directories->add(FSPath(tokens[3]), permit);
+ return "O0;";
+ }
else if (tokens[0] == "REWRITE_VAR")
{
if (tokens.size() < 4)
diff --git a/paludis/repositories/e/pipe_command_handler.hh b/paludis/repositories/e/pipe_command_handler.hh
index 6bc9979..f238f4c 100644
--- a/paludis/repositories/e/pipe_command_handler.hh
+++ b/paludis/repositories/e/pipe_command_handler.hh
@@ -20,6 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PIPE_COMMAND_HANDLER_HH
#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_PIPE_COMMAND_HANDLER_HH 1
+#include <paludis/repositories/e/permitted_directories-fwd.hh>
#include <paludis/environment-fwd.hh>
#include <paludis/package_id-fwd.hh>
#include <paludis/output_manager-fwd.hh>
@@ -34,6 +35,7 @@ namespace paludis
std::string pipe_command_handler(const Environment * const,
const std::shared_ptr<const ERepositoryID> &,
+ const std::shared_ptr<PermittedDirectories> &,
bool in_metadata_generation,
const std::string & s,
const std::shared_ptr<OutputManager> & maybe_output_manager);
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 0129849..fe26f26 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -482,6 +482,7 @@ VDBRepository::perform_uninstall(
n::maybe_output_manager() = output_manager,
n::package_builddir() = package_builddir,
n::package_id() = id,
+ n::permitted_directories() = make_null_shared_ptr(),
n::portdir() = _imp->params.location(),
n::root() = stringify(_imp->params.root()),
n::sandbox() = phase->option("sandbox"),
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index d9aecc2..3b61b5f 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -379,7 +379,7 @@ InstalledUnpackagedRepository::merge(const MergeParams & m)
n::output_manager() = m.output_manager(),
n::package_id() = m.package_id(),
n::permit_destination() = m.permit_destination(),
- n::root() = installed_root_key()->parse_value()
+ n::root() = installed_root_key()->parse_value().realpath()
));
if (m.check())