1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
/* #####################################################################
dummy solver to get quickly a scenario file out of APT
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
#include <apt-pkg/edsp.h>
#include <string.h>
#include <unistd.h>
#include <cstdio>
#include <iostream>
#include <config.h>
/*}}}*/
// ShowHelp - Show a help screen /*{{{*/
// ---------------------------------------------------------------------
/* */
static bool ShowHelp() {
ioprintf(std::cout, "%s %s (%s)\n", PACKAGE, PACKAGE_VERSION, COMMON_ARCH);
std::cout <<
"Usage: apt-dump-resolver\n"
"\n"
"apt-dump-resolver is a dummy solver who just dumps its input to the\n"
"file /tmp/dump.edsp and exists with a proper EDSP error.\n"
"\n"
" This dump has lost Super Cow Powers.\n";
return true;
}
/*}}}*/
int main(int argc,const char *argv[]) /*{{{*/
{
if (argc > 1 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1],"-h") == 0 ||
strcmp(argv[1],"-v") == 0 || strcmp(argv[1],"--version") == 0)) {
ShowHelp();
return 0;
}
// we really don't need anything
DropPrivileges();
FILE* input = fdopen(STDIN_FILENO, "r");
FILE* output = fopen("/tmp/dump.edsp", "w");
char buffer[400];
while (fgets(buffer, sizeof(buffer), input) != NULL)
fputs(buffer, output);
fclose(output);
fclose(input);
EDSP::WriteError("ERR_JUST_DUMPING", "I am too dumb, i can just dump!\nPlease use one of my friends instead!", stdout);
}
|