From 02a180c557abdc943f43e6f3ad9d459f96754bd1 Mon Sep 17 00:00:00 2001 From: Sangwan Kwon Date: Wed, 17 Jul 2019 09:41:14 +0900 Subject: [PATCH] Reorganize directory structure Signed-off-by: Sangwan Kwon --- CMake/Macro.cmake | 44 +++++++ CMakeLists.txt | 8 +- interface-draft.md => api/README.md | 0 osquery/CMakeLists.txt | 76 ++++-------- osquery/manager/CMakeLists.txt | 19 --- osquery/notification/CMakeLists.txt | 18 --- osquery/{property => tizen}/CMakeLists.txt | 11 +- osquery/{ => tizen}/manager/manager.cpp | 0 osquery/{ => tizen}/manager/manager_impl.cpp | 0 osquery/{ => tizen}/manager/manager_impl.h | 0 .../{ => tizen}/manager/tests/manager_tests.cpp | 0 osquery/{ => tizen}/notification/notification.cpp | 0 .../notification/tests/notification_tests.cpp | 0 osquery/{ => tizen}/property/property.cpp | 0 .../{ => tizen}/property/tests/property_tests.cpp | 0 .../tizen/tsqb}/include/column-pack.hxx | 0 {tsqb => osquery/tizen/tsqb}/include/column.hxx | 0 {tsqb => osquery/tizen/tsqb}/include/condition.hxx | 0 {tsqb => osquery/tizen/tsqb}/include/crud.hxx | 0 {tsqb => osquery/tizen/tsqb}/include/database.hxx | 0 .../tizen/tsqb}/include/expression.hxx | 0 .../tizen/tsqb}/include/table-pack.hxx | 0 {tsqb => osquery/tizen/tsqb}/include/table.hxx | 0 .../tizen/tsqb}/include/tuple-helper.hxx | 0 {tsqb => osquery/tizen/tsqb}/include/type.hxx | 0 {tsqb => osquery/tizen/tsqb}/include/util.hxx | 0 {tsqb => osquery/tizen/tsqb}/tests/tsqb-tests.cpp | 0 {tsqb => osquery/tizen/tsqb}/tsqb.hxx | 0 tools/deployment/make_linux_package.sh | 128 -------------------- tools/deployment/osquery.example.conf | 71 ------------ tools/deployment/osqueryctl | 124 -------------------- tools/deployment/osqueryd.initd | 129 --------------------- {sqlite3 => tools/sqlite3}/CMakeLists.txt | 0 {sqlite3 => tools/sqlite3}/sqlite3.c | 0 {sqlite3 => tools/sqlite3}/sqlite3.h | 0 tools/sync.sh | 51 -------- tsqb/CMakeLists.txt | 16 --- 37 files changed, 77 insertions(+), 618 deletions(-) create mode 100644 CMake/Macro.cmake rename interface-draft.md => api/README.md (100%) delete mode 100644 osquery/manager/CMakeLists.txt delete mode 100644 osquery/notification/CMakeLists.txt rename osquery/{property => tizen}/CMakeLists.txt (65%) rename osquery/{ => tizen}/manager/manager.cpp (100%) rename osquery/{ => tizen}/manager/manager_impl.cpp (100%) rename osquery/{ => tizen}/manager/manager_impl.h (100%) rename osquery/{ => tizen}/manager/tests/manager_tests.cpp (100%) rename osquery/{ => tizen}/notification/notification.cpp (100%) rename osquery/{ => tizen}/notification/tests/notification_tests.cpp (100%) rename osquery/{ => tizen}/property/property.cpp (100%) rename osquery/{ => tizen}/property/tests/property_tests.cpp (100%) rename {tsqb => osquery/tizen/tsqb}/include/column-pack.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/include/column.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/include/condition.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/include/crud.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/include/database.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/include/expression.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/include/table-pack.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/include/table.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/include/tuple-helper.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/include/type.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/include/util.hxx (100%) rename {tsqb => osquery/tizen/tsqb}/tests/tsqb-tests.cpp (100%) rename {tsqb => osquery/tizen/tsqb}/tsqb.hxx (100%) delete mode 100755 tools/deployment/make_linux_package.sh delete mode 100644 tools/deployment/osquery.example.conf delete mode 100755 tools/deployment/osqueryctl delete mode 100755 tools/deployment/osqueryd.initd rename {sqlite3 => tools/sqlite3}/CMakeLists.txt (100%) rename {sqlite3 => tools/sqlite3}/sqlite3.c (100%) rename {sqlite3 => tools/sqlite3}/sqlite3.h (100%) delete mode 100755 tools/sync.sh delete mode 100644 tsqb/CMakeLists.txt diff --git a/CMake/Macro.cmake b/CMake/Macro.cmake new file mode 100644 index 0000000..46b4639 --- /dev/null +++ b/CMake/Macro.cmake @@ -0,0 +1,44 @@ +# Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +MACRO(ADD_OSQUERY_LIBRARY IS_CORE TARGET) + ADD_LIBRARY(${TARGET} OBJECT ${ARGN}) + + IF(${IS_CORE}) + LIST(APPEND ${TARGET_OSQUERY_LIB}_SRCS $) + SET(${TARGET_OSQUERY_LIB}_SRCS ${${TARGET_OSQUERY_LIB}_SRCS} PARENT_SCOPE) + ELSE() + LIST(APPEND ${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS $) + SET(${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS ${${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS} PARENT_SCOPE) + ENDIF() +ENDMACRO(ADD_OSQUERY_LIBRARY TARGET) + +MACRO(ADD_OSQUERY_TEST IS_CORE) + LIST(APPEND ${TARGET_OSQUERY_TEST}_SRCS ${ARGN}) + SET(${TARGET_OSQUERY_TEST}_SRCS ${${TARGET_OSQUERY_TEST}_SRCS} PARENT_SCOPE) +ENDMACRO(ADD_OSQUERY_TEST) + +MACRO(TARGET_OSQUERY_LINK_WHOLE TARGET LIBRARY) + TARGET_LINK_LIBRARIES(${TARGET} "-Wl,-whole-archive") + TARGET_LINK_LIBRARIES(${TARGET} ${LIBRARY}) + TARGET_LINK_LIBRARIES(${TARGET} "-Wl,-no-whole-archive") +ENDMACRO(TARGET_OSQUERY_LINK_WHOLE) + +MACRO(ADD_OSQUERY_MODULE TARGET) + ADD_LIBRARY(${TARGET} SHARED ${ARGN}) + TARGET_LINK_LIBRARIES(${TARGET} dl) + ADD_DEPENDENCIES(${TARGET} ${TARGET_OSQUERY_LIB} glog) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS "-fPIC") + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}) +ENDMACRO(ADD_OSQUERY_MODULE) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37480ba..8c07767 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,17 +45,17 @@ ADD_DEFINITIONS(-DOSQUERY_BUILD_VERSION=${OSQUERY_BUILD_VERSION} INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}") INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/api") INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include") -INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/sqlite3") -INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/tsqb") +INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/tools/sqlite3") +INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/osquery/tizen/tsqb") INCLUDE_DIRECTORIES("/usr/local/include") ENABLE_TESTING() +INCLUDE(CMake/Macro.cmake) INCLUDE(CMake/Thrift.cmake) # Make sure the generated paths exist EXECUTE_PROCESS(COMMAND mkdir -p "${CMAKE_BINARY_DIR}/generated") ADD_SUBDIRECTORY(osquery) -ADD_SUBDIRECTORY(sqlite3) -ADD_SUBDIRECTORY(tsqb) # Type-safe query builder +ADD_SUBDIRECTORY(tools/sqlite3) diff --git a/interface-draft.md b/api/README.md similarity index 100% rename from interface-draft.md rename to api/README.md diff --git a/osquery/CMakeLists.txt b/osquery/CMakeLists.txt index 055ae3c..a122f6f 100644 --- a/osquery/CMakeLists.txt +++ b/osquery/CMakeLists.txt @@ -18,6 +18,10 @@ SET(TARGET_OSQUERY_TEST osquery-test) SET(TARGET_OSQUERY_SHELL osqueryi) SET(TARGET_OSQUERY_DAEMON osqueryd) +SET(${TARGET_OSQUERY_LIB}_SRCS "") +SET(${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS "") +SET(${TARGET_OSQUERY_TEST}_SRCS "") + SET(${TARGET_OSQUERY_LIB}_DEP glog gflags pthread @@ -41,66 +45,11 @@ SET(${TARGET_OSQUERY_LIB}_DEP glog systemd udev ip4tc) -SET(${TARGET_OSQUERY_LIB}_SRCS "") -SET(${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS "") -SET(${TARGET_OSQUERY_TEST}_SRCS "") SET(OSQUERY_CODEGEN_PATH "${CMAKE_SOURCE_DIR}/tools/codegen") SET(OSQUERY_TABLES_PATH "${CMAKE_SOURCE_DIR}") SET(OSQUERY_GENERATED_PATH "${CMAKE_BINARY_DIR}/generated") -ADD_DEFINITIONS("-DOSQUERY_BUILD_VERSION=${OSQUERY_BUILD_VERSION}") - -MACRO(ADD_OSQUERY_LIBRARY IS_CORE TARGET) - ADD_LIBRARY(${TARGET} OBJECT ${ARGN}) - - IF(${IS_CORE}) - LIST(APPEND ${TARGET_OSQUERY_LIB}_SRCS $) - SET(${TARGET_OSQUERY_LIB}_SRCS ${${TARGET_OSQUERY_LIB}_SRCS} PARENT_SCOPE) - ELSE() - LIST(APPEND ${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS $) - SET(${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS ${${TARGET_OSQUERY_LIB_ADDITIONAL}_SRCS} PARENT_SCOPE) - ENDIF() -ENDMACRO(ADD_OSQUERY_LIBRARY TARGET) - -MACRO(ADD_OSQUERY_TEST IS_CORE) - LIST(APPEND ${TARGET_OSQUERY_TEST}_SRCS ${ARGN}) - SET(${TARGET_OSQUERY_TEST}_SRCS ${${TARGET_OSQUERY_TEST}_SRCS} PARENT_SCOPE) -ENDMACRO(ADD_OSQUERY_TEST) - -MACRO(TARGET_OSQUERY_LINK_WHOLE TARGET LIBRARY) - TARGET_LINK_LIBRARIES(${TARGET} "-Wl,-whole-archive") - TARGET_LINK_LIBRARIES(${TARGET} ${LIBRARY}) - TARGET_LINK_LIBRARIES(${TARGET} "-Wl,-no-whole-archive") -ENDMACRO(TARGET_OSQUERY_LINK_WHOLE) - -MACRO(ADD_OSQUERY_MODULE TARGET) - ADD_LIBRARY(${TARGET} SHARED ${ARGN}) - TARGET_LINK_LIBRARIES(${TARGET} dl) - ADD_DEPENDENCIES(${TARGET} ${TARGET_OSQUERY_LIB} glog) - SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS "-fPIC") - SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${TARGET}) -ENDMACRO(ADD_OSQUERY_MODULE) - -ADD_SUBDIRECTORY(core) -ADD_SUBDIRECTORY(config) -ADD_SUBDIRECTORY(dispatcher) -ADD_SUBDIRECTORY(distributed) -ADD_SUBDIRECTORY(devtools) -ADD_SUBDIRECTORY(database) -ADD_SUBDIRECTORY(events) -ADD_SUBDIRECTORY(extensions) -ADD_SUBDIRECTORY(filesystem) -ADD_SUBDIRECTORY(logger) -ADD_SUBDIRECTORY(registry) -ADD_SUBDIRECTORY(sql) -ADD_SUBDIRECTORY(tables) - -# tizen feature -ADD_SUBDIRECTORY(manager) -ADD_SUBDIRECTORY(notification) -ADD_SUBDIRECTORY(property) - ## Table generation ############################################################# FILE(GLOB TABLE_FILES "${CMAKE_SOURCE_DIR}/specs/*.table") FILE(GLOB TABLE_FILES_LINUX "${CMAKE_SOURCE_DIR}/specs/linux/*.table") @@ -146,6 +95,23 @@ ADD_CUSTOM_COMMAND( ${GENERATED_TABLES} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") +## Library-obj generation ########################################################### +ADD_SUBDIRECTORY(core) +ADD_SUBDIRECTORY(config) +ADD_SUBDIRECTORY(dispatcher) +ADD_SUBDIRECTORY(distributed) +ADD_SUBDIRECTORY(devtools) +ADD_SUBDIRECTORY(database) +ADD_SUBDIRECTORY(events) +ADD_SUBDIRECTORY(extensions) +ADD_SUBDIRECTORY(filesystem) +ADD_SUBDIRECTORY(logger) +ADD_SUBDIRECTORY(registry) +ADD_SUBDIRECTORY(sql) +ADD_SUBDIRECTORY(tables) + +ADD_SUBDIRECTORY(tizen) + ## Library generation ########################################################### # TODO(sangwan.kwon): Change amalgation files to additional # static_lib should include every object file in the archive in the link diff --git a/osquery/manager/CMakeLists.txt b/osquery/manager/CMakeLists.txt deleted file mode 100644 index 4570e91..0000000 --- a/osquery/manager/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License - -ADD_OSQUERY_LIBRARY(TRUE osquery_manager manager.cpp - manager_impl.cpp) - -FILE(GLOB OSQUERY_MANAGER_TESTS "tests/*.cpp") -ADD_OSQUERY_TEST(TRUE ${OSQUERY_MANAGER_TESTS}) diff --git a/osquery/notification/CMakeLists.txt b/osquery/notification/CMakeLists.txt deleted file mode 100644 index 4083340..0000000 --- a/osquery/notification/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License - -ADD_OSQUERY_LIBRARY(TRUE osquery_notification notification.cpp) - -FILE(GLOB OSQUERY_NOTIFICATION_TESTS "tests/*.cpp") -ADD_OSQUERY_TEST(TRUE ${OSQUERY_NOTIFICATION_TESTS}) diff --git a/osquery/property/CMakeLists.txt b/osquery/tizen/CMakeLists.txt similarity index 65% rename from osquery/property/CMakeLists.txt rename to osquery/tizen/CMakeLists.txt index d4082a6..68a5dfc 100644 --- a/osquery/property/CMakeLists.txt +++ b/osquery/tizen/CMakeLists.txt @@ -12,7 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License -ADD_OSQUERY_LIBRARY(TRUE osquery_property property.cpp) +ADD_OSQUERY_LIBRARY(TRUE osquery_property property/property.cpp) -FILE(GLOB OSQUERY_PROPERTY_TESTS "tests/*.cpp") -ADD_OSQUERY_TEST(TRUE ${OSQUERY_PROPERTY_TESTS}) +ADD_OSQUERY_LIBRARY(TRUE osquery_manager manager/manager.cpp + manager/manager_impl.cpp) + +ADD_OSQUERY_LIBRARY(TRUE osquery_notification notification/notification.cpp) + +FILE(GLOB OSQUERY_TIZEN_TESTS "*/tests/*.cpp") +ADD_OSQUERY_TEST(TRUE ${OSQUERY_TIZEN_TESTS}) diff --git a/osquery/manager/manager.cpp b/osquery/tizen/manager/manager.cpp similarity index 100% rename from osquery/manager/manager.cpp rename to osquery/tizen/manager/manager.cpp diff --git a/osquery/manager/manager_impl.cpp b/osquery/tizen/manager/manager_impl.cpp similarity index 100% rename from osquery/manager/manager_impl.cpp rename to osquery/tizen/manager/manager_impl.cpp diff --git a/osquery/manager/manager_impl.h b/osquery/tizen/manager/manager_impl.h similarity index 100% rename from osquery/manager/manager_impl.h rename to osquery/tizen/manager/manager_impl.h diff --git a/osquery/manager/tests/manager_tests.cpp b/osquery/tizen/manager/tests/manager_tests.cpp similarity index 100% rename from osquery/manager/tests/manager_tests.cpp rename to osquery/tizen/manager/tests/manager_tests.cpp diff --git a/osquery/notification/notification.cpp b/osquery/tizen/notification/notification.cpp similarity index 100% rename from osquery/notification/notification.cpp rename to osquery/tizen/notification/notification.cpp diff --git a/osquery/notification/tests/notification_tests.cpp b/osquery/tizen/notification/tests/notification_tests.cpp similarity index 100% rename from osquery/notification/tests/notification_tests.cpp rename to osquery/tizen/notification/tests/notification_tests.cpp diff --git a/osquery/property/property.cpp b/osquery/tizen/property/property.cpp similarity index 100% rename from osquery/property/property.cpp rename to osquery/tizen/property/property.cpp diff --git a/osquery/property/tests/property_tests.cpp b/osquery/tizen/property/tests/property_tests.cpp similarity index 100% rename from osquery/property/tests/property_tests.cpp rename to osquery/tizen/property/tests/property_tests.cpp diff --git a/tsqb/include/column-pack.hxx b/osquery/tizen/tsqb/include/column-pack.hxx similarity index 100% rename from tsqb/include/column-pack.hxx rename to osquery/tizen/tsqb/include/column-pack.hxx diff --git a/tsqb/include/column.hxx b/osquery/tizen/tsqb/include/column.hxx similarity index 100% rename from tsqb/include/column.hxx rename to osquery/tizen/tsqb/include/column.hxx diff --git a/tsqb/include/condition.hxx b/osquery/tizen/tsqb/include/condition.hxx similarity index 100% rename from tsqb/include/condition.hxx rename to osquery/tizen/tsqb/include/condition.hxx diff --git a/tsqb/include/crud.hxx b/osquery/tizen/tsqb/include/crud.hxx similarity index 100% rename from tsqb/include/crud.hxx rename to osquery/tizen/tsqb/include/crud.hxx diff --git a/tsqb/include/database.hxx b/osquery/tizen/tsqb/include/database.hxx similarity index 100% rename from tsqb/include/database.hxx rename to osquery/tizen/tsqb/include/database.hxx diff --git a/tsqb/include/expression.hxx b/osquery/tizen/tsqb/include/expression.hxx similarity index 100% rename from tsqb/include/expression.hxx rename to osquery/tizen/tsqb/include/expression.hxx diff --git a/tsqb/include/table-pack.hxx b/osquery/tizen/tsqb/include/table-pack.hxx similarity index 100% rename from tsqb/include/table-pack.hxx rename to osquery/tizen/tsqb/include/table-pack.hxx diff --git a/tsqb/include/table.hxx b/osquery/tizen/tsqb/include/table.hxx similarity index 100% rename from tsqb/include/table.hxx rename to osquery/tizen/tsqb/include/table.hxx diff --git a/tsqb/include/tuple-helper.hxx b/osquery/tizen/tsqb/include/tuple-helper.hxx similarity index 100% rename from tsqb/include/tuple-helper.hxx rename to osquery/tizen/tsqb/include/tuple-helper.hxx diff --git a/tsqb/include/type.hxx b/osquery/tizen/tsqb/include/type.hxx similarity index 100% rename from tsqb/include/type.hxx rename to osquery/tizen/tsqb/include/type.hxx diff --git a/tsqb/include/util.hxx b/osquery/tizen/tsqb/include/util.hxx similarity index 100% rename from tsqb/include/util.hxx rename to osquery/tizen/tsqb/include/util.hxx diff --git a/tsqb/tests/tsqb-tests.cpp b/osquery/tizen/tsqb/tests/tsqb-tests.cpp similarity index 100% rename from tsqb/tests/tsqb-tests.cpp rename to osquery/tizen/tsqb/tests/tsqb-tests.cpp diff --git a/tsqb/tsqb.hxx b/osquery/tizen/tsqb/tsqb.hxx similarity index 100% rename from tsqb/tsqb.hxx rename to osquery/tizen/tsqb/tsqb.hxx diff --git a/tools/deployment/make_linux_package.sh b/tools/deployment/make_linux_package.sh deleted file mode 100755 index 998029a..0000000 --- a/tools/deployment/make_linux_package.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env bash - -# 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. - -set -e - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -SOURCE_DIR="$SCRIPT_DIR/../.." -BUILD_DIR="$SOURCE_DIR/build/linux" -export PATH="$PATH:/usr/local/bin" - -source $SCRIPT_DIR/../lib.sh - -PACKAGE_VERSION=`git describe --tags HEAD` -DESCRIPTION="osquery is an operating system instrumentation toolchain." -if [[ $PACKAGE_VERSION == *"-"* ]]; then - PACKAGE_NAME="osquery-latest" -else - PACKAGE_NAME="osquery" -fi -OUTPUT_PKG_PATH="$BUILD_DIR/$PACKAGE_NAME-$PACKAGE_VERSION." - -# Config files -INITD_SRC="$SCRIPT_DIR/osqueryd.initd" -INITD_DST="/etc/init.d/osqueryd" - -CTL_SRC="$SCRIPT_DIR/osqueryctl" - -OSQUERY_EXAMPLE_CONFIG_SRC="$SCRIPT_DIR/osquery.example.conf" -OSQUERY_EXAMPLE_CONFIG_DST="/usr/share/osquery/osquery.example.conf" -OSQUERY_LOG_DIR="/var/log/osquery/" -OSQUERY_VAR_DIR="/var/osquery" -OSQUERY_ETC_DIR="/etc/osquery" - -WORKING_DIR=/tmp/osquery_packaging -INSTALL_PREFIX=$WORKING_DIR/prefix - -function usage() { - fatal "Usage: $0 -t deb|rpm -d DEPENDENCY_LIST - - This will generate an Linux package with: - (1) An example config /var/osquery/osquery.example.config - (2) An init.d script /etc/init.d/osqueryd - (3) The osquery toolset /usr/bin/osquery*" -} - -function parse_args() { - while [ "$1" != "" ]; do - case $1 in - -t | --type ) shift - PACKAGE_TYPE=$1 - ;; - -d | --dependencies ) shift - PACKAGE_DEPENDENCIES="${@}" - ;; - -h | --help ) usage - ;; - esac - shift - done -} - -function check_parsed_args() { - if [[ $PACKAGE_TYPE = "" ]]; then - usage - fi - - OUTPUT_PKG_PATH=$OUTPUT_PKG_PATH$PACKAGE_TYPE -} - -function main() { - parse_args $@ - check_parsed_args - - platform OS - - rm -rf $WORKING_DIR - rm -f $OUTPUT_PKG_PATH - mkdir -p $INSTALL_PREFIX - - log "copying osquery binaries" - BINARY_INSTALL_DIR="$INSTALL_PREFIX/usr/bin/" - mkdir -p $BINARY_INSTALL_DIR - cp "$BUILD_DIR/osquery/osqueryi" $BINARY_INSTALL_DIR - cp "$BUILD_DIR/osquery/osqueryd" $BINARY_INSTALL_DIR - strip $BINARY_INSTALL_DIR/* - cp "$CTL_SRC" $BINARY_INSTALL_DIR - - # Create the prefix log dir and copy source configs - log "copying osquery configurations" - mkdir -p $INSTALL_PREFIX/$OSQUERY_VAR_DIR - mkdir -p $INSTALL_PREFIX/$OSQUERY_LOG_DIR - mkdir -p $INSTALL_PREFIX/$OSQUERY_ETC_DIR - mkdir -p `dirname $INSTALL_PREFIX$OSQUERY_EXAMPLE_CONFIG_DST` - cp $OSQUERY_EXAMPLE_CONFIG_SRC $INSTALL_PREFIX$OSQUERY_EXAMPLE_CONFIG_DST - - mkdir -p `dirname $INSTALL_PREFIX$INITD_DST` - cp $INITD_SRC $INSTALL_PREFIX$INITD_DST - - log "creating package" - IFS=',' read -a deps <<< "$PACKAGE_DEPENDENCIES" - PACKAGE_DEPENDENCIES= - for element in "${deps[@]}" - do - element=`echo $element | sed 's/ *$//'` - PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES -d \"$element\"" - done - - CMD="fpm -s dir -t $PACKAGE_TYPE \ - -n $PACKAGE_NAME -v $PACKAGE_VERSION \ - $PACKAGE_DEPENDENCIES \ - -p $OUTPUT_PKG_PATH \ - --url http://osquery.io \ - -m osquery@osquery.io \ - --vendor Facebook \ - --license BSD \ - --description \"$DESCRIPTION\" \ - \"$INSTALL_PREFIX/=/\"" - eval "$CMD" - log "package created at $OUTPUT_PKG_PATH" -} - -main $@ diff --git a/tools/deployment/osquery.example.conf b/tools/deployment/osquery.example.conf deleted file mode 100644 index 7f35b2e..0000000 --- a/tools/deployment/osquery.example.conf +++ /dev/null @@ -1,71 +0,0 @@ -{ - /* Configure the daemon below */ - "options": { - // Select the osquery config plugin. - "config_plugin": "filesystem", - - // Select the osquery logging plugin. - "logger_plugin": "filesystem", - - // The log directory stores info, warning, and errors. - // If the daemon uses the 'filesystem' logging retriever then the log_dir - // will also contain the query results. - //"osquery_log_dir": "/var/log/osquery", - - // Set 'disable_logging' to true to prevent writing any info, warning, error - // logs. If a logging plugin is selected it will still write query results. - //"disable_logging": "false", - - // Query differential results are logged as change-events to assist log - // aggregation operations like searching and transactons. - // Set 'log_results_events' to log differentials as transactions. - //"log_result_events": "true", - - // Splay the scheduled interval for queries. - // This is very helpful to prevent system performance impact when scheduling - // large numbers of queries that run a smaller or similar intervals. - //"schedule_splay_percent": "10", - - // Use the system hostname as an identifier for results. - // If hostnames change with DHCP a more static option is 'uuid'. - //"host_identifier": "hostname", - - // Write the pid of the osqueryd process to a pidfile/mutex. - //"pidfile": "/var/osquery/osquery.pidfile", - - // Clear events from the osquery backing store after a number of seconds. - "event_pubsub_expiry": "86000", - - // A filesystem path for disk-based backing storage used for events and - // and query results differentials. See also 'use_in_memory_database'. - //"db_path": "/var/osquery/osquery.db", - - // If using a third-party backing store you may want to run completely in - // memory. Currently rocksdb must use disk-based storage. - //"use_in_memory_database": "false", - - // Comma-delimited list of table names to be disabled. - // This allows osquery to be launched without certain tables. - //"disable_tables": "foo_bar,time", - - // Enable debug or verbose debug output when logging. - "debug": "false", - "verbose_debug": "false", - - // The number of threads for concurrent query schedule execution. - "worker_threads": "4" - }, - - /* Define a schedule of queries */ - "scheduledQueries": [ - // This is a simple example query that outputs information about osquery. - { - // More complicated queries benefit from a name such as 'my_processes'. - "name": "info", - // The exact query to run, include a semi-colon. - "query": "SELECT * FROM osquery_info;", - // The interval in seconds to run this query, not an exact interval. - "interval": 3600 - } - ] -} diff --git a/tools/deployment/osqueryctl b/tools/deployment/osqueryctl deleted file mode 100755 index 008538e..0000000 --- a/tools/deployment/osqueryctl +++ /dev/null @@ -1,124 +0,0 @@ -#!/bin/bash - -ensure_root() { - if [ $UID -ne 0 ]; then - echo "User has insufficient privileges. $0 must be run as root." - exit 4 - fi -} -ensure_root - -check_config() { - if [ ! -e $REAL_CONFIG_PATH ] ; then - echo "No osquery config file found at $REAL_CONFIG_PATH." - echo "See '$EXAMPLE_CONFIG_PATH' for an example config." - exit 4 - fi -} - -# Use this function to detect the operating system that this -platform() { - local __resultvar=$1 - if [[ -f "/etc/redhat-release" ]]; then - eval $__resultvar="centos" - elif [[ -f "/etc/lsb-release" ]]; then - eval $__resultvar="ubuntu" - else - eval $__resultvar=`uname -s | tr '[:upper:]' '[:lower:]'` - fi -} - -platform OS - -if [ $OS = "darwin" ]; then - REAL_CONFIG_PATH="/var/osquery/osquery.conf" - EXAMPLE_CONFIG_PATH="/var/osquery/osquery.example.conf" - PIDFILE="/var/osquery/osquery.pid" - LOCKFILE="/var/osquery/osquery.lock" - EXEC="/usr/local/bin/osqueryd" - PLIST_DOMAIN="com.facebook.osqueryd" - PLIST_PATH="/Library/LaunchDaemons/$PLIST_DOMAIN.plist" - LAUNCHCTL_LIST=`launchctl list | grep com.facebook.osqueryd` - LAUNCHCTL_LIST_PID=`echo $LAUNCHCTL_LIST | awk '{ print $1 }'` -else - INIT_SCRIPT_PATH="/etc/init.d/osqueryd" - if [ ! -e $INIT_SCRIPT_PATH ]; then - echo "Cannot find the init.d script at $INIT_SCRIPT_PATH" - exit 6 - fi - - REAL_CONFIG_PATH="/etc/osquery/osquery.conf" - EXAMPLE_CONFIG_PATH="/usr/share/osquery/osquery.example.conf" - PIDFILE="/var/run/osquery.pid" - LOCKFILE="/var/lock/subsys/osqueryd" - EXEC="/usr/bin/osqueryd" -fi -PROG="osqueryd" - -exec_with_env() { - REAL_CONFIG_PATH=$REAL_CONFIG_PATH \ - EXAMPLE_CONFIG_PATH=$EXAMPLE_CONFIG_PATH \ - PIDFILE=$PIDFILE \ - LOCKFILE=$LOCKFILE \ - EXEC=$EXEC \ - PROG=$PROG \ - $1 - return $? -} - -start() { - check_config - if [ $OS = "darwin" ]; then - launchctl start $PLIST_PATH - else - exec_with_env "service osqueryd start" - fi -} - -stop() { - if [ $OS = "darwin" ]; then - launchctl stop $PLIST_PATH - else - exec_with_env "service osqueryd stop" - fi -} - -restart() { - stop - start -} - -status() { - if [ $OS = "darwin" ]; then - if [[ "$LAUNCHCTL_LIST" = "" || "$LAUNCHCTL_LIST_PID" = "-" ]]; then - echo "$PLIST_DOMAIN is not running" - else - echo "$PLIST_DOMAIN is running. pid: $LAUNCHCTL_LIST_PID" - fi - else - exec_with_env "service osqueryd status" - fi -} - -case "$1" in - start) - $1 - ;; - stop) - $1 - ;; - restart) - $1 - ;; - status) - $1 - ;; - config-check) - $EXEC --config_path=$REAL_CONFIG_PATH --config_check - ;; - *) - echo $"Usage: $0 {start|stop|status|restart}" - exit 2 - -esac -exit $? diff --git a/tools/deployment/osqueryd.initd b/tools/deployment/osqueryd.initd deleted file mode 100755 index b0e6341..0000000 --- a/tools/deployment/osqueryd.initd +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/sh -# -# osqueryd Start/Stop the osquery daemon. -# -# chkconfig: 3345 90 60 -# Description: -# With osquery, you can use SQL to query low-level -# operating system information. Under the hood, instead -# of querying static tables, these queries dynamically execute -# high-performance native code. The results of the -# SQL query are transparently returned to you quickly and easily -# -### BEGIN INIT INFO -# Provides: osquery osqueryd -# Required-Start: $local_fs $syslog -# Required-Stop: $local_fs $syslog -# Default-Start: 3345 -# Default-Stop: 90 -# Short-Description: run osqueryd daemon -# Description: -# With osquery, you can use SQL to query low-level -# operating system information. Under the hood, instead -# of querying static tables, these queries dynamically execute -# high-performance native code. The results of the -# SQL query are transparently returned to you quickly and easily -# -# -### END INIT INFO - -if [ -z $RETVAL ]; then RETVAL=0; fi -if [ -z $PROG ]; then PROG="osqueryd"; fi -if [ -z $EXEC ]; then EXEC=/usr/bin/osqueryd; fi -if [ -z $REAL_CONFIG_PATH ]; then REAL_CONFIG_PATH=/etc/osquery/osquery.conf; fi -if [ -z $LOCKFILE ]; then LOCKFILE=/var/lock/osqueryd; fi -if [ -z $PIDFILE ]; then PIDFILE=/var/run/osquery.pid; fi -if [ -z $UID ]; then UID=$(id -u); fi - -if [ $UID -eq 0 ] && [ -e /etc/sysconfig/$PROG ]; then - . /etc/sysconfig/$PROG -fi - -if [ -e /etc/init.d/functions ]; then - . /etc/init.d/functions -fi - -if [ ! -e $REAL_CONFIG_PATH ] ; then - echo "No osquery config file found at $REAL_CONFIG_PATH" - echo "See '/usr/share/osquery/osquery.example.conf' for an example config." - exit 1 -fi - -ensure_root() { - if [ $UID -ne 0 ] ; then - echo "User has insufficient privilege." - exit 1 - fi -} - -start() { - ensure_root - - if [ -f $PIDFILE ]; then - PID=$(cat $PIDFILE) - PROCNAME=$(ps -p $PID -o comm\=) - if [ "$PROCNAME" = "$PROG" ]; then - return 0 - else - # osqueryd pidfile exists but it's not running - rm $PIDFILE - fi - fi - - $PROG --config_path=$REAL_CONFIG_PATH \ - --pidfile=$PIDFILE \ - --daemonize=true - return $? -} - -stop() { - ensure_root - - if [ ! -f $PIDFILE ] ; then - return 0 - else - PID=$(cat $PIDFILE) - pkill -P $PID && kill -9 $PID - rm -f $PIDFILE - fi -} - -restart() { - stop - start -} - -status() { - if [ ! -f $PIDFILE ] ; then - echo "$PROG is not running. no pidfile found." - else - PID=$(cat $PIDFILE) - PROCNAME=$(ps -p $PID -o comm\=) - if [ "$PROCNAME" = "$PROG" ]; then - echo "$PROG is already running: $PID" - return 0 - else - # osqueryd pidfile exists but it's not running - echo "$PROG is not running but a stale pidfile was found." - fi - fi -} - -case "$1" in - start) - $1 - ;; - stop) - $1 - ;; - restart) - $1 - ;; - status) - $1 - ;; - *) - echo "Usage: $0 {start|stop|status|restart}" - exit 2 -esac -exit $? diff --git a/sqlite3/CMakeLists.txt b/tools/sqlite3/CMakeLists.txt similarity index 100% rename from sqlite3/CMakeLists.txt rename to tools/sqlite3/CMakeLists.txt diff --git a/sqlite3/sqlite3.c b/tools/sqlite3/sqlite3.c similarity index 100% rename from sqlite3/sqlite3.c rename to tools/sqlite3/sqlite3.c diff --git a/sqlite3/sqlite3.h b/tools/sqlite3/sqlite3.h similarity index 100% rename from sqlite3/sqlite3.h rename to tools/sqlite3/sqlite3.h diff --git a/tools/sync.sh b/tools/sync.sh deleted file mode 100755 index 23e2512..0000000 --- a/tools/sync.sh +++ /dev/null @@ -1,51 +0,0 @@ - #!/usr/bin/env bash - -# 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. - -set -e - -if [ "$#" -ne 1 ]; then - echo "Usage: $0 BUILD_DIR" - exit 1 -fi - -BUILD_DIR=$1 -SYNC_DIR="$BUILD_DIR/sync" -VERSION=`git describe --tags HEAD --always` - -if [ -f "$BUILD_DIR/generated" ]; then - echo "Error: $BUILD_DIR/generated not found." - echo "Run 'make sdk' first" - exit 1 -fi - -mkdir -p "$SYNC_DIR" -rm -rf "$SYNC_DIR/osquery*" -mkdir -p "$SYNC_DIR/osquery/generated" - -# merge the headers with the implementation files -cp -R osquery "$SYNC_DIR" -cp -R include/osquery "$SYNC_DIR" -for file in $BUILD_DIR/generated/*.cpp; do - cp "$file" "$SYNC_DIR/osquery/generated/"; -done -cp osquery.thrift "$SYNC_DIR/osquery/extensions" -rm -rf "$SYNC_DIR/osquery/examples" - -# delete all of the old CMake files -find "$SYNC_DIR" -type f -name "CMakeLists.txt" -exec rm -f {} \; - -# make the targets file -mkdir -p "$SYNC_DIR/code-analysis" -(cd "$SYNC_DIR/code-analysis" && SDK=True cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../../../../) -python tools/codegen/gentargets.py -v $VERSION --sdk $VERSION \ - -i "$SYNC_DIR/code-analysis/compile_commands.json" >$SYNC_DIR/osquery/TARGETS - -# wrap it up in a tarball -(cd "$SYNC_DIR" && tar -zcf osquery-sync-$VERSION.tar.gz osquery) -echo "Generated $SYNC_DIR/osquery-sync-$VERSION.tar.gz" diff --git a/tsqb/CMakeLists.txt b/tsqb/CMakeLists.txt deleted file mode 100644 index d4874e6..0000000 --- a/tsqb/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License - -FILE(GLOB TSQB_TESTS "tests/*.cpp") -ADD_OSQUERY_TEST(TRUE ${TSQB_TESTS}) -- 2.7.4