aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-09-01 16:30:15 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2008-09-01 16:30:15 +0100
commit78ce4a65b080ac2a3bb8a569c2f9d317f0906e67 (patch)
tree8c23061e4b2450b95f090a97abd7544bc8675f5d
parenteebdfdbd65a7971d2cbb5812dea42ef05dd899cf (diff)
downloadpaludis-78ce4a65b080ac2a3bb8a569c2f9d317f0906e67.tar.gz
paludis-78ce4a65b080ac2a3bb8a569c2f9d317f0906e67.tar.xz
userpriv is mandatory on exherbo
Fixes: ticket:638
-rw-r--r--paludis/distributions/exherbo/paludis.conf1
-rw-r--r--paludis/distributions/gentoo/paludis.conf1
-rw-r--r--paludis/environments/paludis/extra_distribution_data.cc2
-rw-r--r--paludis/environments/paludis/extra_distribution_data.hh2
-rw-r--r--paludis/environments/paludis/paludis_config.cc23
5 files changed, 25 insertions, 4 deletions
diff --git a/paludis/distributions/exherbo/paludis.conf b/paludis/distributions/exherbo/paludis.conf
index b3d12cf..cd01858 100644
--- a/paludis/distributions/exherbo/paludis.conf
+++ b/paludis/distributions/exherbo/paludis.conf
@@ -1,6 +1,7 @@
bashrc_filename = bashrc
keywords_filename_part = platforms
licenses_filename_part = licences
+mandatory_userpriv = true
mirrors_filename_part = mirrors
package_mask_filename_part = package_mask
package_unmask_filename_part = package_unmask
diff --git a/paludis/distributions/gentoo/paludis.conf b/paludis/distributions/gentoo/paludis.conf
index 204670e..1c5b97e 100644
--- a/paludis/distributions/gentoo/paludis.conf
+++ b/paludis/distributions/gentoo/paludis.conf
@@ -1,6 +1,7 @@
bashrc_filename = bashrc
keywords_filename_part = keywords
licenses_filename_part = licenses
+mandatory_userpriv = false
mirrors_filename_part = mirrors
package_mask_filename_part = package_mask
package_unmask_filename_part = package_unmask
diff --git a/paludis/environments/paludis/extra_distribution_data.cc b/paludis/environments/paludis/extra_distribution_data.cc
index 345d67e..68d1d07 100644
--- a/paludis/environments/paludis/extra_distribution_data.cc
+++ b/paludis/environments/paludis/extra_distribution_data.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/environments/paludis/extra_distribution_data.hh>
+#include <paludis/util/destringify.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/distribution-impl.hh>
@@ -41,6 +42,7 @@ namespace paludis
value_for<n::bashrc_filename>(k->get("bashrc_filename")),
value_for<n::keywords_filename_part>(k->get("keywords_filename_part")),
value_for<n::licenses_filename_part>(k->get("licenses_filename_part")),
+ value_for<n::mandatory_userpriv>(destringify<bool>(k->get("mandatory_userpriv"))),
value_for<n::mirrors_filename_part>(k->get("mirrors_filename_part")),
value_for<n::package_mask_filename_part>(k->get("package_mask_filename_part")),
value_for<n::package_unmask_filename_part>(k->get("package_unmask_filename_part")),
diff --git a/paludis/environments/paludis/extra_distribution_data.hh b/paludis/environments/paludis/extra_distribution_data.hh
index 7c4de48..963fa6f 100644
--- a/paludis/environments/paludis/extra_distribution_data.hh
+++ b/paludis/environments/paludis/extra_distribution_data.hh
@@ -31,6 +31,7 @@ namespace paludis
struct bashrc_filename;
struct keywords_filename_part;
struct licenses_filename_part;
+ struct mandatory_userpriv;
struct mirrors_filename_part;
struct package_mask_filename_part;
struct package_unmask_filename_part;
@@ -46,6 +47,7 @@ namespace paludis
NamedValue<n::bashrc_filename, std::string> bashrc_filename;
NamedValue<n::keywords_filename_part, std::string> keywords_filename_part;
NamedValue<n::licenses_filename_part, std::string> licenses_filename_part;
+ NamedValue<n::mandatory_userpriv, bool> mandatory_userpriv;
NamedValue<n::mirrors_filename_part, std::string> mirrors_filename_part;
NamedValue<n::package_mask_filename_part, std::string> package_mask_filename_part;
NamedValue<n::package_unmask_filename_part, std::string> package_unmask_filename_part;
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index 53ac71c..1f4cc63 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -443,6 +443,11 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
_imp->root = root_prefix.empty() ? "/" : root_prefix;
_imp->config_dir = stringify(local_config_dir);
+
+ const std::tr1::shared_ptr<const PaludisDistribution> dist(
+ PaludisExtraDistributionData::get_instance()->data_from_distribution(
+ *DistributionData::get_instance()->distribution_from_string(distribution())));
+
/* check that we can safely use userpriv */
{
Command cmd(Command("ls -ld '" + stringify(local_config_dir) + "'/* >/dev/null 2>/dev/null")
@@ -456,11 +461,21 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
_imp->reduced_uid.reset(new uid_t(getuid()));
_imp->reduced_gid.reset(new gid_t(getgid()));
}
- }
- const std::tr1::shared_ptr<const PaludisDistribution> dist(
- PaludisExtraDistributionData::get_instance()->data_from_distribution(
- *DistributionData::get_instance()->distribution_from_string(distribution())));
+ if (dist->mandatory_userpriv() && ((0 == *_imp->reduced_uid || 0 == *_imp->reduced_gid)))
+ {
+ std::string s;
+ if (0 == *_imp->reduced_uid)
+ s = "uid " + stringify(*_imp->reduced_uid);
+ if (0 == *_imp->reduced_gid)
+ {
+ if (! s.empty())
+ s.append(" or ");
+ s.append("gid " + stringify(*_imp->reduced_gid));
+ }
+ throw PaludisConfigError("Cannot use " + s + " for userpriv");
+ }
+ }
std::tr1::function<std::string (const std::string &)> predefined_conf_vars_func(
std::tr1::bind(&initial_conf_vars, root_prefix, std::tr1::placeholders::_1));