projects
/
apt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* merged NMU from aba
[apt.git]
/
methods
/
gpgv.cc
diff --git
a/methods/gpgv.cc
b/methods/gpgv.cc
index 24e945b2c3c772d4dfc62d7a024b930302de4a94..227e08d63123e2c51ba77966dc218e41f13f217c 100644
(file)
--- a/
methods/gpgv.cc
+++ b/
methods/gpgv.cc
@@
-1,6
+1,7
@@
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/strutl.h>
+#include <apti18n.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/stat.h>
#include <unistd.h>
@@
-10,16
+11,18
@@
#include <errno.h>
#include <sys/wait.h>
#include <iostream>
#include <errno.h>
#include <sys/wait.h>
#include <iostream>
+#include <sstream>
#define GNUPGPREFIX "[GNUPG:]"
#define GNUPGBADSIG "[GNUPG:] BADSIG"
#define GNUPGNOPUBKEY "[GNUPG:] NO_PUBKEY"
#define GNUPGVALIDSIG "[GNUPG:] VALIDSIG"
#define GNUPGPREFIX "[GNUPG:]"
#define GNUPGBADSIG "[GNUPG:] BADSIG"
#define GNUPGNOPUBKEY "[GNUPG:] NO_PUBKEY"
#define GNUPGVALIDSIG "[GNUPG:] VALIDSIG"
+#define GNUPGNODATA "[GNUPG:] NODATA"
class GPGVMethod : public pkgAcqMethod
{
private:
class GPGVMethod : public pkgAcqMethod
{
private:
-
const char *
VerifyGetSigners(const char *file, const char *outfile,
+
string
VerifyGetSigners(const char *file, const char *outfile,
vector<string> &GoodSigners, vector<string> &BadSigners,
vector<string> &NoPubKeySigners);
vector<string> &GoodSigners, vector<string> &BadSigners,
vector<string> &NoPubKeySigners);
@@
-31,11
+34,15
@@
class GPGVMethod : public pkgAcqMethod
GPGVMethod() : pkgAcqMethod("1.0",SingleInstance | SendConfig) {};
};
GPGVMethod() : pkgAcqMethod("1.0",SingleInstance | SendConfig) {};
};
-
const char *
GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
+
string
GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
vector<string> &GoodSigners,
vector<string> &BadSigners,
vector<string> &NoPubKeySigners)
{
vector<string> &GoodSigners,
vector<string> &BadSigners,
vector<string> &NoPubKeySigners)
{
+ // setup a (empty) stringstream for formating the return value
+ std::stringstream ret;
+ ret.str("");
+
if (_config->FindB("Debug::Acquire::gpgv", false))
{
std::cerr << "inside VerifyGetSigners" << std::endl;
if (_config->FindB("Debug::Acquire::gpgv", false))
{
std::cerr << "inside VerifyGetSigners" << std::endl;
@@
-53,9
+60,11
@@
const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
std::cerr << "Keyring path: " << pubringpath << std::endl;
}
std::cerr << "Keyring path: " << pubringpath << std::endl;
}
- if (stat(pubringpath.c_str(), &buff) != 0)
- return (string("Couldn't access keyring: ") + strerror(errno)).c_str();
-
+ if (stat(pubringpath.c_str(), &buff) != 0)
+ {
+ ioprintf(ret, _("Couldn't access keyring: '%s'"), strerror(errno));
+ return ret.str();
+ }
if (pipe(fd) < 0)
{
return "Couldn't create pipe";
if (pipe(fd) < 0)
{
return "Couldn't create pipe";
@@
-64,7
+73,7
@@
const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
pid = fork();
if (pid < 0)
{
pid = fork();
if (pid < 0)
{
- return
(string("Couldn't spawn new process") + strerror(errno)).c_str(
);
+ return
string("Couldn't spawn new process") + strerror(errno
);
}
else if (pid == 0)
{
}
else if (pid == 0)
{
@@
-88,7
+97,7
@@
const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
continue;
Args[i++] = Opts->Value.c_str();
if(i >= 395) {
continue;
Args[i++] = Opts->Value.c_str();
if(i >= 395) {
- std::cerr <<
"E: Argument list from Acquire::gpgv::Options too long. Exiting."
<< std::endl;
+ std::cerr <<
_("E: Argument list from Acquire::gpgv::Options too long. Exiting.")
<< std::endl;
exit(111);
}
}
exit(111);
}
}
@@
-163,7
+172,12
@@
const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
std::cerr << "Got NO_PUBKEY " << std::endl;
NoPubKeySigners.push_back(string(buffer+sizeof(GNUPGPREFIX)));
}
std::cerr << "Got NO_PUBKEY " << std::endl;
NoPubKeySigners.push_back(string(buffer+sizeof(GNUPGPREFIX)));
}
-
+ if (strncmp(buffer, GNUPGNODATA, sizeof(GNUPGBADSIG)-1) == 0)
+ {
+ if (_config->FindB("Debug::Acquire::gpgv", false))
+ std::cerr << "Got NODATA! " << std::endl;
+ BadSigners.push_back(string(buffer+sizeof(GNUPGPREFIX)));
+ }
if (strncmp(buffer, GNUPGVALIDSIG, sizeof(GNUPGVALIDSIG)-1) == 0)
{
char *sig = buffer + sizeof(GNUPGPREFIX);
if (strncmp(buffer, GNUPGVALIDSIG, sizeof(GNUPGVALIDSIG)-1) == 0)
{
char *sig = buffer + sizeof(GNUPGPREFIX);
@@
-181,27
+195,27
@@
const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
waitpid(pid, &status, 0);
if (_config->FindB("Debug::Acquire::gpgv", false))
{
waitpid(pid, &status, 0);
if (_config->FindB("Debug::Acquire::gpgv", false))
{
- std::cerr <<"gpgv exited\n";
+ std::cerr <<
"gpgv exited\n";
}
if (WEXITSTATUS(status) == 0)
{
if (GoodSigners.empty())
}
if (WEXITSTATUS(status) == 0)
{
if (GoodSigners.empty())
- return
"Internal error: Good signature, but could not determine key fingerprint?!"
;
- return
NULL
;
+ return
_("Internal error: Good signature, but could not determine key fingerprint?!")
;
+ return
""
;
}
else if (WEXITSTATUS(status) == 1)
{
}
else if (WEXITSTATUS(status) == 1)
{
- return
"At least one invalid signature was encountered."
;
+ return
_("At least one invalid signature was encountered.")
;
}
else if (WEXITSTATUS(status) == 111)
{
}
else if (WEXITSTATUS(status) == 111)
{
- return (string("Could not execute ") + gpgvpath +
-
string(" to verify signature (is gnupg installed?)")).c_
str();
+ ioprintf(ret, _("Could not execute '%s' to verify signature (is gnupg installed?)"), gpgvpath.c_str());
+
return ret.
str();
}
else
{
}
else
{
- return
"Unknown error executing gpgv"
;
+ return
_("Unknown error executing gpgv")
;
}
}
}
}
@@
-219,8
+233,8
@@
bool GPGVMethod::Fetch(FetchItem *Itm)
URIStart(Res);
// Run gpgv on file, extract contents and get the key ID of the signer
URIStart(Res);
// Run gpgv on file, extract contents and get the key ID of the signer
-
const char *
msg = VerifyGetSigners(Path.c_str(), Itm->DestFile.c_str(),
-
GoodSigners, BadSigners, NoPubKeySigners);
+
string
msg = VerifyGetSigners(Path.c_str(), Itm->DestFile.c_str(),
+ GoodSigners, BadSigners, NoPubKeySigners);
if (GoodSigners.empty() || !BadSigners.empty() || !NoPubKeySigners.empty())
{
string errmsg;
if (GoodSigners.empty() || !BadSigners.empty() || !NoPubKeySigners.empty())
{
string errmsg;
@@
-232,35
+246,39
@@
bool GPGVMethod::Fetch(FetchItem *Itm)
{
if (!BadSigners.empty())
{
{
if (!BadSigners.empty())
{
- errmsg +=
"The following signatures were invalid:\n"
;
+ errmsg +=
_("The following signatures were invalid:\n")
;
for (vector<string>::iterator I = BadSigners.begin();
I != BadSigners.end(); I++)
errmsg += (*I + "\n");
}
if (!NoPubKeySigners.empty())
{
for (vector<string>::iterator I = BadSigners.begin();
I != BadSigners.end(); I++)
errmsg += (*I + "\n");
}
if (!NoPubKeySigners.empty())
{
- errmsg +=
"The following signatures couldn't be verified because the public key is not available:\n"
;
+ errmsg +=
_("The following signatures couldn't be verified because the public key is not available:\n")
;
for (vector<string>::iterator I = NoPubKeySigners.begin();
I != NoPubKeySigners.end(); I++)
errmsg += (*I + "\n");
}
}
for (vector<string>::iterator I = NoPubKeySigners.begin();
I != NoPubKeySigners.end(); I++)
errmsg += (*I + "\n");
}
}
- return _error->Error(errmsg.c_str());
+ // this is only fatal if we have no good sigs or if we have at
+ // least one bad signature. good signatures and NoPubKey signatures
+ // happen easily when a file is signed with multiple signatures
+ if(GoodSigners.empty() or !BadSigners.empty())
+ return _error->Error(errmsg.c_str());
}
// Transfer the modification times
struct stat Buf;
if (stat(Path.c_str(),&Buf) != 0)
}
// Transfer the modification times
struct stat Buf;
if (stat(Path.c_str(),&Buf) != 0)
- return _error->Errno("stat",
"Failed to stat %s"
, Path.c_str());
+ return _error->Errno("stat",
_("Failed to stat %s")
, Path.c_str());
struct utimbuf TimeBuf;
TimeBuf.actime = Buf.st_atime;
TimeBuf.modtime = Buf.st_mtime;
if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0)
struct utimbuf TimeBuf;
TimeBuf.actime = Buf.st_atime;
TimeBuf.modtime = Buf.st_mtime;
if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0)
- return _error->Errno("utime",
"Failed to set modification time"
);
+ return _error->Errno("utime",
_("Failed to set modification time")
);
if (stat(Itm->DestFile.c_str(),&Buf) != 0)
if (stat(Itm->DestFile.c_str(),&Buf) != 0)
- return _error->Errno("stat",
"Failed to stat"
);
+ return _error->Errno("stat",
_("Failed to stat")
);
// Return a Done response
Res.LastModified = Buf.st_mtime;
// Return a Done response
Res.LastModified = Buf.st_mtime;
@@
-275,7
+293,7
@@
bool GPGVMethod::Fetch(FetchItem *Itm)
if (_config->FindB("Debug::Acquire::gpgv", false))
{
if (_config->FindB("Debug::Acquire::gpgv", false))
{
- std::cerr <<
"gpgv su
ceeded\n";
+ std::cerr <<
"gpgv suc
ceeded\n";
}
return true;
}
return true;
@@
-284,6
+302,8
@@
bool GPGVMethod::Fetch(FetchItem *Itm)
int main()
{
int main()
{
+ setlocale(LC_ALL, "");
+
GPGVMethod Mth;
return Mth.Run();
GPGVMethod Mth;
return Mth.Run();