From ef9425971e042680337120e5efaa628470ad68c4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 7 Dec 2007 15:55:22 +0100 Subject: * apt-pkg/acquire-item.{cc,h}: - make the authentication download code more robust against servers/proxies with broken If-Range implementations --- apt-pkg/acquire-item.cc | 21 +++++++++++++++------ apt-pkg/acquire-item.h | 4 ++++ 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index c8ac84f56..7cae6c8b7 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -770,16 +770,19 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner, Desc.Owner = this; Desc.ShortDesc = ShortDesc; Desc.URI = URI; - string Final = _config->FindDir("Dir::State::lists"); Final += URItoFileName(RealURI); struct stat Buf; if (stat(Final.c_str(),&Buf) == 0) { - // File was already in place. It needs to be re-verified - // because Release might have changed, so Move it into partial - Rename(Final,DestFile); + // File was already in place. It needs to be re-downloaded/verified + // because Release might have changed, we do give it a differnt + // name than DestFile because otherwise the http method will + // send If-Range requests and there are too many broken servers + // out there that do not understand them + LastGoodSig = DestFile+".reverify"; + Rename(Final,LastGoodSig); } QueueURI(Desc); @@ -791,7 +794,7 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner, string pkgAcqMetaSig::Custom600Headers() { struct stat Buf; - if (stat(DestFile.c_str(),&Buf) != 0) + if (stat(LastGoodSig.c_str(),&Buf) != 0) return "\nIndex-File: true"; return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime); @@ -821,6 +824,12 @@ void pkgAcqMetaSig::Done(string Message,unsigned long Size,string MD5, Complete = true; + // put the last known good file back on i-m-s hit (it will + // be re-verified again) + // Else do nothing, we have the new file in DestFile then + if(StringToBool(LookupTag(Message,"IMS-Hit"),false) == true) + Rename(LastGoodSig, DestFile); + // queue a pkgAcqMetaIndex to be verified against the sig we just retrieved new pkgAcqMetaIndex(Owner, MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc, DestFile, IndexTargets, MetaIndexParser); @@ -837,7 +846,7 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) Item::Failed(Message,Cnf); // move the sigfile back on transient network failures if(FileExists(DestFile)) - Rename(DestFile,Final); + Rename(LastGoodSig,Final); // set the status back to , Item::Failed likes to reset it Status = pkgAcquire::Item::StatTransientNetworkError; diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h index edd910230..a48f7f7e5 100644 --- a/apt-pkg/acquire-item.h +++ b/apt-pkg/acquire-item.h @@ -609,6 +609,10 @@ struct IndexTarget class pkgAcqMetaSig : public pkgAcquire::Item { protected: + /** \brief The last good signature file */ + string LastGoodSig; + + /** \brief The fetch request that is currently being processed. */ pkgAcquire::ItemDesc Desc; -- cgit v1.2.3 From f6c702eba601aa3ecf253d1a4d9119949a0a2cf9 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Sat, 8 Dec 2007 12:15:21 -0200 Subject: * Applied patch from Alexander Winston to use 'min' as symbol for minute, closes: #219034. --- apt-pkg/contrib/strutl.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 006452af4..a04c266ba 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -331,19 +331,19 @@ string TimeToStr(unsigned long Sec) { if (Sec > 60*60*24) { - sprintf(S,"%lid %lih%lim%lis",Sec/60/60/24,(Sec/60/60) % 24,(Sec/60) % 60,Sec % 60); + sprintf(S,"%lid %lih%limin%lis",Sec/60/60/24,(Sec/60/60) % 24,(Sec/60) % 60,Sec % 60); break; } if (Sec > 60*60) { - sprintf(S,"%lih%lim%lis",Sec/60/60,(Sec/60) % 60,Sec % 60); + sprintf(S,"%lih%limin%lis",Sec/60/60,(Sec/60) % 60,Sec % 60); break; } if (Sec > 60) { - sprintf(S,"%lim%lis",Sec/60,Sec % 60); + sprintf(S,"%limin%lis",Sec/60,Sec % 60); break; } -- cgit v1.2.3 From da543ed87d3f8b8a0030a211452c9bddfc066f0b Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Sun, 16 Dec 2007 18:35:58 -0200 Subject: * Applied patch from Peter Eisentraut to fix a grammatical error ("manual installed" -> "manually installed"), closes: #438136. * --- apt-pkg/algorithms.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 62727a852..158f9c258 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1261,8 +1261,8 @@ void pkgProblemResolver::InstallProtect() Cache.MarkDelete(I); else { - // preserver the information if the package was auto - // or manual installed + // preserve the information whether the package was auto + // or manually installed bool autoInst = (Cache[I].Flags & pkgCache::Flag::Auto); Cache.MarkInstall(I, false, 0, !autoInst); } -- cgit v1.2.3 From db2cca1129fa2d88eae80e1c4a17e263236a95a3 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Sun, 16 Dec 2007 18:53:32 -0200 Subject: * apt-pkg/contrib/configuration.cc: - if RootDir is set, then FindFile and FindDir will return paths relative to the directory stored in RootDir, closes: #456457. --- apt-pkg/contrib/configuration.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 3109fd7a5..e8301d918 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -173,6 +173,11 @@ string Configuration::Find(const char *Name,const char *Default) const */ string Configuration::FindFile(const char *Name,const char *Default) const { + const Item *RootItem = Lookup("RootDir"); + std::string rootDir = (RootItem == 0) ? "" : RootItem->Value; + if(rootDir.size() > 0 && rootDir[rootDir.size() - 1] != '/') + rootDir.push_back('/'); + const Item *Itm = Lookup(Name); if (Itm == 0 || Itm->Value.empty() == true) { @@ -204,7 +209,7 @@ string Configuration::FindFile(const char *Name,const char *Default) const Itm = Itm->Parent; } - return val; + return rootDir + val; } /*}}}*/ // Configuration::FindDir - Find a directory name /*{{{*/ -- cgit v1.2.3 From aff87a762f86ed47f2b81ccbac23faa5d9fddcdb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 17 Dec 2007 20:49:50 +0100 Subject: apt-pkg/deb/dpkgpm.cc: fix types --- apt-pkg/deb/dpkgpm.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index d796146fa..11bf827d7 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -342,8 +342,8 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) */ void pkgDPkgPM::DoStdin(int master) { - char input_buf[256] = {0,}; - int len = read(0, input_buf, sizeof(input_buf)); + unsigned char input_buf[256] = {0,}; + ssize_t len = read(0, input_buf, sizeof(input_buf)); if (len) write(master, input_buf, len); else @@ -357,9 +357,9 @@ void pkgDPkgPM::DoStdin(int master) */ void pkgDPkgPM::DoTerminalPty(int master) { - char term_buf[1024] = {0,}; + unsigned char term_buf[1024] = {0,0, }; - int len=read(master, term_buf, sizeof(term_buf)); + ssize_t len=read(master, term_buf, sizeof(term_buf)); if(len == -1 && errno == EIO) { // this happens when the child is about to exit, we -- cgit v1.2.3