- {
- 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;
- 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]);
- // Redirect output to /dev/null; we read from the status fd
- dup2(nullfd, STDOUT_FILENO);
- dup2(nullfd, STDERR_FILENO);
- // Redirect the pipe to the status fd (3)
- dup2(fd[1], 3);
-
- putenv((char *)"LANG=");
- putenv((char *)"LC_ALL=");
- putenv((char *)"LC_MESSAGES=");
- execvp(gpgvpath.c_str(), (char **)Args);
-
- exit(111);
- }