X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b3d44315ee812ba2d0a99751695b5a4314407ec2..f77bf408f3f7ae650bac2a967f28610737acf1ab:/methods/gpgv.cc diff --git a/methods/gpgv.cc b/methods/gpgv.cc index b34ea8d85..5cb154f66 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -46,7 +47,7 @@ const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, int status; struct stat buff; string gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv"); - string pubringpath = _config->Find("Apt::GPGV::TrustedKeyring", "/etc/apt/trusted.gpg"); + string pubringpath = _config->Find("APT::GPGV::TrustedKeyring", "/etc/apt/trusted.gpg"); if (_config->FindB("Debug::Acquire::gpgv", false)) { std::cerr << "gpgv path: " << gpgvpath << std::endl; @@ -68,11 +69,41 @@ const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, } else if (pid == 0) { + const char *Args[400]; + unsigned int i = 0; + + Args[i++] = gpgvpath.c_str(); + Args[i++] = "--status-fd"; + Args[i++] = "3"; + Args[i++] = "--keyring"; + Args[i++] = pubringpath.c_str(); + + Configuration::Item const *Opts; + Opts = _config->Tree("Acquire::gpgv::Options"); + if (Opts != 0) + { + Opts = Opts->Child; + for (; Opts != 0; Opts = Opts->Next) + { + if (Opts->Value.empty() == true) + continue; + Args[i++] = Opts->Value.c_str(); + if(i >= 395) { + std::cerr << _("E: Argument list from Acquire::gpgv::Options too long. Exiting.") << std::endl; + exit(111); + } + } + } + Args[i++] = file; + Args[i++] = outfile; + Args[i++] = NULL; + if (_config->FindB("Debug::Acquire::gpgv", false)) { - std::cerr << "Preparing to exec: " << gpgvpath - << " --status-fd 3 --keyring " << pubringpath - << " " << file << " " << outfile << std::endl; + std::cerr << "Preparing to exec: " << gpgvpath; + for(unsigned int j=0;Args[j] != NULL; j++) + std::cerr << " " << Args[j]; + std::cerr << std::endl; } int nullfd = open("/dev/null", O_RDONLY); close(fd[0]); @@ -85,8 +116,7 @@ const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, putenv("LANG="); putenv("LC_ALL="); putenv("LC_MESSAGES="); - execlp(gpgvpath.c_str(), gpgvpath.c_str(), "--status-fd", "3", "--keyring", - pubringpath.c_str(), file, outfile, NULL); + execvp(gpgvpath.c_str(), (char **)Args); exit(111); } @@ -152,27 +182,28 @@ const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, 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()) - return "Internal error: Good signature, but could not determine key fingerprint?!"; + return _("Internal error: Good signature, but could not determine key fingerprint?!"); return NULL; } 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) { - return (string("Could not execute ") + gpgvpath + - string(" to verify signature (is gnupg installed?)")).c_str(); + // FIXME String concatenation considered harmful. + return (string(_("Could not execute ")) + gpgvpath + + string(_(" to verify signature (is gnupg installed?)"))).c_str(); } else { - return "Unknown error executing gpgv"; + return _("Unknown error executing gpgv"); } } @@ -203,14 +234,14 @@ bool GPGVMethod::Fetch(FetchItem *Itm) { if (!BadSigners.empty()) { - errmsg += "The following signatures were invalid:\n"; + errmsg += _("The following signatures were invalid:\n"); for (vector::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::iterator I = NoPubKeySigners.begin(); I != NoPubKeySigners.end(); I++) errmsg += (*I + "\n"); @@ -222,16 +253,16 @@ bool GPGVMethod::Fetch(FetchItem *Itm) // 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) - 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) - return _error->Errno("stat","Failed to stat"); + return _error->Errno("stat",_("Failed to stat")); // Return a Done response Res.LastModified = Buf.st_mtime; @@ -246,7 +277,7 @@ bool GPGVMethod::Fetch(FetchItem *Itm) if (_config->FindB("Debug::Acquire::gpgv", false)) { - std::cerr <<"gpgv suceeded\n"; + std::cerr << "gpgv succeeded\n"; } return true; @@ -255,6 +286,8 @@ bool GPGVMethod::Fetch(FetchItem *Itm) int main() { + setlocale(LC_ALL, ""); + GPGVMethod Mth; return Mth.Run();