summaryrefslogtreecommitdiff
path: root/methods/copy.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-11-04 13:19:14 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2015-11-05 12:21:33 +0100
commit30c8107e9c56d7d78dcf9136f94aeed9d631dfb3 (patch)
treec8d9a601ab50de8d8cd059c2f84e94fedf4f8213 /methods/copy.cc
parent23d35ec15a849ee755f51a99939b0131e8faefa5 (diff)
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
Diffstat (limited to 'methods/copy.cc')
-rw-r--r--methods/copy.cc26
1 files changed, 6 insertions, 20 deletions
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 <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/configuration.h>
+#include "aptmethod.h"
#include <string>
#include <sys/stat.h>
@@ -25,23 +26,14 @@
#include <apti18n.h>
/*}}}*/
-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;
}