osquery-1/osquery/main/shell.cpp

35 lines
994 B
C++
Raw Normal View History

/*
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
2015-04-27 23:40:05 +00:00
#include <stdio.h>
#include <osquery/core.h>
2015-03-18 19:01:58 +00:00
#include "osquery/devtools/devtools.h"
2014-07-31 00:35:19 +00:00
int main(int argc, char *argv[]) {
2015-02-03 05:21:36 +00:00
// Parse/apply flags, start registry, load logger/config plugins.
2015-03-03 23:03:14 +00:00
osquery::Initializer runner(argc, argv, osquery::OSQUERY_TOOL_SHELL);
2015-04-27 23:40:05 +00:00
if (argc > 1 || !isatty(fileno(stdin)) || osquery::FLAGS_A.size() > 0 ||
osquery::FLAGS_L) {
// A query was set as a positional argument for via stdin.
osquery::FLAGS_disable_events = true;
}
2015-03-03 23:03:14 +00:00
runner.start();
2015-02-03 05:21:36 +00:00
// Virtual tables will be attached to the shell's in-memory SQLite DB.
int retcode = osquery::launchIntoShell(argc, argv);
// Finally shutdown.
2015-03-03 23:03:14 +00:00
runner.shutdown();
return retcode;
2014-07-31 00:35:19 +00:00
}