|
|
@@ -18,6 +18,7 @@ |
|
|
#include <stddef.h>
|
|
|
|
|
|
#include <algorithm>
|
|
|
+#include <fstream>
|
|
|
#include <iostream>
|
|
|
#include <string>
|
|
|
#include <vector>
|
|
|
@@ -97,6 +98,7 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, |
|
|
std::vector<std::string> dataHeader;
|
|
|
char * sig = NULL;
|
|
|
char * data = NULL;
|
|
|
+ char * conf = nullptr;
|
|
|
|
|
|
if (releaseSignature == DETACHED)
|
|
|
{
|
|
|
@@ -107,6 +109,7 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, |
|
|
{
|
|
|
sig = GenerateTemporaryFileTemplate("apt.sig");
|
|
|
data = GenerateTemporaryFileTemplate("apt.data");
|
|
|
+ conf = GenerateTemporaryFileTemplate("apt.conf");
|
|
|
if (sig == NULL || data == NULL)
|
|
|
{
|
|
|
ioprintf(std::cerr, "Couldn't create tempfile names for splitting up %s", File.c_str());
|
|
|
@@ -115,8 +118,11 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, |
|
|
|
|
|
int const sigFd = mkstemp(sig);
|
|
|
int const dataFd = mkstemp(data);
|
|
|
- if (sigFd == -1 || dataFd == -1)
|
|
|
+ int const confFd = mkstemp(conf);
|
|
|
+ if (sigFd == -1 || dataFd == -1 || confFd == -1 )
|
|
|
{
|
|
|
+ if (confFd != -1)
|
|
|
+ unlink(conf);
|
|
|
if (dataFd != -1)
|
|
|
unlink(data);
|
|
|
if (sigFd != -1)
|
|
|
@@ -129,14 +135,20 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, |
|
|
signature.OpenDescriptor(sigFd, FileFd::WriteOnly, true);
|
|
|
FileFd message;
|
|
|
message.OpenDescriptor(dataFd, FileFd::WriteOnly, true);
|
|
|
+ std::ofstream configStream(conf);
|
|
|
|
|
|
- if (signature.Failed() == true || message.Failed() == true ||
|
|
|
+ _config->Dump(configStream);
|
|
|
+ close(confFd);
|
|
|
+
|
|
|
+ if (signature.Failed() == true || message.Failed() == true || configStream.fail() == true ||
|
|
|
SplitClearSignedFile(File, &message, &dataHeader, &signature) == false)
|
|
|
{
|
|
|
if (dataFd != -1)
|
|
|
unlink(data);
|
|
|
if (sigFd != -1)
|
|
|
unlink(sig);
|
|
|
+ if (confFd != -1)
|
|
|
+ unlink(conf);
|
|
|
ioprintf(std::cerr, "Splitting up %s into data and signature failed", File.c_str());
|
|
|
exit(112);
|
|
|
}
|
|
|
@@ -180,7 +192,7 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, |
|
|
else
|
|
|
{
|
|
|
//#define UNLINK_EXIT(X) exit(X)
|
|
|
-#define UNLINK_EXIT(X) unlink(sig);unlink(data);exit(X)
|
|
|
+#define UNLINK_EXIT(X) unlink(sig);unlink(data);unlink(conf);exit(X)
|
|
|
|
|
|
// for clear-signed files we have created tempfiles we have to clean up
|
|
|
// and we do an additional check, so fork yet another time …
|
|
|
@@ -191,6 +203,7 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, |
|
|
}
|
|
|
if(pid == 0)
|
|
|
{
|
|
|
+ setenv("APT_CONFIG", conf, 1);
|
|
|
if (statusfd != -1)
|
|
|
dup2(fd[1], statusfd);
|
|
|
execvp(Args[0], (char **) &Args[0]);
|
|
|
@@ -211,8 +224,10 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, |
|
|
// we don't need the files any longer
|
|
|
unlink(sig);
|
|
|
unlink(data);
|
|
|
+ unlink(conf);
|
|
|
free(sig);
|
|
|
free(data);
|
|
|
+ free(conf);
|
|
|
|
|
|
// check if it exit'ed normally …
|
|
|
if (WIFEXITED(Status) == false)
|
|
|
|
0 comments on commit
1bdb1e5