2014-12-18 18:50:47 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-07-31 00:35:19 +00:00
|
|
|
#include <boost/thread.hpp>
|
|
|
|
|
2014-08-21 21:35:51 +00:00
|
|
|
#include <glog/logging.h>
|
|
|
|
|
2014-12-03 23:14:02 +00:00
|
|
|
#include <osquery/config.h>
|
|
|
|
#include <osquery/config/plugin.h>
|
|
|
|
#include <osquery/core.h>
|
|
|
|
#include <osquery/database.h>
|
|
|
|
#include <osquery/events.h>
|
|
|
|
#include <osquery/logger/plugin.h>
|
|
|
|
#include <osquery/scheduler.h>
|
2014-07-31 00:35:19 +00:00
|
|
|
|
2014-08-30 11:06:21 +00:00
|
|
|
int main(int argc, char* argv[]) {
|
2014-11-09 04:27:28 +00:00
|
|
|
osquery::initOsquery(argc, argv, osquery::OSQUERY_TOOL_DAEMON);
|
2014-07-31 00:35:19 +00:00
|
|
|
|
2014-11-18 02:42:36 +00:00
|
|
|
auto pid_status = osquery::createPidFile();
|
|
|
|
if (!pid_status.ok()) {
|
|
|
|
LOG(ERROR) << "Could not create osquery pidfile: " << pid_status.toString();
|
2014-12-08 18:40:10 +00:00
|
|
|
::exit(EXIT_FAILURE);
|
2014-11-18 02:42:36 +00:00
|
|
|
}
|
|
|
|
|
2014-10-27 18:55:28 +00:00
|
|
|
try {
|
|
|
|
osquery::DBHandle::getInstance();
|
|
|
|
} catch (std::exception& e) {
|
|
|
|
LOG(ERROR) << "osqueryd failed to start: " << e.what();
|
|
|
|
::exit(1);
|
|
|
|
}
|
|
|
|
|
2014-08-21 21:35:51 +00:00
|
|
|
LOG(INFO) << "Listing all plugins";
|
|
|
|
|
|
|
|
LOG(INFO) << "Logger plugins:";
|
|
|
|
for (const auto& it : REGISTERED_LOGGER_PLUGINS) {
|
|
|
|
LOG(INFO) << " - " << it.first;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG(INFO) << "Config plugins:";
|
|
|
|
for (const auto& it : REGISTERED_CONFIG_PLUGINS) {
|
|
|
|
LOG(INFO) << " - " << it.first;
|
|
|
|
}
|
|
|
|
|
2014-11-09 04:27:28 +00:00
|
|
|
LOG(INFO) << "Event Publishers:";
|
2014-10-03 15:36:22 +00:00
|
|
|
for (const auto& it : REGISTERED_EVENTPUBLISHERS) {
|
2014-09-24 18:25:05 +00:00
|
|
|
LOG(INFO) << " - " << it.first;
|
|
|
|
}
|
|
|
|
|
2014-11-09 04:27:28 +00:00
|
|
|
LOG(INFO) << "Event Subscribers:";
|
2014-10-03 15:36:22 +00:00
|
|
|
for (const auto& it : REGISTERED_EVENTSUBSCRIBERS) {
|
2014-09-24 18:25:05 +00:00
|
|
|
LOG(INFO) << " - " << it.first;
|
|
|
|
}
|
|
|
|
|
2014-09-23 01:35:12 +00:00
|
|
|
// Start a thread for each appropriate event type
|
2014-10-27 18:55:28 +00:00
|
|
|
osquery::registries::faucet(REGISTERED_EVENTPUBLISHERS,
|
2014-10-28 00:37:36 +00:00
|
|
|
REGISTERED_EVENTSUBSCRIBERS);
|
2014-09-23 01:35:12 +00:00
|
|
|
osquery::EventFactory::delay();
|
2014-07-31 00:35:19 +00:00
|
|
|
|
2014-09-23 01:35:12 +00:00
|
|
|
boost::thread scheduler_thread(osquery::initializeScheduler);
|
2014-07-31 00:35:19 +00:00
|
|
|
scheduler_thread.join();
|
|
|
|
|
2014-09-23 01:35:12 +00:00
|
|
|
// End any event type run loops.
|
|
|
|
osquery::EventFactory::end();
|
|
|
|
|
2014-07-31 00:35:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|