aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-22 19:13:03 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-22 19:13:03 +0000
commit906f9be9f7b137bb5350a20676a833a26454fca8 (patch)
tree216e5d575a522ce10762196f77361ed461a59405
parentdc997e46f68620b05f314b30c4efafb5b0848df2 (diff)
downloadpaludis-906f9be9f7b137bb5350a20676a833a26454fca8.tar.gz
paludis-906f9be9f7b137bb5350a20676a833a26454fca8.tar.xz
More userpriv work
-rw-r--r--paludis/repositories/gentoo/ebuild.cc2
-rw-r--r--paludis/repositories/gentoo/ebuild.sr2
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.cc15
3 files changed, 15 insertions, 4 deletions
diff --git a/paludis/repositories/gentoo/ebuild.cc b/paludis/repositories/gentoo/ebuild.cc
index c23e3b5..d652a48 100644
--- a/paludis/repositories/gentoo/ebuild.cc
+++ b/paludis/repositories/gentoo/ebuild.cc
@@ -385,7 +385,7 @@ EbuildInstallCommand::extend_command(const Command & cmd)
j(install_params.expand_vars->end()) ; i != j ; ++i)
result.with_setenv(i->first, i->second);
- if (ebuild_ip_build == install_params.phase && ! install_params.no_userpriv)
+ if (ebuild_ip_build == install_params.phase && install_params.userpriv)
result.with_uid_gid(params.environment->reduced_uid(), params.environment->reduced_gid());
return result;
diff --git a/paludis/repositories/gentoo/ebuild.sr b/paludis/repositories/gentoo/ebuild.sr
index ccc2b2e..2bc5012 100644
--- a/paludis/repositories/gentoo/ebuild.sr
+++ b/paludis/repositories/gentoo/ebuild.sr
@@ -61,7 +61,7 @@ make_class_EbuildInstallCommandParams()
key profiles "std::tr1::shared_ptr<const FSEntryCollection>"
key expand_vars "std::tr1::shared_ptr<const AssociativeCollection<std::string, std::string> >"
key disable_cfgpro bool
- key no_userpriv bool
+ key userpriv bool
key debug_build InstallDebugOption
key slot SlotName
key phase EbuildInstallCommandPhase
diff --git a/paludis/repositories/gentoo/ebuild_entries.cc b/paludis/repositories/gentoo/ebuild_entries.cc
index 8148e49..3102e7d 100644
--- a/paludis/repositories/gentoo/ebuild_entries.cc
+++ b/paludis/repositories/gentoo/ebuild_entries.cc
@@ -254,13 +254,15 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
PackageDatabaseEntry e(q, v, _imp->portage_repository->name());
- bool fetch_restrict(false), no_mirror(false);
+ bool fetch_restrict(false), no_mirror(false), userpriv_restrict;
{
std::list<std::string> restricts;
WhitespaceTokeniser::get_instance()->tokenise(
metadata->ebuild_interface->restrict_string, std::back_inserter(restricts));
fetch_restrict = (restricts.end() != std::find(restricts.begin(), restricts.end(), "fetch")) ||
(restricts.end() != std::find(restricts.begin(), restricts.end(), "nofetch"));
+ userpriv_restrict = (restricts.end() != std::find(restricts.begin(), restricts.end(), "userpriv")) ||
+ (restricts.end() != std::find(restricts.begin(), restricts.end(), "nouserpriv"));
no_mirror = (restricts.end() != std::find(restricts.begin(), restricts.end(), "mirror")) ||
(restricts.end() != std::find(restricts.begin(), restricts.end(), "nomirror"));
}
@@ -481,6 +483,15 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
throw PackageInstallActionError("Can't install '" + stringify(q) + "-"
+ stringify(v) + "' because no destinations were provided");
+ bool userpriv_ok((! userpriv_restrict) && (_imp->environment->reduced_gid() != getgid()));
+ if (userpriv_ok && FSEntry(_imp->params.buildroot).group() != _imp->environment->reduced_gid())
+ {
+ Log::get_instance()->message(ll_warning, lc_context, "Directory '" +
+ stringify(_imp->params.buildroot) + "' does not have gid '" +
+ stringify(_imp->environment->reduced_gid()) + "', cannot enable userpriv");
+ userpriv_ok = false;
+ }
+
EbuildInstallCommandParams install_params(
EbuildInstallCommandParams::create()
.phase(ebuild_ip_build)
@@ -497,7 +508,7 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
.config_protect_mask(_imp->portage_repository->profile_variable("CONFIG_PROTECT_MASK"))
.loadsaveenv_dir(_imp->params.buildroot / stringify(q.category) / (
stringify(q.package) + "-" + stringify(v)) / "temp")
- .no_userpriv(false)
+ .userpriv(userpriv_ok)
.slot(SlotName(metadata->slot)));
EbuildInstallCommand build_cmd(command_params, install_params);