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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
/*
stealth.cc
*/
#include "stealth.h"
static Arg::LongOption longOpt_begin[] =
{
Arg::LongOption("debug", 'd'),
Arg::LongOption("echo-commands", 'e'),
Arg::LongOption("max-size", Arg::Required), // 10m by default
Arg::LongOption("no-child-processes", 'n'),
Arg::LongOption("only-stdout", 'o'),
Arg::LongOption("parse-config-file", 'c'),
Arg::LongOption("quiet", 'q'),
Arg::LongOption("random-interval", 'i'),
Arg::LongOption("run-command", 'r'),
Arg::LongOption("version", 'v'),
Arg::LongOption("keep-alive", Arg::Required), // runfilename
Arg::LongOption("suppress", Arg::Required), // runfilename
Arg::LongOption("repeat", Arg::Required),
Arg::LongOption("rerun", Arg::Required),
Arg::LongOption("terminate", Arg::Required), // runfilename
Arg::LongOption("resume", Arg::Required), // runfilename
Arg::LongOption("usage"),
Arg::LongOption("help"),
};
static Arg::LongOption const * const longOpt_end =
longOpt_begin + sizeof(longOpt_begin) / sizeof(Arg::LongOption);
int main(int argc, char **argv)
try
{
try
{
// construct Arg object to process
Arg &arg = Arg::initialize("cdei:noqr:v",
longOpt_begin, longOpt_end,
argc, argv);
bool debug = arg.option('d');
Util::setDebug(debug);
// handle process control options
Util::processControlOptions();
Util::maybeBackground(); // maybe run Stealth in the background
ConfigFile configfile; // ConfigFile object reads
// configuration file
try
{
configfile.open(arg[0]);
}
catch (...) // No configfile, then show message
{
Util::exit("Can't read configuration file `%s'", arg[0]);
}
// ConfigSorter sorts the
// configuration file. Separates
// USEs, DEFINEs and commands.
ConfigSorter sorter(configfile);
Reporter reporter(sorter["REPORT"]);
Scanner scanner(sorter, reporter); // Construct the integrityscanner
// Contruct the process monitor
Monitor monitor(sorter, reporter, scanner);
monitor.control(); // control the scanning process,
// run all the Scanner's tests
}
catch (Errno const &err)
{
cerr << err.what() << ": " << err.which() << endl;
throw Util::ERROR; // return 1;
}
Util::unlinkRunfile();
return 0;
}
catch (Util::Terminate terminate) // may also be OK
{
Util::mainProcess();
return terminate;
}
|