Skip to content

Commit

Permalink
[Auditbeat] Cherry-pick #11565 to 7.0: Package: Open versioned librpm…
Browse files Browse the repository at this point in the history
… shared objects (#11579)

Cherry-pick of PR #11565 to 7.0 branch. Original message: 

To access Librpm functions in the package dataset, we currently dlopen() `/usr/lib64/librpm.so` which is usually a symlink to the versioned shared object e.g. `/usr/lib64/librpm.so.1`. However, this symlink is only present when the package `rpm-devel` is installed and that's usually not the case by default.

This PR changes to using the versioned shared object names as a fallback when the symlink is not available. Versions 1, 3, and 8 are library versions that are present on systems I've tested on, while other in-between versions are not explicitly tested, but it's reasonable to assume they work. In any case, if any of the functions we are looking for are not available the dataset will still abort.

We will have to add new versions as they become available, e.g. if Fedora 30 ships with `librpm.so.9` the dataset will not work out of the box until we add it to the search path. I've thought about adding it pre-emptively since it's likely that it will just work out of the box (we are not using that many functions, and none of the ones we use should have any side effects), but decided not to since we really don't know what could change. And since the generic `librpm.so` symlink is the first in the search path, it's always possible for the user to create or change this symlink to point to a version of their choice.

I've also changed from an absolute path (`/usr/lib64/librpm.so*`) to a generic one (`librpm.so*`) to be more flexible about the location.

With this change, the package dataset works on CentOS 6, 7, and Fedora 29 without the `rpm-devel` package installed. The package is still required for compilation.
  • Loading branch information
Christoph Wurm committed Apr 2, 2019
1 parent b9cf73a commit 6c5687b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ https://github.com/elastic/beats/compare/v7.0.0-rc1...master[Check the HEAD diff

*Auditbeat*

- Package dataset: dlopen versioned librpm shared objects. {pull}11565[11565]

*Filebeat*

- Don't apply multiline rules in Logstash json logs. {pull}11346[11346]
Expand Down
12 changes: 11 additions & 1 deletion x-pack/auditbeat/module/system/package/rpm_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,17 @@ var cFun *cFunctions

func dlopenCFunctions() (*cFunctions, error) {
var librpmNames = []string{
"/usr/lib64/librpm.so",
"librpm.so", // with rpm-devel installed
"librpm.so.8", // Fedora 29
"librpm.so.3", // CentOS 7
"librpm.so.1", // CentOS 6

// Following for completeness, but not explicitly tested
"librpm.so.7",
"librpm.so.6",
"librpm.so.5",
"librpm.so.4",
"librpm.so.2",
}
var cFun cFunctions

Expand Down

0 comments on commit 6c5687b

Please sign in to comment.