aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-12 00:39:21 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-12 00:39:21 +0000
commit18c1ceed03e53ce9273482867ef9697b46dcc9b0 (patch)
treee7c32dd36caf30b09f043c10927d3ea1b68ee9c0
parent337644c6c8c5251b6bb67b6d380cc11bbd3b4f31 (diff)
downloadpaludis-18c1ceed03e53ce9273482867ef9697b46dcc9b0.tar.gz
paludis-18c1ceed03e53ce9273482867ef9697b46dcc9b0.tar.xz
More userpriv work
-rw-r--r--paludis/merger/merger.cc29
-rw-r--r--paludis/merger/merger.sr1
-rw-r--r--paludis/merger/merger_TEST.cc3
-rw-r--r--paludis/repositories/gentoo/ebuild.cc5
-rw-r--r--paludis/repositories/gentoo/ebuild.se1
-rw-r--r--paludis/repositories/gentoo/ebuild_entries.cc4
-rw-r--r--paludis/repositories/gentoo/vdb_merger.cc4
-rw-r--r--paludis/util/fs_entry.cc3
-rw-r--r--src/clients/paludis/Makefile.am1
9 files changed, 44 insertions, 7 deletions
diff --git a/paludis/merger/merger.cc b/paludis/merger/merger.cc
index ff192bf..d4b45ad 100644
--- a/paludis/merger/merger.cc
+++ b/paludis/merger/merger.cc
@@ -119,6 +119,8 @@ Merger::merge()
MergerEntryType
Merger::entry_type(const FSEntry & f)
{
+ Context context("When checking type of '" + stringify(f) + "':");
+
if (! f.exists())
return met_nothing;
@@ -184,6 +186,8 @@ Merger::do_dir_recursive(bool is_check, const FSEntry & src, const FSEntry & dst
void
Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
{
+ Context context("When handling file '" + stringify(src) + "' to '" + stringify(dst) + "':");
+
MergerEntryType m(entry_type(dst / src.basename()));
if (is_check &&
@@ -235,6 +239,8 @@ Merger::on_file(bool is_check, const FSEntry & src, const FSEntry & dst)
void
Merger::on_dir(bool is_check, const FSEntry & src, const FSEntry & dst)
{
+ Context context("When handling dir '" + stringify(src) + "' to '" + stringify(dst) + "':");
+
MergerEntryType m(entry_type(dst / src.basename()));
if (is_check &&
@@ -287,6 +293,8 @@ Merger::on_dir(bool is_check, const FSEntry & src, const FSEntry & dst)
void
Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
{
+ Context context("When handling sym '" + stringify(src) + "' to '" + stringify(dst) + "':");
+
MergerEntryType m(entry_type(dst / src.basename()));
if (is_check &&
@@ -338,6 +346,8 @@ Merger::on_sym(bool is_check, const FSEntry & src, const FSEntry & dst)
void
Merger::on_misc(bool is_check, const FSEntry & src, const FSEntry & dst)
{
+ Context context("When handling misc '" + stringify(src) + "' to '" + stringify(dst) + "':");
+
on_error(is_check, "Cannot write '" + stringify(src) + "' to '" + stringify(dst) +
"' because it is not a recognised file type");
}
@@ -525,6 +535,9 @@ Merger::on_sym_over_misc(bool is_check, const FSEntry & src, const FSEntry & dst
void
Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::string & dst_name)
{
+ Context context("When installing file '" + stringify(src) + "' to '" + stringify(dst_dir) + "' with protection '"
+ + stringify(dst_name) + "':");
+
if (0 != _options.environment->perform_hook(extend_hook(
Hook("merger_install_file_pre")
("INSTALL_SOURCE", stringify(src))
@@ -542,8 +555,11 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
if (-1 == output_fd)
throw MergerError("Cannot write '" + stringify(dst_dir / dst_name) + "'");
- if (0 != ::fchown(output_fd, src.owner(), src.group()))
- throw MergerError("Cannot fchown '" + stringify(dst_dir / dst_name) + "'");
+ if (! _options.no_chown)
+ if (0 != ::fchown(output_fd,
+ src.owner() == _options.environment->reduced_uid() ? 0 : src.owner(),
+ src.group() == _options.environment->reduced_gid() ? 0 : src.group()))
+ throw MergerError("Cannot fchown '" + stringify(dst_dir / dst_name) + "'");
/* set*id bits */
if (0 != ::fchmod(output_fd, src.permissions()))
@@ -565,6 +581,8 @@ Merger::install_file(const FSEntry & src, const FSEntry & dst_dir, const std::st
void
Merger::install_dir(const FSEntry & src, const FSEntry & dst_dir)
{
+ Context context("When installing dir '" + stringify(src) + "' to '" + stringify(dst_dir) + "':");
+
if (0 != _options.environment->perform_hook(extend_hook(
Hook("merger_install_dir_pre")
("INSTALL_SOURCE", stringify(src))
@@ -576,7 +594,10 @@ Merger::install_dir(const FSEntry & src, const FSEntry & dst_dir)
FSEntry dst(dst_dir / src.basename());
FSCreateCon createcon(MatchPathCon::get_instance()->match(stringify(dst), mode));
dst.mkdir(mode);
- dst.chown(src.owner(), src.group());
+ if (! _options.no_chown)
+ dst.chown(
+ src.owner() == _options.environment->reduced_uid() ? 0 : src.owner(),
+ src.group() == _options.environment->reduced_gid() ? 0 : src.group());
/* pick up set*id bits */
dst.chmod(src.permissions());
@@ -591,6 +612,8 @@ Merger::install_dir(const FSEntry & src, const FSEntry & dst_dir)
void
Merger::install_sym(const FSEntry & src, const FSEntry & dst_dir)
{
+ Context context("When installing sym '" + stringify(src) + "' to '" + stringify(dst_dir) + "':");
+
if (0 != _options.environment->perform_hook(extend_hook(
Hook("merger_install_sym_pre")
("INSTALL_SOURCE", stringify(src))
diff --git a/paludis/merger/merger.sr b/paludis/merger/merger.sr
index d4dc0ac..cbf3526 100644
--- a/paludis/merger/merger.sr
+++ b/paludis/merger/merger.sr
@@ -6,6 +6,7 @@ make_class_MergerOptions()
key environment "Environment *"
key image "FSEntry"
key root "FSEntry"
+ key no_chown bool
allow_named_args
diff --git a/paludis/merger/merger_TEST.cc b/paludis/merger/merger_TEST.cc
index 7c6b90b..615c742 100644
--- a/paludis/merger/merger_TEST.cc
+++ b/paludis/merger/merger_TEST.cc
@@ -97,7 +97,8 @@ namespace
merger(MergerOptions::create()
.image(image_dir)
.root(root_dir)
- .environment(&env))
+ .environment(&env)
+ .no_chown(true))
{
}
};
diff --git a/paludis/repositories/gentoo/ebuild.cc b/paludis/repositories/gentoo/ebuild.cc
index ae184b3..72aff19 100644
--- a/paludis/repositories/gentoo/ebuild.cc
+++ b/paludis/repositories/gentoo/ebuild.cc
@@ -310,7 +310,10 @@ EbuildInstallCommand::commands() const
switch (install_params.phase)
{
case ebuild_ip_build:
- return "init setup unpack compile test install saveenv";
+ return "init setup unpack compile test saveenv";
+
+ case ebuild_ip_install:
+ return "loadenv install saveenv";
case ebuild_ip_preinstall:
return "loadenv strip preinst saveenv";
diff --git a/paludis/repositories/gentoo/ebuild.se b/paludis/repositories/gentoo/ebuild.se
index 05e9464..5aa0536 100644
--- a/paludis/repositories/gentoo/ebuild.se
+++ b/paludis/repositories/gentoo/ebuild.se
@@ -6,6 +6,7 @@ make_enum_EbuildInstallCommandPhase()
prefix ebuild_ip
key ebuild_ip_build "Build the package."
+ key ebuild_ip_install "Install the package to D."
key ebuild_ip_preinstall "Preinstall to a live system."
key ebuild_ip_postinstall "Postinstall to a live system."
key ebuild_ip_tidyup "Tidy up work."
diff --git a/paludis/repositories/gentoo/ebuild_entries.cc b/paludis/repositories/gentoo/ebuild_entries.cc
index c9b0955..914b8de 100644
--- a/paludis/repositories/gentoo/ebuild_entries.cc
+++ b/paludis/repositories/gentoo/ebuild_entries.cc
@@ -506,6 +506,10 @@ EbuildEntries::install(const QualifiedPackageName & q, const VersionSpec & v,
EbuildInstallCommand build_cmd(command_params, install_params);
build_cmd();
+ install_params.phase = ebuild_ip_install;
+ EbuildInstallCommand install_cmd(command_params, install_params);
+ install_cmd();
+
for (DestinationsCollection::Iterator d(o.destinations->begin()),
d_end(o.destinations->end()) ; d != d_end ; ++d)
{
diff --git a/paludis/repositories/gentoo/vdb_merger.cc b/paludis/repositories/gentoo/vdb_merger.cc
index 3f23a7a..aef3ac0 100644
--- a/paludis/repositories/gentoo/vdb_merger.cc
+++ b/paludis/repositories/gentoo/vdb_merger.cc
@@ -20,6 +20,7 @@
#include "vdb_merger.hh"
#include <paludis/util/log.hh>
#include <paludis/util/tokeniser.hh>
+#include <paludis/util/system.hh>
#include <paludis/digests/md5.hh>
#include <paludis/environment.hh>
#include <fstream>
@@ -57,7 +58,8 @@ VDBMerger::VDBMerger(const VDBMergerOptions & o) :
Merger(MergerOptions::create()
.environment(o.environment)
.image(o.image)
- .root(o.root)),
+ .root(o.root)
+ .no_chown(! getenv_with_default("PALUDIS_NO_CHOWN", "").empty())),
PrivateImplementationPattern<VDBMerger>(new Implementation<VDBMerger>(o))
{
}
diff --git a/paludis/util/fs_entry.cc b/paludis/util/fs_entry.cc
index 0782d02..f71ed2f 100644
--- a/paludis/util/fs_entry.cc
+++ b/paludis/util/fs_entry.cc
@@ -458,7 +458,8 @@ void
FSEntry::chown(const uid_t new_owner, const gid_t new_group)
{
if (0 != ::chown(_path.c_str(), new_owner, new_group))
- throw FSError("chown '" + _path + "' failed: " + ::strerror(errno));
+ throw FSError("chown '" + _path + "' to '" + stringify(new_owner) + "', '"
+ + stringify(new_group) + "' failed: " + ::strerror(errno));
}
void
diff --git a/src/clients/paludis/Makefile.am b/src/clients/paludis/Makefile.am
index 57c2c98..f2bf184 100644
--- a/src/clients/paludis/Makefile.am
+++ b/src/clients/paludis/Makefile.am
@@ -84,6 +84,7 @@ TESTS_ENVIRONMENT = env \
PALUDIS_EBUILD_DIR_FALLBACK="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories/gentoo/ebuild/`" \
PALUDIS_REPOSITORY_SO_DIR="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/repositories`" \
PALUDIS_ENVIRONMENT_SO_DIR="`$(top_srcdir)/paludis/repositories/gentoo/ebuild/utils/canonicalise $(top_builddir)/paludis/environments`" \
+ PALUDIS_NO_CHOWN="yupyup" \
SYSCONFDIR="$(sysconfdir)" \
bash $(top_srcdir)/test/run_test.sh bash