···11+From: Jack Baldry <jack.baldry@grafana.com>
22+Date: Tue, 15 Nov 2022 15:40:31 -0400
33+Subject: [PATCH] Remove circular definition of AUDIT_FILTER_EXCLUDE
44+55+https://github.com/osquery/osquery/issues/6551
66+77+Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
88+---
99+ libraries/cmake/source/libaudit/src/lib/libaudit.h | 1 -
1010+ 1 file changed, 1 deletion(-)
1111+1212+diff --git a/libraries/cmake/source/libaudit/src/lib/libaudit.h b/libraries/cmake/source/libaudit/src/libaudit.h
1313+--- a/libraries/cmake/source/libaudit/src/lib/libaudit.h
1414++++ b/libraries/cmake/source/libaudit/src/lib/libaudit.h
1515+@@ -260,7 +260,6 @@ extern "C" {
1616+ #define AUDIT_KEY_SEPARATOR 0x01
1717+1818+ /* These are used in filter control */
1919+-#define AUDIT_FILTER_EXCLUDE AUDIT_FILTER_TYPE
2020+ #define AUDIT_FILTER_MASK 0x07 /* Mask to get actual filter */
2121+ #define AUDIT_FILTER_UNSET 0x80 /* This value means filter is unset */
2222+2323+--
2424+2.38.1
2525+
+37
pkgs/tools/system/osquery/Remove-git-reset.patch
···11+From: Jack Baldry <jack.baldry@grafana.com>
22+Date: Tue, 15 Nov 2022 13:48:07 -0400
33+Subject: [PATCH] Remove git reset
44+55+This is not required for nixpkgs builds because we are not working in
66+the source repository and therefore do not need to be careful about
77+updating submodule content.
88+99+Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
1010+---
1111+ libraries/cmake/source/modules/utils.cmake | 11 -----------
1212+ 1 file changed, 11 deletions(-)
1313+1414+diff --git a/libraries/cmake/source/modules/utils.cmake b/libraries/cmake/source/modules/utils.cmake
1515+--- a/libraries/cmake/source/modules/utils.cmake
1616++++ b/libraries/cmake/source/modules/utils.cmake
1717+@@ -102,17 +102,6 @@ function(patchSubmoduleSourceCode library_name patches_dir source_dir apply_to_d
1818+ file(COPY "${source_dir}" DESTINATION "${parent_dir}")
1919+ endif()
2020+2121+- # We need to restore the source code to its original state, pre patch
2222+- execute_process(
2323+- COMMAND "${GIT_EXECUTABLE}" reset --hard HEAD
2424+- RESULT_VARIABLE process_exit_code
2525+- WORKING_DIRECTORY "${source_dir}"
2626+- )
2727+-
2828+- if(NOT ${process_exit_code} EQUAL 0)
2929+- message(FATAL_ERROR "Failed to git reset the following submodule: \"${source_dir}\"")
3030+- endif()
3131+-
3232+ set(patchSubmoduleSourceCode_Patched TRUE PARENT_SCOPE)
3333+ endfunction()
3434+3535+--
3636+2.38.1
3737+
···11+From: Jack Baldry <jack.baldry@grafana.com>
22+Date: Tue, 15 Nov 2022 14:34:33 -0400
33+Subject: [PATCH] Use locale.h instead of removed xlocale.h header
44+55+https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27xlocale.h.27
66+77+Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
88+---
99+ libraries/cmake/source/augeas/gnulib/generated/linux/x86_64/lib/locale.h | 4 ++--
1010+ 1 file changed, 2 insertions(+), 2 deletions(-)
1111+1212+diff --git a/libraries/cmake/source/augeas/gnulib/generated/linux/x86_64/lib/locale.h b/libraries/cmake/source/augeas/gnulib/generated/linux/x86_64/lib/locale.h
1313+--- a/libraries/cmake/source/augeas/gnulib/generated/linux/x86_64/lib/locale.h
1414++++ b/libraries/cmake/source/augeas/gnulib/generated/linux/x86_64/lib/locale.h
1515+@@ -48,9 +48,9 @@
1616+ /* NetBSD 5.0 mis-defines NULL. */
1717+ #include <stddef.h>
1818+1919+-/* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */
2020++/* Mac OS X 10.5 defines the locale_t type in <locale.h>. */
2121+ #if 1
2222+-# include <xlocale.h>
2323++# include <locale.h>
2424+ #endif
2525+2626+ /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
2727+--
2828+2.38.1
2929+
+85
pkgs/tools/system/osquery/default.nix
···11+{ lib
22+, cmake
33+, fetchFromGitHub
44+, git
55+, llvmPackages
66+, nixosTests
77+, overrideCC
88+, perl
99+, python3
1010+, stdenv
1111+, openssl_1_1
1212+}:
1313+1414+let
1515+ buildStdenv = overrideCC stdenv llvmPackages.clangUseLLVM;
1616+in
1717+buildStdenv.mkDerivation rec {
1818+ pname = "osquery";
1919+ version = "5.5.1";
2020+2121+ src = fetchFromGitHub {
2222+ owner = "osquery";
2323+ repo = "osquery";
2424+ rev = version;
2525+ fetchSubmodules = true;
2626+ sha256 = "sha256-Q6PQVnBjAjAlR725fyny+RhQFUNwxWGjLDuS5p9JKlU=";
2727+ };
2828+2929+ patches = [
3030+ ./Remove-git-reset.patch
3131+ ./Use-locale.h-instead-of-removed-xlocale.h-header.patch
3232+ ./Remove-circular-definition-of-AUDIT_FILTER_EXCLUDE.patch
3333+ # For current state of compilation against glibc in the clangWithLLVM toolchain, refer to the upstream issue in https://github.com/osquery/osquery/issues/7823.
3434+ ./Remove-system-controls-table.patch
3535+ ];
3636+3737+3838+ buildInputs = [
3939+ llvmPackages.libunwind
4040+ ];
4141+ nativeBuildInputs = [
4242+ cmake
4343+ git
4444+ perl
4545+ python3
4646+ ];
4747+4848+ postPatch = ''
4949+ substituteInPlace cmake/install_directives.cmake --replace "/control" "control"
5050+ # This is required to build libarchive with our glibc version
5151+ # which provides the ARC4RANDOM_BUF function
5252+ substituteInPlace libraries/cmake/source/libarchive/CMakeLists.txt --replace " target_compile_definitions(thirdparty_libarchive PRIVATE" " target_compile_definitions(thirdparty_libarchive PRIVATE HAVE_ARC4RANDOM_BUF"
5353+ # We need to override this hash because we use our own openssl 1.1 version
5454+ substituteInPlace libraries/cmake/formula/openssl/CMakeLists.txt --replace "d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca" "e2f8d84b523eecd06c7be7626830370300fbcc15386bf5142d72758f6963ebc6"
5555+ cat libraries/cmake/formula/openssl/CMakeLists.txt
5656+ '';
5757+5858+ # For explanation of these deletions, refer to the ./Use-locale.h-instead-of-removed-xlocale.h-header.patch file.
5959+ preConfigure = ''
6060+ find libraries/cmake/source -name 'config.h' -exec sed -i '/#define HAVE_XLOCALE_H 1/d' {} \;
6161+ '';
6262+6363+ cmakeFlags = [
6464+ "-DOSQUERY_VERSION=${version}"
6565+ "-DOSQUERY_OPENSSL_ARCHIVE_PATH=${openssl_1_1.src}"
6666+ ];
6767+6868+ postFixup = ''
6969+ patchelf --set-rpath "${llvmPackages.libunwind}/lib:$(patchelf --print-rpath $out/bin/osqueryd)" "$out/bin/osqueryd"
7070+ '';
7171+7272+ passthru.tests.osquery = nixosTests.osquery;
7373+7474+ meta = with lib; {
7575+ description = "SQL powered operating system instrumentation, monitoring, and analytics.";
7676+ longDescription = ''
7777+ The system controls table is not included as it does not presently compile with glibc >= 2.32.
7878+ For more information, refer to https://github.com/osquery/osquery/issues/7823
7979+ '';
8080+ homepage = "https://osquery.io";
8181+ license = licenses.bsd3;
8282+ platforms = platforms.linux;
8383+ maintainers = with maintainers; [ znewman01 lewo ];
8484+ };
8585+}