From 30c8107e9c56d7d78dcf9136f94aeed9d631dfb3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 4 Nov 2015 13:19:14 +0100 Subject: drop privileges in copy:// method as we do for file:// Continueing on the track of dropping privileges in all methods, lets drop it in copy, too, as the reasoning for it is very similar to file and the interaction between the too quiet interesting as copy kinda surfed as a fallback for file not being able to read the file. Both now show a better error message as well as it was previously claiming to have a hashsum mismatch, given that it couldn't read the file. Git-Dch: Ignore --- methods/copy.cc | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'methods/copy.cc') diff --git a/methods/copy.cc b/methods/copy.cc index 373ad3604..e515b2def 100644 --- a/methods/copy.cc +++ b/methods/copy.cc @@ -17,6 +17,7 @@ #include #include #include +#include "aptmethod.h" #include #include @@ -25,23 +26,14 @@ #include /*}}}*/ -class CopyMethod : public pkgAcqMethod +class CopyMethod : public aptMethod { virtual bool Fetch(FetchItem *Itm) APT_OVERRIDE; - void CalculateHashes(FetchItem const * const Itm, FetchResult &Res); - + public: - - CopyMethod() : pkgAcqMethod("1.0",SingleInstance | SendConfig) {}; -}; -void CopyMethod::CalculateHashes(FetchItem const * const Itm, FetchResult &Res) -{ - Hashes Hash(Itm->ExpectedHashes); - FileFd Fd(Res.Filename, FileFd::ReadOnly); - Hash.AddFD(Fd); - Res.TakeHashes(Hash); -} + CopyMethod() : aptMethod("copy", "1.0",SingleInstance | SendConfig) {}; +}; // CopyMethod::Fetch - Fetch a file /*{{{*/ // --------------------------------------------------------------------- @@ -76,12 +68,7 @@ bool CopyMethod::Fetch(FetchItem *Itm) FileFd From(File,FileFd::ReadOnly); FileFd To(Itm->DestFile,FileFd::WriteAtomic); To.EraseOnFailure(); - if (_error->PendingError() == true) - { - To.OpFail(); - return false; - } - + // Copy the file if (CopyFile(From,To) == false) { @@ -101,7 +88,6 @@ bool CopyMethod::Fetch(FetchItem *Itm) return _error->Errno("utimes",_("Failed to set modification time")); CalculateHashes(Itm, Res); - URIDone(Res); return true; } -- cgit v1.2.3