summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cacheiterators.h10
-rw-r--r--apt-pkg/cdrom.cc2
-rw-r--r--apt-pkg/contrib/strutl.cc17
-rw-r--r--apt-pkg/contrib/strutl.h1
-rw-r--r--apt-pkg/deb/debsystem.cc15
-rw-r--r--apt-pkg/deb/dpkgpm.cc16
-rw-r--r--apt-pkg/indexcopy.cc10
-rw-r--r--apt-pkg/indexrecords.cc6
8 files changed, 56 insertions, 21 deletions
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index 08eafca0f..bbbcb7753 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -104,7 +104,7 @@ class pkgCache::VerIterator
// Iteration
void operator ++(int) {if (Ver != Owner->VerP) Ver = Owner->VerP + Ver->NextVer;};
inline void operator ++() {operator ++(0);};
- inline bool end() const {return Owner == NULL || (Ver == Owner->VerP?true:false);};
+ inline bool end() const {return Owner == 0 || (Ver == Owner->VerP?true:false);};
inline void operator =(const VerIterator &B) {Ver = B.Ver; Owner = B.Owner;};
// Comparison
@@ -160,7 +160,7 @@ class pkgCache::DescIterator
// Iteration
void operator ++(int) {if (Desc != Owner->DescP) Desc = Owner->DescP + Desc->NextDesc;};
inline void operator ++() {operator ++(0);};
- inline bool end() const {return Desc == Owner->DescP?true:false;};
+ inline bool end() const {return Owner == 0 || Desc == Owner->DescP?true:false;};
inline void operator =(const DescIterator &B) {Desc = B.Desc; Owner = B.Owner;};
// Comparison
@@ -314,7 +314,7 @@ class pkgCache::PkgFileIterator
// Iteration
void operator ++(int) {if (File!= Owner->PkgFileP) File = Owner->PkgFileP + File->NextFile;};
inline void operator ++() {operator ++(0);};
- inline bool end() const {return File == Owner->PkgFileP?true:false;};
+ inline bool end() const {return Owner == 0 || File == Owner->PkgFileP?true:false;};
// Comparison
inline bool operator ==(const PkgFileIterator &B) const {return File == B.File;};
@@ -360,7 +360,7 @@ class pkgCache::VerFileIterator
// Iteration
void operator ++(int) {if (FileP != Owner->VerFileP) FileP = Owner->VerFileP + FileP->NextFile;};
inline void operator ++() {operator ++(0);};
- inline bool end() const {return FileP == Owner->VerFileP?true:false;};
+ inline bool end() const {return Owner == 0 || FileP == Owner->VerFileP?true:false;};
// Comparison
inline bool operator ==(const VerFileIterator &B) const {return FileP == B.FileP;};
@@ -392,7 +392,7 @@ class pkgCache::DescFileIterator
// Iteration
void operator ++(int) {if (FileP != Owner->DescFileP) FileP = Owner->DescFileP + FileP->NextFile;};
inline void operator ++() {operator ++(0);};
- inline bool end() const {return FileP == Owner->DescFileP?true:false;};
+ inline bool end() const {return Owner == 0 || FileP == Owner->DescFileP?true:false;};
// Comparison
inline bool operator ==(const DescFileIterator &B) const {return FileP == B.FileP;};
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index 370687f24..a31602dfa 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -686,7 +686,7 @@ bool pkgCdrom::Add(pkgCdromStatus *log)
{
if (_config->FindB("APT::CDROM::NoMount",false) == false)
UnmountCdrom(CDROM);
- return _error->Error("Unable to locate any package files, perhaps this is not a Debian Disc");
+ return _error->Error(_("Unable to locate any package files, perhaps this is not a Debian Disc or the wrong architecture?"));
}
// Check if the CD is in the database
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index bd374fd1e..98d9c41e4 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1027,11 +1027,26 @@ void ioprintf(ostream &out,const char *format,...)
va_start(args,format);
// sprintf the description
- char S[400];
+ char S[4096];
vsnprintf(S,sizeof(S),format,args);
out << S;
}
/*}}}*/
+// strprintf - C format string outputter to C++ strings /*{{{*/
+// ---------------------------------------------------------------------
+/* This is used to make the internationalization strings easier to translate
+ and to allow reordering of parameters */
+void strprintf(string &out,const char *format,...)
+{
+ va_list args;
+ va_start(args,format);
+
+ // sprintf the description
+ char S[4096];
+ vsnprintf(S,sizeof(S),format,args);
+ out = string(S);
+}
+ /*}}}*/
// safe_snprintf - Safer snprintf /*{{{*/
// ---------------------------------------------------------------------
/* This is a snprintf that will never (ever) go past 'End' and returns a
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 53146ced7..d9972abf4 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -59,6 +59,7 @@ bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length);
bool TokSplitString(char Tok,char *Input,char **List,
unsigned long ListMax);
void ioprintf(ostream &out,const char *format,...) APT_FORMAT2;
+void strprintf(string &out,const char *format,...) APT_FORMAT2;
char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_FORMAT3;
bool CheckDomainList(const string &Host, const string &List);
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index 11a84f1c6..b882367b8 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -17,7 +17,8 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
-
+#include <apti18n.h>
+
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
@@ -66,11 +67,11 @@ bool debSystem::Lock()
if (LockFD == -1)
{
if (errno == EACCES || errno == EAGAIN)
- return _error->Error("Unable to lock the administration directory (%s), "
- "is another process using it?",AdminDir.c_str());
+ return _error->Error(_("Unable to lock the administration directory (%s), "
+ "is another process using it?"),AdminDir.c_str());
else
- return _error->Error("Unable to lock the administration directory (%s), "
- "are you root?",AdminDir.c_str());
+ return _error->Error(_("Unable to lock the administration directory (%s), "
+ "are you root?"),AdminDir.c_str());
}
// See if we need to abort with a dirty journal
@@ -78,8 +79,8 @@ bool debSystem::Lock()
{
close(LockFD);
LockFD = -1;
- return _error->Error("dpkg was interrupted, you must manually "
- "run 'dpkg --configure -a' to correct the problem. ");
+ return _error->Error(_("dpkg was interrupted, you must manually "
+ "run 'dpkg --configure -a' to correct the problem. "));
}
LockCount++;
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 40aafafa4..686cbc6ee 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -587,6 +587,11 @@ static int racy_pselect(int nfds, fd_set *readfds, fd_set *writefds,
*/
bool pkgDPkgPM::Go(int OutStatusFd)
{
+ fd_set rfds;
+ struct timespec tv;
+ sigset_t sigmask;
+ sigset_t original_sigmask;
+
unsigned int MaxArgs = _config->FindI("Dpkg::MaxArgs",8*1024);
unsigned int MaxArgBytes = _config->FindI("Dpkg::MaxArgBytes",32*1024);
bool NoTriggers = _config->FindB("DPkg::NoTriggers",false);
@@ -798,7 +803,14 @@ bool pkgDPkgPM::Go(int OutStatusFd)
rtt = tt;
cfmakeraw(&rtt);
rtt.c_lflag &= ~ECHO;
+ // block SIGTTOU during tcsetattr to prevent a hang if
+ // the process is a member of the background process group
+ // http://www.opengroup.org/onlinepubs/000095399/functions/tcsetattr.html
+ sigemptyset(&sigmask);
+ sigaddset(&sigmask, SIGTTOU);
+ sigprocmask(SIG_BLOCK,&sigmask, &original_sigmask);
tcsetattr(0, TCSAFLUSH, &rtt);
+ sigprocmask(SIG_SETMASK, &original_sigmask, 0);
}
// Fork dpkg
@@ -865,10 +877,6 @@ bool pkgDPkgPM::Go(int OutStatusFd)
close(slave);
// setups fds
- fd_set rfds;
- struct timespec tv;
- sigset_t sigmask;
- sigset_t original_sigmask;
sigemptyset(&sigmask);
sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask);
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index 9e5c03e0b..5a92c79b7 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -522,6 +522,15 @@ bool SigVerify::Verify(string prefix, string file, indexRecords *MetaIndex)
{
const indexRecords::checkSum *Record = MetaIndex->Lookup(file);
+ // we skip non-existing files in the verifcation to support a cdrom
+ // with no Packages file (just a Package.gz), see LP: #255545
+ // (non-existing files are not considered a error)
+ if(!FileExists(prefix+file))
+ {
+ _error->Warning("Skipping non-exisiting file %s", string(prefix+file).c_str());
+ return true;
+ }
+
if (!Record)
{
_error->Warning("Can't find authentication record for: %s",file.c_str());
@@ -651,6 +660,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
if(!Verify(prefix,*I, MetaIndex)) {
// something went wrong, don't copy the Release.gpg
// FIXME: delete any existing gpg file?
+ _error->Discard();
continue;
}
}
diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc
index 502f454a8..ab208e246 100644
--- a/apt-pkg/indexrecords.cc
+++ b/apt-pkg/indexrecords.cc
@@ -37,14 +37,14 @@ bool indexRecords::Load(const string Filename)
pkgTagFile TagFile(&Fd, Fd.Size() + 256); // XXX
if (_error->PendingError() == true)
{
- ErrorText = _(("Unable to parse Release file " + Filename).c_str());
+ strprintf(ErrorText, _("Unable to parse Release file %s"),Filename.c_str());
return false;
}
pkgTagSection Section;
if (TagFile.Step(Section) == false)
{
- ErrorText = _(("No sections in Release file " + Filename).c_str());
+ strprintf(ErrorText, _("No sections in Release file %s"), Filename.c_str());
return false;
}
@@ -78,7 +78,7 @@ bool indexRecords::Load(const string Filename)
if(HashString::SupportedHashes()[i] == NULL)
{
- ErrorText = _(("No Hash entry in Release file " + Filename).c_str());
+ strprintf(ErrorText, _("No Hash entry in Release file %s"), Filename.c_str());
return false;
}