aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-06-24 01:26:14 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-06-24 01:26:14 +0100
commit571e096926ba2518e001dd1e7681cf1dfd94482d (patch)
tree08e37d825e300bf2615f0395d1075c2022f922e1
parent64f0748bd372d7fd7075d69dbdc730ffd93cc941 (diff)
downloadpaludis-571e096926ba2518e001dd1e7681cf1dfd94482d.tar.gz
paludis-571e096926ba2518e001dd1e7681cf1dfd94482d.tar.xz
importare can now change file ownership to root.
importare --rewrite-ids-over-to-root n will rewrite any uid or gid greater than n to 0. -1 disables, which is the default for now. Fixes: ticket:599
-rw-r--r--NEWS2
-rw-r--r--paludis/literal_metadata_key.cc12
-rw-r--r--paludis/literal_metadata_key.hh17
-rw-r--r--paludis/merger-fwd.hh4
-rw-r--r--paludis/merger.cc11
-rw-r--r--paludis/merger_TEST.cc11
-rw-r--r--paludis/ndbam_merger.cc1
-rw-r--r--paludis/ndbam_merger.hh4
-rw-r--r--paludis/repositories/e/exndbam_repository.cc15
-rw-r--r--paludis/repositories/e/vdb_merger.cc13
-rw-r--r--paludis/repositories/unpackaged/installed_repository.cc30
-rw-r--r--paludis/repositories/unpackaged/installed_repository_TEST.cc3
-rw-r--r--paludis/repositories/unpackaged/registration.cc9
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.cc4
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository.hh3
-rw-r--r--paludis/repositories/unpackaged/unpackaged_repository_TEST.cc6
-rw-r--r--paludis/util/keys.hh2
-rw-r--r--src/clients/importare/command_line.cc2
-rw-r--r--src/clients/importare/command_line.hh1
-rw-r--r--src/clients/importare/importare.cc3
20 files changed, 144 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index a1018a8..a3c3dda 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,8 @@ trunk/:
* New Selection + Filter + Generator interface using Environment, replacing
the old PackageDatabase Query (ticket:559).
+ * importare can now change file ownership to root (ticket:599).
+
0.26.1:
* Bug fix: if we install a directory using rename(), call utime() on all
file children.
diff --git a/paludis/literal_metadata_key.cc b/paludis/literal_metadata_key.cc
index 8eb9a36..25aa64d 100644
--- a/paludis/literal_metadata_key.cc
+++ b/paludis/literal_metadata_key.cc
@@ -136,6 +136,17 @@ LiteralMetadataStringSetKey::pretty_print_flat(const Formatter<std::string> & f)
return join(value()->begin(), value()->end(), " ", std::tr1::bind(&format_string, _1, f));
}
+ExtraLiteralMetadataValueKeyMethods<long>::~ExtraLiteralMetadataValueKeyMethods()
+{
+}
+
+std::string
+ExtraLiteralMetadataValueKeyMethods<long>::pretty_print() const
+{
+ long v(static_cast<const LiteralMetadataValueKey<long> *>(this)->value());
+ return stringify(v);
+}
+
ExtraLiteralMetadataValueKeyMethods<std::tr1::shared_ptr<const PackageID> >::~ExtraLiteralMetadataValueKeyMethods()
{
}
@@ -181,5 +192,6 @@ LiteralMetadataValueKey<T_>::value() const
template class LiteralMetadataValueKey<FSEntry>;
template class LiteralMetadataValueKey<std::string>;
template class LiteralMetadataValueKey<bool>;
+template class LiteralMetadataValueKey<long>;
template class LiteralMetadataValueKey<std::tr1::shared_ptr<const PackageID> >;
diff --git a/paludis/literal_metadata_key.hh b/paludis/literal_metadata_key.hh
index 0d4821a..02285f6 100644
--- a/paludis/literal_metadata_key.hh
+++ b/paludis/literal_metadata_key.hh
@@ -68,6 +68,23 @@ namespace paludis
};
/**
+ * Implement extra methods for LiteralMetadataValueKey for long.
+ *
+ * \ingroup g_metadata_key
+ * \since 0.28
+ */
+ template <>
+ class ExtraLiteralMetadataValueKeyMethods<long> :
+ public virtual ExtraMetadataValueKeyMethods<long>
+ {
+ public:
+ virtual ~ExtraLiteralMetadataValueKeyMethods() = 0;
+
+ virtual std::string pretty_print() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
+ /**
* A LiteralMetadataValueKey is a MetadataValueKey whose value is a
* copyable literal that is known at construction time.
*
diff --git a/paludis/merger-fwd.hh b/paludis/merger-fwd.hh
index 991d6a8..5fda85e 100644
--- a/paludis/merger-fwd.hh
+++ b/paludis/merger-fwd.hh
@@ -27,6 +27,7 @@
#include <paludis/util/keys.hh>
#include <paludis/util/fs_entry-fwd.hh>
#include <paludis/environment-fwd.hh>
+#include <tr1/functional>
/** \file
* Forward declarations for paludis/merger.hh .
@@ -68,7 +69,8 @@ namespace paludis
kc::Field<k::root, FSEntry>,
kc::Field<k::no_chown, bool>,
kc::Field<k::options, MergerOptions>,
- kc::Field<k::install_under, FSEntry>
+ kc::Field<k::install_under, FSEntry>,
+ kc::Field<k::get_new_ids_or_minus_one, std::tr1::function<std::pair<uid_t, gid_t> (const FSEntry &)> >
> MergerParams;
class MergerError;
diff --git a/paludis/merger.cc b/paludis/merger.cc
index 2653b61..cc0e9d1 100644
--- a/paludis/merger.cc
+++ b/paludis/merger.cc
@@ -664,19 +664,18 @@ Merger::do_ownership_fixes_recursive(const FSEntry & dir)
{
for (DirIterator d(dir, DirIteratorOptions() + dio_include_dotfiles + dio_inode_sort), d_end ; d != d_end ; ++d)
{
- uid_t new_uid(d->owner() == _imp->params[k::environment()]->reduced_uid() ? 0 : -1);
- gid_t new_gid(d->group() == _imp->params[k::environment()]->reduced_gid() ? 0 : -1);
- if (uid_t(-1) != new_uid || gid_t(-1) != new_gid)
+ std::pair<uid_t, gid_t> new_ids(_imp->params[k::get_new_ids_or_minus_one()](*d));
+ if (uid_t(-1) != new_ids.first || gid_t(-1) != new_ids.second)
{
FSEntry f(*d);
- f.lchown(new_uid, new_gid);
+ f.lchown(new_ids.first, new_ids.second);
if (et_dir == entry_type(*d))
{
mode_t mode(f.permissions());
- if (uid_t(-1) != new_uid)
+ if (uid_t(-1) != new_ids.first)
mode &= ~S_ISUID;
- if (gid_t(-1) != new_gid)
+ if (gid_t(-1) != new_ids.second)
mode &= ~S_ISGID;
f.chmod(mode);
}
diff --git a/paludis/merger_TEST.cc b/paludis/merger_TEST.cc
index e1d1c64..034be95 100644
--- a/paludis/merger_TEST.cc
+++ b/paludis/merger_TEST.cc
@@ -32,6 +32,15 @@
using namespace paludis;
using namespace test;
+namespace
+{
+ std::pair<uid_t, gid_t>
+ get_new_ids_or_minus_one(const FSEntry &)
+ {
+ return std::make_pair(-1, -1);
+ }
+}
+
namespace paludis
{
class HookTestEnvironment :
@@ -158,6 +167,7 @@ namespace
(k::install_under(), FSEntry("/"))
(k::environment(), &env)
(k::no_chown(), true)
+ (k::get_new_ids_or_minus_one(), &get_new_ids_or_minus_one)
(k::options(), MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs))
{
}
@@ -173,6 +183,7 @@ namespace
(k::install_under(), FSEntry("/"))
(k::environment(), &env)
(k::no_chown(), true)
+ (k::get_new_ids_or_minus_one(), &get_new_ids_or_minus_one)
(k::options(), o))
{
}
diff --git a/paludis/ndbam_merger.cc b/paludis/ndbam_merger.cc
index cf2b23f..81dbfa6 100644
--- a/paludis/ndbam_merger.cc
+++ b/paludis/ndbam_merger.cc
@@ -69,6 +69,7 @@ NDBAMMerger::NDBAMMerger(const NDBAMMergerParams & p) :
(k::root(), p[k::root()])
(k::no_chown(), ! getenv_with_default("PALUDIS_NO_CHOWN", "").empty())
(k::install_under(), p[k::install_under()])
+ (k::get_new_ids_or_minus_one(), p[k::get_new_ids_or_minus_one()])
(k::options(), p[k::options()])),
PrivateImplementationPattern<NDBAMMerger>(new Implementation<NDBAMMerger>(p)),
_imp(PrivateImplementationPattern<NDBAMMerger>::_imp)
diff --git a/paludis/ndbam_merger.hh b/paludis/ndbam_merger.hh
index 911267c..42ca550 100644
--- a/paludis/ndbam_merger.hh
+++ b/paludis/ndbam_merger.hh
@@ -24,6 +24,7 @@
#include <paludis/package_id-fwd.hh>
#include <paludis/util/kc-fwd.hh>
#include <paludis/util/keys.hh>
+#include <tr1/functional>
namespace paludis
{
@@ -36,7 +37,8 @@ namespace paludis
kc::Field<k::config_protect, std::string>,
kc::Field<k::config_protect_mask, std::string>,
kc::Field<k::package_id, std::tr1::shared_ptr<const PackageID> >,
- kc::Field<k::options, MergerOptions>
+ kc::Field<k::options, MergerOptions>,
+ kc::Field<k::get_new_ids_or_minus_one, std::tr1::function<std::pair<uid_t, gid_t> (const FSEntry &)> >
> NDBAMMergerParams;
/**
diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc
index d129ade..d64cfc0 100644
--- a/paludis/repositories/e/exndbam_repository.cc
+++ b/paludis/repositories/e/exndbam_repository.cc
@@ -43,6 +43,7 @@
#include <paludis/package_id.hh>
#include <paludis/action.hh>
#include <paludis/literal_metadata_key.hh>
+#include <tr1/functional>
#include <fstream>
using namespace paludis;
@@ -264,6 +265,18 @@ ExndbamRepository::need_keys_added() const
{
}
+namespace
+{
+ std::pair<uid_t, gid_t>
+ get_new_ids_or_minus_one(const Environment * const env, const FSEntry & f)
+ {
+ if (f.owner() == env->reduced_uid() || f.group() == env->reduced_gid())
+ return std::make_pair(0, 0);
+ else
+ return std::make_pair(-1, -1);
+ }
+}
+
void
ExndbamRepository::merge(const MergeParams & m)
{
@@ -337,6 +350,8 @@ ExndbamRepository::merge(const MergeParams & m)
(k::config_protect(), config_protect)
(k::config_protect_mask(), config_protect_mask)
(k::package_id(), m[k::package_id()])
+ (k::get_new_ids_or_minus_one(), std::tr1::bind(&get_new_ids_or_minus_one, _imp->params.environment,
+ std::tr1::placeholders::_1))
(k::options(), m[k::options()]));
if (! merger.check())
diff --git a/paludis/repositories/e/vdb_merger.cc b/paludis/repositories/e/vdb_merger.cc
index a62b040..2d30cf4 100644
--- a/paludis/repositories/e/vdb_merger.cc
+++ b/paludis/repositories/e/vdb_merger.cc
@@ -62,6 +62,18 @@ namespace paludis
};
}
+namespace
+{
+ std::pair<uid_t, gid_t>
+ get_new_ids_or_minus_one(const Environment * const env, const FSEntry & f)
+ {
+ if (f.owner() == env->reduced_uid() || f.group() == env->reduced_gid())
+ return std::make_pair(0, 0);
+ else
+ return std::make_pair(-1, -1);
+ }
+}
+
VDBMerger::VDBMerger(const VDBMergerParams & p) :
Merger(MergerParams::named_create()
(k::environment(), p[k::environment()])
@@ -69,6 +81,7 @@ VDBMerger::VDBMerger(const VDBMergerParams & p) :
(k::install_under(), FSEntry("/"))
(k::root(), p[k::root()])
(k::no_chown(), ! getenv_with_default("PALUDIS_NO_CHOWN", "").empty())
+ (k::get_new_ids_or_minus_one(), std::tr1::bind(&get_new_ids_or_minus_one, p[k::environment()], std::tr1::placeholders::_1))
(k::options(), p[k::options()])),
PrivateImplementationPattern<VDBMerger>(new Implementation<VDBMerger>(p)),
_imp(PrivateImplementationPattern<VDBMerger>::_imp)
diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc
index 4379d08..03fe9f7 100644
--- a/paludis/repositories/unpackaged/installed_repository.cc
+++ b/paludis/repositories/unpackaged/installed_repository.cc
@@ -223,9 +223,26 @@ InstalledUnpackagedRepository::some_ids_might_support_action(const SupportsActio
return v.result;
}
+namespace
+{
+ std::pair<uid_t, gid_t>
+ get_new_ids_or_minus_one(const Environment * const env, const int rewrite_ids_over_to_root, const FSEntry & f)
+ {
+ if (f.owner() == env->reduced_uid() || f.group() == env->reduced_gid())
+ return std::make_pair(0, 0);
+ else if ((-1 != rewrite_ids_over_to_root) && (f.owner() > static_cast<unsigned int>(rewrite_ids_over_to_root)
+ || f.group() > static_cast<unsigned int>(rewrite_ids_over_to_root)))
+ return std::make_pair(0, 0);
+ else
+ return std::make_pair(-1, -1);
+ }
+}
+
void
InstalledUnpackagedRepository::merge(const MergeParams & m)
{
+ using namespace std::tr1::placeholders;
+
Context context("When merging '" + stringify(*m[k::package_id()]) + "' at '" + stringify(m[k::image_dir()])
+ "' to InstalledUnpackagedRepository repository '" + stringify(name()) + "':");
@@ -243,6 +260,17 @@ InstalledUnpackagedRepository::merge(const MergeParams & m)
install_under = kk->value();
}
+ int rewrite_ids_over_to_root(-1);
+ {
+ Repository::MetadataConstIterator k(m[k::package_id()]->repository()->find_metadata("rewrite_ids_over_to_root"));
+ if (k == m[k::package_id()]->repository()->end_metadata())
+ throw InstallActionError("Could not fetch rewrite_ids_over_to_root key from owning repository");
+ const MetadataValueKey<long> * kk(visitor_cast<const MetadataValueKey<long> >(**k));
+ if (! kk)
+ throw InstallActionError("Fetched rewrite_ids_over_to_root key but did not get a long key from owning repository");
+ rewrite_ids_over_to_root = kk->value();
+ }
+
std::tr1::shared_ptr<const PackageID> if_overwritten_id, if_same_name_id;
{
std::tr1::shared_ptr<const PackageIDSequence> ids(package_ids(m[k::package_id()]->name()));
@@ -321,6 +349,8 @@ InstalledUnpackagedRepository::merge(const MergeParams & m)
(k::config_protect(), getenv_with_default("CONFIG_PROTECT", ""))
(k::config_protect_mask(), getenv_with_default("CONFIG_PROTECT_MASK", ""))
(k::package_id(), m[k::package_id()])
+ (k::get_new_ids_or_minus_one(), std::tr1::bind(&get_new_ids_or_minus_one, _imp->params.environment,
+ rewrite_ids_over_to_root, _1))
(k::options(), MergerOptions() + mo_rewrite_symlinks + mo_allow_empty_dirs));
if (! merger.check())
diff --git a/paludis/repositories/unpackaged/installed_repository_TEST.cc b/paludis/repositories/unpackaged/installed_repository_TEST.cc
index 58a4908..23479a8 100644
--- a/paludis/repositories/unpackaged/installed_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/installed_repository_TEST.cc
@@ -376,6 +376,7 @@ namespace test_cases
(k::install_under(), FSEntry("/"))
(k::build_dependencies(), "")
(k::run_dependencies(), "")
+ (k::rewrite_ids_over_to_root(), -1)
(k::description(), "")
));
env.package_database()->add_repository(1, source_repo);
@@ -431,6 +432,7 @@ namespace test_cases
(k::install_under(), FSEntry("/"))
(k::build_dependencies(), "")
(k::run_dependencies(), "")
+ (k::rewrite_ids_over_to_root(), -1)
(k::description(), "")
));
env.package_database()->add_repository(1, source_repo);
@@ -487,6 +489,7 @@ namespace test_cases
(k::location(), FSEntry("installed_repository_TEST_dir/src4b2"))
(k::install_under(), FSEntry("/"))
(k::build_dependencies(), "")
+ (k::rewrite_ids_over_to_root(), -1)
(k::run_dependencies(), "")
(k::description(), "")
));
diff --git a/paludis/repositories/unpackaged/registration.cc b/paludis/repositories/unpackaged/registration.cc
index 34affa7..117bec5 100644
--- a/paludis/repositories/unpackaged/registration.cc
+++ b/paludis/repositories/unpackaged/registration.cc
@@ -21,6 +21,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/destringify.hh>
#include <paludis/repositories/unpackaged/installed_repository.hh>
#include <paludis/repositories/unpackaged/unpackaged_repository.hh>
#include <paludis/repositories/unpackaged/exceptions.hh>
@@ -68,6 +69,13 @@ namespace
if (m->end() != m->find("description"))
description = m->find("description")->second;
+ int rewrite_ids_over_to_root(-1);
+ if (m->end() != m->find("rewrite_ids_over_to_root") && ! m->find("rewrite_ids_over_to_root")->second.empty())
+ {
+ Context item_context("When handling rewrite_ids_over_to_root key:");
+ rewrite_ids_over_to_root = destringify<int>(m->find("rewrite_ids_over_to_root")->second);
+ }
+
return make_shared_ptr(new UnpackagedRepository(RepositoryName("unpackaged"),
unpackaged_repositories::UnpackagedRepositoryParams::named_create()
(k::environment(), env)
@@ -78,6 +86,7 @@ namespace
(k::slot(), SlotName(slot))
(k::build_dependencies(), build_dependencies)
(k::run_dependencies(), run_dependencies)
+ (k::rewrite_ids_over_to_root(), rewrite_ids_over_to_root)
(k::description(), description)));
}
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.cc b/paludis/repositories/unpackaged/unpackaged_repository.cc
index 794400d..410aeb9 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository.cc
@@ -45,6 +45,7 @@ namespace paludis
std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > location_key;
std::tr1::shared_ptr<const MetadataValueKey<FSEntry> > install_under_key;
+ std::tr1::shared_ptr<const MetadataValueKey<long> > rewrite_ids_over_to_root_key;
std::tr1::shared_ptr<const MetadataValueKey<std::string> > name_key;
std::tr1::shared_ptr<const MetadataValueKey<std::string> > slot_key;
std::tr1::shared_ptr<const MetadataValueKey<std::string> > format_key;
@@ -64,6 +65,8 @@ namespace paludis
mkt_significant, params[k::location()])),
install_under_key(new LiteralMetadataValueKey<FSEntry> ("install_under", "install_under",
mkt_significant, params[k::install_under()])),
+ rewrite_ids_over_to_root_key(new LiteralMetadataValueKey<long> ("rewrite_ids_over_to_root", "rewrite_ids_over_to_root",
+ mkt_normal, params[k::rewrite_ids_over_to_root()])),
name_key(new LiteralMetadataValueKey<std::string> ("name", "name",
mkt_normal, stringify(params[k::name()]))),
slot_key(new LiteralMetadataValueKey<std::string> ("slot", "slot",
@@ -116,6 +119,7 @@ UnpackagedRepository::_add_metadata_keys() const
clear_metadata_keys();
add_metadata_key(_imp->location_key);
add_metadata_key(_imp->install_under_key);
+ add_metadata_key(_imp->rewrite_ids_over_to_root_key);
add_metadata_key(_imp->name_key);
add_metadata_key(_imp->slot_key);
add_metadata_key(_imp->format_key);
diff --git a/paludis/repositories/unpackaged/unpackaged_repository.hh b/paludis/repositories/unpackaged/unpackaged_repository.hh
index 0d27f1b..2f72592 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository.hh
+++ b/paludis/repositories/unpackaged/unpackaged_repository.hh
@@ -39,7 +39,8 @@ namespace paludis
kc::Field<k::slot, SlotName>,
kc::Field<k::build_dependencies, std::string>,
kc::Field<k::run_dependencies, std::string>,
- kc::Field<k::description, std::string>
+ kc::Field<k::description, std::string>,
+ kc::Field<k::rewrite_ids_over_to_root, int>
> UnpackagedRepositoryParams;
}
diff --git a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
index bbff750..0a39157 100644
--- a/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
+++ b/paludis/repositories/unpackaged/unpackaged_repository_TEST.cc
@@ -61,6 +61,7 @@ namespace test_cases
(k::build_dependencies(), "")
(k::run_dependencies(), "")
(k::description(), "")
+ (k::rewrite_ids_over_to_root(), -1)
));
env.package_database()->add_repository(1, repo);
@@ -89,6 +90,7 @@ namespace test_cases
(k::install_under(), FSEntry("/"))
(k::build_dependencies(), "")
(k::run_dependencies(), "")
+ (k::rewrite_ids_over_to_root(), -1)
(k::description(), "")
));
env.package_database()->add_repository(1, repo);
@@ -123,6 +125,7 @@ namespace test_cases
(k::install_under(), FSEntry("/"))
(k::build_dependencies(), "")
(k::run_dependencies(), "")
+ (k::rewrite_ids_over_to_root(), -1)
(k::description(), "")
));
env.package_database()->add_repository(1, repo);
@@ -152,6 +155,7 @@ namespace test_cases
(k::install_under(), FSEntry("/"))
(k::build_dependencies(), "")
(k::run_dependencies(), "")
+ (k::rewrite_ids_over_to_root(), -1)
(k::description(), "")
));
env.package_database()->add_repository(1, repo);
@@ -194,6 +198,7 @@ namespace test_cases
(k::install_under(), FSEntry("/"))
(k::build_dependencies(), "")
(k::run_dependencies(), "")
+ (k::rewrite_ids_over_to_root(), -1)
(k::description(), "")
));
env.package_database()->add_repository(1, repo);
@@ -248,6 +253,7 @@ namespace test_cases
(k::install_under(), FSEntry("/magic/pixie"))
(k::build_dependencies(), "")
(k::run_dependencies(), "")
+ (k::rewrite_ids_over_to_root(), -1)
(k::description(), "")
));
env.package_database()->add_repository(1, repo);
diff --git a/paludis/util/keys.hh b/paludis/util/keys.hh
index ef81f5b..0b0dcec 100644
--- a/paludis/util/keys.hh
+++ b/paludis/util/keys.hh
@@ -183,6 +183,8 @@ namespace paludis
typedef kc::Key<154> repository;
typedef kc::Key<155> repository_homepage;
typedef kc::Key<156> repository_description;
+ typedef kc::Key<157> get_new_ids_or_minus_one;
+ typedef kc::Key<158> rewrite_ids_over_to_root;
}
}
diff --git a/src/clients/importare/command_line.cc b/src/clients/importare/command_line.cc
index c01571b..1352096 100644
--- a/src/clients/importare/command_line.cc
+++ b/src/clients/importare/command_line.cc
@@ -46,6 +46,8 @@ CommandLine::CommandLine() :
"Options affecting the source image"),
a_location(&source_args, "location", 'l', "Location of source image (default: current directory)"),
a_install_under(&source_args, "install-under", 'u', "Install under a given directory (default: /)"),
+ a_rewrite_ids_over_to_root(&source_args, "rewrite-ids-over-to-root", 'r',
+ "Change any UID or GID over this value to 0 (-1 disables, default)"),
metadata_args(this, "Metadata options",
"Options affecting generated metadata"),
diff --git a/src/clients/importare/command_line.hh b/src/clients/importare/command_line.hh
index 1ddf7cf..85c1184 100644
--- a/src/clients/importare/command_line.hh
+++ b/src/clients/importare/command_line.hh
@@ -56,6 +56,7 @@ class CommandLine :
paludis::args::ArgsGroup source_args;
paludis::args::StringArg a_location;
paludis::args::StringArg a_install_under;
+ paludis::args::IntegerArg a_rewrite_ids_over_to_root;
paludis::args::ArgsGroup metadata_args;
paludis::args::StringArg a_description;
diff --git a/src/clients/importare/importare.cc b/src/clients/importare/importare.cc
index bf5fb8a..55a1a8b 100644
--- a/src/clients/importare/importare.cc
+++ b/src/clients/importare/importare.cc
@@ -181,6 +181,9 @@ main(int argc, char *argv[])
CommandLine::get_instance()->a_install_under.specified() ?
FSEntry(CommandLine::get_instance()->a_install_under.argument()) :
FSEntry("/")));
+ keys->insert("rewrite_ids_over_to_root", stringify(
+ CommandLine::get_instance()->a_rewrite_ids_over_to_root.specified() ?
+ CommandLine::get_instance()->a_rewrite_ids_over_to_root.argument() : -1));
keys->insert("format", "unpackaged");
keys->insert("name", stringify(q));
keys->insert("version", stringify(v));