Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osquery: 2.5.2 -> 3.2.2 #39336

Merged
merged 2 commits into from Apr 24, 2018
Merged

osquery: 2.5.2 -> 3.2.2 #39336

merged 2 commits into from Apr 24, 2018

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Apr 22, 2018

Motivation for this change

The package was originally broken as reported in #38940 and
osquery/osquery#4257. The latest version (3.x) contains several
important fixes for GCC 7, so now we can compile without a much less
complicated patches.

The following changes were needed to fix the derivation:

  • Upgrade osquery/third-party to the latest rev to be compliant with
    osquery 3.

  • Keep using an override for the AWS SDK (for a lower closure size and
    less compile time), but make the ec2 API available.

  • Added the dependencies fpm, zstd, rdkafka, rapidjson to the
    build. linenoise-ng is obsolete as it's directly bundled with
    osquery/third-party.

  • Fixed the linking issue with gflags as recommended in the mailing
    list: https://groups.google.com/d/msg/nix-devel/l1blj-mWxtI/J3CwPATBCAAJ

  • Dropped the obsolete dependencies cpp-netlib, lz4, apt and
    devicemapper (thanks @infinisil).

  • Applied the patch from tools/get_platform.py: add support for nixos osquery/osquery#4267 for NixOS support during
    configure phase, override OSQUERY_PLATFORM to provide nixos:version
    for sandbox and non-NixOS based builds. The platform-nixos.patch
    file is now obsolete (thanks @flokli).

  • Dropped the newline character from .version to avoid \n in the
    distro version provided by osquery

The patch was rebased against the 3.x branch of osquery and contains
mostly old changes. Additionally several testing targets were skipped as
they broke the build.

The functionality has been testing using the following command:

mkdir /tmp/osq.log/
./result/bin/osqueryd --pidfile /tmp/osq.pid \
  --database_path /tmp/test.db --logger_path /tmp/osq.log

With the daemon running the database can be queried easily using
./result/bin/osqueryi.

Fixes ticket #38940
See ticket #36453

Further reference can be gathered from the affected Hydra logs for
the master branch: https://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.osquery.x86_64-linux

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: osquery

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Failure on x86_64-linux (full log)

Attempted: osquery

Partial log (click to expand)

patching script interpreter paths in /nix/store/3n12pzp1znfsr07a7r8a9g9ywwqm160b-aws-sdk-cpp-1.4.33
checking for references to /build in /nix/store/3n12pzp1znfsr07a7r8a9g9ywwqm160b-aws-sdk-cpp-1.4.33...
shrinking RPATHs of ELF executables and libraries in /nix/store/ldc79lsmj10r3imijlddwdi2ks4gj4s7-aws-sdk-cpp-1.4.33-dev
patching script interpreter paths in /nix/store/ldc79lsmj10r3imijlddwdi2ks4gj4s7-aws-sdk-cpp-1.4.33-dev
checking for references to /build in /nix/store/ldc79lsmj10r3imijlddwdi2ks4gj4s7-aws-sdk-cpp-1.4.33-dev...
shrinking RPATHs of ELF executables and libraries in /nix/store/3jcnvd0va0xvh9fkzv433wyj9gfi93bn-aws-sdk-cpp-1.4.33-debug
patching script interpreter paths in /nix/store/3jcnvd0va0xvh9fkzv433wyj9gfi93bn-aws-sdk-cpp-1.4.33-debug
checking for references to /build in /nix/store/3jcnvd0va0xvh9fkzv433wyj9gfi93bn-aws-sdk-cpp-1.4.33-debug...
cannot build derivation '/nix/store/hbjqnqb230fhpc0js447z1ihxbvph4zg-osquery-3.2.2.drv': 1 dependencies couldn't be built
�[31;1merror:�[0m build of '/nix/store/hbjqnqb230fhpc0js447z1ihxbvph4zg-osquery-3.2.2.drv' failed

@Ma27
Copy link
Member Author

Ma27 commented Apr 22, 2018

ok, rebasing onto the latest master seems to have killed it because of newly broken builds...
Will continue to investigate...

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: osquery

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: osquery

Partial log (click to expand)

post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/rv7s4rcdl660rrv9bf6xyvckq00yvh6a-osquery-3.2.2
shrinking /nix/store/rv7s4rcdl660rrv9bf6xyvckq00yvh6a-osquery-3.2.2/bin/osqueryd
shrinking /nix/store/rv7s4rcdl660rrv9bf6xyvckq00yvh6a-osquery-3.2.2/bin/osqueryi
strip is /nix/store/j75dgadrff2d1fyc4fczmcgqkid2imdx-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/rv7s4rcdl660rrv9bf6xyvckq00yvh6a-osquery-3.2.2/bin
patching script interpreter paths in /nix/store/rv7s4rcdl660rrv9bf6xyvckq00yvh6a-osquery-3.2.2
/nix/store/rv7s4rcdl660rrv9bf6xyvckq00yvh6a-osquery-3.2.2/etc/init.d/osqueryd: interpreter directive changed from "/bin/sh" to "/nix/store/xn5gv3lpfy91yvfy9b0i7klfcxh9xskz-bash-4.4-p19/bin/sh"
checking for references to /build in /nix/store/rv7s4rcdl660rrv9bf6xyvckq00yvh6a-osquery-3.2.2...
/nix/store/rv7s4rcdl660rrv9bf6xyvckq00yvh6a-osquery-3.2.2

@infinisil
Copy link
Member

infinisil commented Apr 22, 2018

When I run your command as root for the daemon (and having corrected --database-path to --database_path) it gives me this error:

$ sudo result/bin/osqueryd --pidfile /tmp/osq.pid --database_path /tmp/test.db --logger_path /tmp/osq.log
E0422 23:39:28.478080 19220 init.cpp:565] Cannot activate filesystem logger plugin:
  Could not create file: /tmp/osq.log/osqueryd.results.log

Even running with root doesn't make it work.

Here is the strace tail:

ioprio_set(IOPRIO_WHO_PGRP, 0, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 3)) = -1 EINVAL (Invalid argument)
stat("/etc/osquery/extensions.load", 0x7ffdc8deb0d0) = -1 ENOENT (No such file or directory)
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f3578b0f000
mprotect(0x7f3578b10000, 8388608, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0x7f357930b2b0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f357930f9d0, tls=0x7f357930f700, child_tidptr=0x7f357930f9d0) = 29741
futex(0x7f357930f9d0, FUTEX_WAIT, 29741, NULL�[0;31mE0422 23:44:55.228698 29742 init.cpp:565] Cannot activate filesystem logger plugin: Could not create file: /tmp/osq.log/osqueryd.results.log
�[m) = 0
close(4)                                = 0
exit_group(78)                          = ?
+++ exited with 78 +++

I thought it might have something to do with me using ZFS, but I also tried it with a tmpfs but I get exactly the same error.

@Mic92
Copy link
Member

Mic92 commented Apr 22, 2018

The interesting part where it creates the log file is not included in strace here.

@infinisil
Copy link
Member

@Mic92 Good point, but even in the full strace it doesn't show up: https://gist.github.com/Infinisil/eb224302b74d3d56a1a4ef2cfce46208 (search for "osq.log"). I think it's the clone call that does something in another thread or something (I'm no syscall expert).

@Mic92
Copy link
Member

Mic92 commented Apr 22, 2018

Use -f for strace so it will follow forks.

@infinisil
Copy link
Member

Ah yes this makes it a bit clearer: https://gist.github.com/Infinisil/568c8915033266df0d18280951e4e012#file-strace-L6185-L6203

openat(AT_FDCWD, "/tmp//osqueryd.paul.root.log.ERROR.20180423-005306.2352", O_WRONLY|O_CREAT|O_EXCL, 0664)

It seems to have the logger path set to "" at that point :/

@Ma27
Copy link
Member Author

Ma27 commented Apr 23, 2018

When I run your command as root for the daemon (and having corrected --database-path to --database_path) it gives me this error:

Ouch, that's been an avoidable typo, thx! :/

It seems to have the logger path set to "" at that point :/

As stated in the docs (https://github.com/facebook/osquery/blob/3.2.3/docs/wiki/deployment/logging.md) they write files into the logger_path, so they expect it to be a directory.

The module creates the logger_path in the preStart hook of the systemd service as well, so I guess that this is the expected behavior.

@flokli
Copy link
Contributor

flokli commented Apr 23, 2018

@Ma27 Thanks a lot for doing that bump! I'll soon give this a try as well :-)

I recently filed osquery/osquery#4267 adding support for NixOS to tools/get_platform.py, mainly for building osquery outside the sandbox (as /etc/os-release shouldn't be accessible from the sandbox anyways), but this might help upstreaming some other patches as well, and also get some insight in the "quite odd dependency management" mentioned there - for example, we use sqlite from nixpkgs instead of the one from third-party.

Can you set OSQUERY_PLATFORM instead of applying pkgs/tools/system/osquery/platform-nixos.patch?

@infinisil
Copy link
Member

@Ma27 Ahh, how did I not think of creating that directory, it works indeed. But that error was rather confusing for such a basic problem.

Now that I can verify it working, I'm going to suggest this patch which removes unnecessary dependencies:

diff --git a/pkgs/tools/system/osquery/default.nix b/pkgs/tools/system/osquery/default.nix
index 8fb2226b7f5..93c971b3998 100644
--- a/pkgs/tools/system/osquery/default.nix
+++ b/pkgs/tools/system/osquery/default.nix
@@ -1,23 +1,14 @@
 { stdenv, lib, fetchFromGitHub, pkgconfig, cmake, pythonPackages
 , udev, audit, aws-sdk-cpp, cryptsetup, lvm2, libgcrypt, libarchive
-, libgpgerror, libuuid, iptables, apt, dpkg, lzma, lz4, bzip2, rpm
+, libgpgerror, libuuid, iptables, dpkg, lzma, bzip2, rpm
 , beecrypt, augeas, libxml2, sleuthkit, yara, lldpd, google-gflags
-, thrift, boost, rocksdb_lite, cpp-netlib, glog, gbenchmark, snappy
-, openssl, file, doxygen, devicemapper
+, thrift, boost, rocksdb_lite, glog, gbenchmark, snappy
+, openssl, file, doxygen
 , gtest, sqlite, fpm, zstd, rdkafka, rapidjson
 }:
 
 let
 
-  aws-sdk-cpp' = aws-sdk-cpp.overrideAttrs (_: {
-    src = fetchFromGitHub {
-      owner = "awslabs";
-      repo = "aws-sdk-cpp";
-      rev = "1.2.7";
-      sha256 = "182wr6j4pqz7g7j9b9cdgkpmflv3b17kl52gkwfz5b2qr8dix2ca";
-    };
-  });
-
   thirdparty = fetchFromGitHub {
     owner = "osquery";
     repo = "third-party";
@@ -44,7 +35,7 @@ stdenv.mkDerivation rec {
   patches = [ ./misc.patch ] ++ lib.optional stdenv.isLinux ./platform-nixos.patch;
 
   nativeBuildInputs = [
-    pkgconfig cmake pythonPackages.python pythonPackages.jinja2
+    pkgconfig cmake pythonPackages.python pythonPackages.jinja2 doxygen fpm
   ];
 
   buildInputs = let
@@ -54,17 +45,16 @@ stdenv.mkDerivation rec {
   in [
     udev audit
 
-    (aws-sdk-cpp'.override {
+    (aws-sdk-cpp.override {
       apis = [ "firehose" "kinesis" "sts" "ec2" ];
       customMemoryManagement = false;
     }).dev
-
-    lvm2 libgcrypt libarchive libgpgerror libuuid iptables.dev apt dpkg
-    lzma lz4 bzip2 rpm beecrypt augeas libxml2 sleuthkit
+    lvm2 libgcrypt libarchive libgpgerror libuuid iptables dpkg
+    lzma bzip2 rpm beecrypt augeas libxml2 sleuthkit
     yara lldpd gflags' thrift boost
-    cpp-netlib glog gbenchmark snappy openssl
-    file doxygen devicemapper cryptsetup
-    gtest sqlite fpm zstd rdkafka rapidjson rocksdb_lite
+    glog gbenchmark snappy openssl
+    file cryptsetup
+    gtest sqlite zstd rdkafka rapidjson rocksdb_lite
   ];
 
   preConfigure = ''
  • Version 1.2.7 of aws-sdk-cpp isn't needed, the latest one works just fine
  • Moves doxygen and fpm to nativeBuildInputs
  • Removes dependencies apt, lz4, cpp-netlib and devicemapper

@Ma27
Copy link
Member Author

Ma27 commented Apr 23, 2018

I recently filed osquery/osquery#4267 adding support for NixOS to tools/get_platform.py, mainly for building osquery outside the sandbox (as /etc/os-release shouldn't be accessible from the sandbox anyways), but this might help upstreaming some other patches as well, and also get some insight in the "quite odd dependency management" mentioned there - for example, we use sqlite from nixpkgs instead of the one from third-party.

Awesome! I've just seen the ticket regarding compilation errors on NixOS, but I've obviously missed that. This looks indeed like a much better solution, I'll give it a try!

Ahh, how did I not think of creating that directory, it works indeed. But that error was rather confusing for such a basic problem.

You're absolutely right! I stumbled about this as well :-)

Now that I can verify it working, I'm going to suggest this patch which removes unnecessary dependencies:

Thanks! I didn't like the AWS override hack either, so I'll try it out :-)

@Ma27
Copy link
Member Author

Ma27 commented Apr 23, 2018

I fixed the commit with the comments from @infinisil and @flokli, thanks a lot!

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: osquery

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: osquery

Partial log (click to expand)

post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/icbip8m9wsmwh05dgszm5wr0yg4q1j9x-osquery-3.2.2
shrinking /nix/store/icbip8m9wsmwh05dgszm5wr0yg4q1j9x-osquery-3.2.2/bin/osqueryd
shrinking /nix/store/icbip8m9wsmwh05dgszm5wr0yg4q1j9x-osquery-3.2.2/bin/osqueryi
strip is /nix/store/j75dgadrff2d1fyc4fczmcgqkid2imdx-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/icbip8m9wsmwh05dgszm5wr0yg4q1j9x-osquery-3.2.2/bin
patching script interpreter paths in /nix/store/icbip8m9wsmwh05dgszm5wr0yg4q1j9x-osquery-3.2.2
/nix/store/icbip8m9wsmwh05dgszm5wr0yg4q1j9x-osquery-3.2.2/etc/init.d/osqueryd: interpreter directive changed from "/bin/sh" to "/nix/store/xn5gv3lpfy91yvfy9b0i7klfcxh9xskz-bash-4.4-p19/bin/sh"
checking for references to /build in /nix/store/icbip8m9wsmwh05dgszm5wr0yg4q1j9x-osquery-3.2.2...
/nix/store/icbip8m9wsmwh05dgszm5wr0yg4q1j9x-osquery-3.2.2

patches = [
./misc.patch
(fetchpatch {
url = "https://patch-diff.githubusercontent.com/raw/facebook/osquery/pull/4267.patch";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This url will break if changes are made to the pull request. @flokli could you make a dedicated branch for this that is independent from the pull request and that will not change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need that patch here at all? This tools/get_platform.py shouldn't even run if OSQUERY_PLATFORM is set…

cpp-netlib glog gbenchmark snappy openssl linenoise-ng
file doxygen devicemapper cryptsetup
gtest sqlite
}).dev
Copy link
Member

@infinisil infinisil Apr 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why .dev specifically? I'm pretty sure that's not needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.dev is the output of the derivation which contains the development headers. Just search with rg "\.dev" the nixpkgs repo and you'll see that this is needed sometimes (Obviously the aws-sdk doesn't provide the headers in out)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildInputs chooses dev outputs automatically:

dependencies = map (map lib.chooseDevOutputs) [

@@ -1 +1 @@
18.09
18.09
Copy link
Member

@infinisil infinisil Apr 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the history of this .version file, there were a couple times where this has been updated to remove the trailing newline, and the reason for that is the nixpkgs/.editorconfig file which specifies that a trailing newline should be inserted for all files. You can add the following section to that file to prevent further newline insertions for that file:

[.version]
insert_final_newline = false

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be addressed in a different commit or PR for the git history?


# this is what `osquery --help` will show as the version.
OSQUERY_BUILD_VERSION = version;
OSQUERY_PLATFORM = "nixos;${builtins.readFile "${builtins.toString path}/.version"}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toString is available at top-level scope, so you can remove the builtins. here.

@Ma27
Copy link
Member Author

Ma27 commented Apr 23, 2018

thanks for the suggestions, I'll make the requested changes tonight :-)

@Ma27
Copy link
Member Author

Ma27 commented Apr 23, 2018

@infinisil you're absolutely right, thanks!

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! One last thing though: I would put the .editorconfig update and newline removal in a first commit and the osquery update in a second one.

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: osquery

Partial log (click to expand)

/nix/store/icbip8m9wsmwh05dgszm5wr0yg4q1j9x-osquery-3.2.2

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: osquery

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@Ma27
Copy link
Member Author

Ma27 commented Apr 23, 2018

@Mic92 @flokli patch is removed %)

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: osquery

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: osquery

Partial log (click to expand)

post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/3gacg6f39rfpkggbdp86a2mvavkk98l3-osquery-3.2.2
shrinking /nix/store/3gacg6f39rfpkggbdp86a2mvavkk98l3-osquery-3.2.2/bin/osqueryd
shrinking /nix/store/3gacg6f39rfpkggbdp86a2mvavkk98l3-osquery-3.2.2/bin/osqueryi
strip is /nix/store/j75dgadrff2d1fyc4fczmcgqkid2imdx-binutils-2.30/bin/strip
stripping (with command strip and flags -S) in /nix/store/3gacg6f39rfpkggbdp86a2mvavkk98l3-osquery-3.2.2/bin
patching script interpreter paths in /nix/store/3gacg6f39rfpkggbdp86a2mvavkk98l3-osquery-3.2.2
/nix/store/3gacg6f39rfpkggbdp86a2mvavkk98l3-osquery-3.2.2/etc/init.d/osqueryd: interpreter directive changed from "/bin/sh" to "/nix/store/xn5gv3lpfy91yvfy9b0i7klfcxh9xskz-bash-4.4-p19/bin/sh"
checking for references to /build in /nix/store/3gacg6f39rfpkggbdp86a2mvavkk98l3-osquery-3.2.2...
/nix/store/3gacg6f39rfpkggbdp86a2mvavkk98l3-osquery-3.2.2

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @zimbatm indicated, the .version thing really needs to be in a different commit or PR

When reading the `nixpkgs` version from `.version` you always have a
`\n` at the end because of the final newline.

This issue exists since b7d15ed and had to be fixed several times
according to the history of `.version`.

Furthermore @infinisil recommended I explicitly configured
`.editorconfig` to avoid newlines in `.version`.
The package was originally broken as reported in NixOS#38940 and
osquery/osquery#4257. The latest version (3.x) contains several
important fixes for GCC 7, so now we can compile without a much less
complicated patches.

The following changes were needed to fix the derivation:

* Upgrade `osquery/third-party` to the latest rev to be compliant with
  osquery 3.

* Keep using an override for the AWS SDK (for a lower closure size and
  less compile time), but make the `ec2` API available.

* Added the dependencies `fpm`, `zstd`, `rdkafka`, `rapidjson` to the
  build. `linenoise-ng` is obsolete as it's directly bundled with
  `osquery/third-party`.

* Fixed the linking issue with `gflags` as recommended in the mailing
  list: https://groups.google.com/d/msg/nix-devel/l1blj-mWxtI/J3CwPATBCAAJ

* Dropped the obsolete dependencies `cpp-netlib`, `lz4`, `apt` and
  `devicemapper` (thanks @infinisil).

* Override `OSQUERY_PLATFORM` to provide `nixos:version`
  for sandbox and non-NixOS based builds. The `platform-nixos.patch`
  file is now obsolete (thanks @flokli).

The patch was rebased against the 3.x branch of `osquery` and contains
mostly old changes. Additionally several testing targets were skipped as
they broke the build.

The functionality has been testing using the following command:

```
mkdir /tmp/osq.log/
./result/bin/osqueryd --pidfile /tmp/osq.pid \
  --database_path /tmp/test.db --logger_path /tmp/osq.log
```

With the daemon running the database can be queried easily using
`./result/bin/osqueryi`.

Fixes ticket NixOS#38940
See ticket NixOS#36453

Further reference can be gathered from the affected Hydra logs for
the master branch: https://hydra.nixos.org/job/nixos/trunk-combined/nixpkgs.osquery.x86_64-linux
@Ma27
Copy link
Member Author

Ma27 commented Apr 24, 2018

@infinisil @zimbatm done %)

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: osquery

Partial log (click to expand)

/nix/store/3gacg6f39rfpkggbdp86a2mvavkk98l3-osquery-3.2.2

@GrahamcOfBorg
Copy link

No attempt on aarch64-linux (full log)

The following builds were skipped because they don't evaluate on aarch64-linux: osquery

Partial log (click to expand)


a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowUnsupportedSystem = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowUnsupportedSystem = true; }
to ~/.config/nixpkgs/config.nix.


@Mic92 Mic92 merged commit 62529a6 into NixOS:master Apr 24, 2018
@Ma27 Ma27 deleted the fix-osquery branch April 24, 2018 08:30
@Ma27 Ma27 mentioned this pull request Apr 30, 2018
8 tasks
Ma27 added a commit to Ma27/nixpkgs that referenced this pull request Apr 30, 2018
Some time ago I fixed the broken package `osquery` (see NixOS#39336).
I had to test the package manually by starting the daemon locally,
however this doesn't ensure that the module is still functional.

In order to cover the package *and* the integration with the NixOS
module I thought that adding a testcase might be the best idea.

The current testcase does the following things:

* Starts an `osqueryd` service in a test machine with customized logger
  path and PID file

* Ensures that the `osqueryd.service` unit is running

* Checks if the customized flags (`pidfile`, `logger_path`) are applied
  to `osquery`.

* Performs a simple test query against the `etc_hosts` database to check
  if the basic funcitonality of `osquery` (storing system information into
  a database) works fine.
Synthetica9 pushed a commit to Synthetica9/nixpkgs that referenced this pull request May 3, 2018
Some time ago I fixed the broken package `osquery` (see NixOS#39336).
I had to test the package manually by starting the daemon locally,
however this doesn't ensure that the module is still functional.

In order to cover the package *and* the integration with the NixOS
module I thought that adding a testcase might be the best idea.

The current testcase does the following things:

* Starts an `osqueryd` service in a test machine with customized logger
  path and PID file

* Ensures that the `osqueryd.service` unit is running

* Checks if the customized flags (`pidfile`, `logger_path`) are applied
  to `osquery`.

* Performs a simple test query against the `etc_hosts` database to check
  if the basic funcitonality of `osquery` (storing system information into
  a database) works fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants