summaryrefslogtreecommitdiff
path: root/ftparchive/writer.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-06-09 10:52:45 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-06-09 10:52:45 +0200
commit308b793694774eece8765d172b8e989d8ed29925 (patch)
treebad798009c7f2b857c060e299294f63eabc3b20f /ftparchive/writer.cc
parent1aa9b2974d33015102224ffb738b2e8e0a4bcb42 (diff)
parentb02fffa64833e1f8e2617669d89de0a6d0882747 (diff)
- backport forgotten Valid-Until patch from the obsolete experimental
branch to prevent replay attacks better, thanks to Thomas Viehmann for the initial patch! (Closes: #499897) * doc/apt.conf.5.xml: - document the new Valid-Until related options * apt-pkg/contrib/strutl.cc: - split StrToTime() into HTTP1.1 and FTP date parser methods and use strptime() instead of some self-made scanf mangling - use the portable timegm shown in his manpage instead of a strange looking code copycat from wget * ftparchive/writer.cc: - add ValidTime option to generate a Valid-Until header in Release file
Diffstat (limited to 'ftparchive/writer.cc')
-rw-r--r--ftparchive/writer.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index 6cda29b21..650eec57c 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -924,6 +924,15 @@ ReleaseWriter::ReleaseWriter(string const &DB)
datestr[0] = '\0';
}
+ time_t const validuntil = now + _config->FindI("APT::FTPArchive::Release::ValidTime", 0);
+ char validstr[128];
+ if (now == validuntil ||
+ strftime(validstr, sizeof(validstr), "%a, %d %b %Y %H:%M:%S UTC",
+ gmtime(&validuntil)) == 0)
+ {
+ datestr[0] = '\0';
+ }
+
map<string,string> Fields;
Fields["Origin"] = "";
Fields["Label"] = "";
@@ -931,6 +940,7 @@ ReleaseWriter::ReleaseWriter(string const &DB)
Fields["Version"] = "";
Fields["Codename"] = "";
Fields["Date"] = datestr;
+ Fields["Valid-Until"] = validstr;
Fields["Architectures"] = "";
Fields["Components"] = "";
Fields["Description"] = "";