summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-05-25 15:55:05 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-05-25 15:55:05 +0200
commitff371080d8672b94ef289f1162704e74959b4ddf (patch)
treeef1009f20f84b4d53a8f837f02411c7789b89fc4 /methods
parent921a3ce01c2595e9df9ff20bdd259e14733dcb16 (diff)
parent642ebc1a04c9c7915474c57f1143a9389ee6636a (diff)
merged lp:~donkult/apt/sid
Diffstat (limited to 'methods')
-rw-r--r--methods/gpgv.cc42
-rw-r--r--methods/rred.cc19
2 files changed, 28 insertions, 33 deletions
diff --git a/methods/gpgv.cc b/methods/gpgv.cc
index c58e6cc45..a149d67dd 100644
--- a/methods/gpgv.cc
+++ b/methods/gpgv.cc
@@ -12,6 +12,8 @@
#include <iostream>
#include <sstream>
+#include <vector>
+
#define GNUPGPREFIX "[GNUPG:]"
#define GNUPGBADSIG "[GNUPG:] BADSIG"
#define GNUPGNOPUBKEY "[GNUPG:] NO_PUBKEY"
@@ -87,23 +89,18 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
return string("Couldn't spawn new process") + strerror(errno);
else if (pid == 0)
{
- const char *Args[400];
- unsigned int i = 0;
+ std::vector<const char *> Args;
+ Args.reserve(30);
- Args[i++] = gpgvpath.c_str();
- Args[i++] = "--status-fd";
- Args[i++] = "3";
- Args[i++] = "--ignore-time-conflict";
+ Args.push_back(gpgvpath.c_str());
+ Args.push_back("--status-fd");
+ Args.push_back("3");
+ Args.push_back("--ignore-time-conflict");
for (vector<string>::const_iterator K = keyrings.begin();
K != keyrings.end(); ++K)
{
- Args[i++] = "--keyring";
- Args[i++] = K->c_str();
- // check overflow (minus a bit of extra space at the end)
- if(i >= sizeof(Args)/sizeof(char*)-5) {
- std::clog << _("E: Too many keyrings should be passed to gpgv. Exiting.") << std::endl;
- exit(111);
- }
+ Args.push_back("--keyring");
+ Args.push_back(K->c_str());
}
Configuration::Item const *Opts;
@@ -115,23 +112,18 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
{
if (Opts->Value.empty() == true)
continue;
- Args[i++] = Opts->Value.c_str();
- // check overflow (minus a bit of extra space at the end)
- if(i >= sizeof(Args)/sizeof(char*)-5) {
- std::clog << _("E: Argument list from Acquire::gpgv::Options too long. Exiting.") << std::endl;
- exit(111);
- }
+ Args.push_back(Opts->Value.c_str());
}
}
- Args[i++] = file;
- Args[i++] = outfile;
- Args[i++] = NULL;
+ Args.push_back(file);
+ Args.push_back(outfile);
+ Args.push_back(NULL);
if (Debug == true)
{
std::clog << "Preparing to exec: " << gpgvpath;
- for(unsigned int j=0;Args[j] != NULL; j++)
- std::clog << " " << Args[j];
+ for(std::vector<const char *>::const_iterator a = Args.begin();*a != NULL; ++a)
+ std::clog << " " << *a;
std::clog << std::endl;
}
int const nullfd = open("/dev/null", O_RDONLY);
@@ -145,7 +137,7 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
putenv((char *)"LANG=");
putenv((char *)"LC_ALL=");
putenv((char *)"LC_MESSAGES=");
- execvp(gpgvpath.c_str(), (char **)Args);
+ execvp(gpgvpath.c_str(), (char **) &Args[0]);
exit(111);
}
diff --git a/methods/rred.cc b/methods/rred.cc
index 262c78cab..f42c7a072 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -477,23 +477,26 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/
Patch.Close();
To.Close();
- // Transfer the modification times
- struct stat Buf;
- if (stat(Path.c_str(),&Buf) != 0)
+ /* Transfer the modification times from the patch file
+ to be able to see in which state the file should be
+ and use the access time from the "old" file */
+ struct stat BufBase, BufPatch;
+ if (stat(Path.c_str(),&BufBase) != 0 ||
+ stat(string(Path+".ed").c_str(),&BufPatch) != 0)
return _error->Errno("stat",_("Failed to stat"));
struct utimbuf TimeBuf;
- TimeBuf.actime = Buf.st_atime;
- TimeBuf.modtime = Buf.st_mtime;
+ TimeBuf.actime = BufBase.st_atime;
+ TimeBuf.modtime = BufPatch.st_mtime;
if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0)
return _error->Errno("utime",_("Failed to set modification time"));
- if (stat(Itm->DestFile.c_str(),&Buf) != 0)
+ if (stat(Itm->DestFile.c_str(),&BufBase) != 0)
return _error->Errno("stat",_("Failed to stat"));
// return done
- Res.LastModified = Buf.st_mtime;
- Res.Size = Buf.st_size;
+ Res.LastModified = BufBase.st_mtime;
+ Res.Size = BufBase.st_size;
Res.TakeHashes(Hash);
URIDone(Res);