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

[Auditbeat] Cherry-pick #10796 to 7.x: Package dataset: Make librpm code compatible across CentOS 6.x, 7.x, and Fedora 29 #10842

Merged
merged 1 commit into from
Feb 25, 2019

Conversation

cwurm
Copy link
Contributor

@cwurm cwurm commented Feb 20, 2019

Cherry-pick of PR #10796 to 7.x branch. Original message:

Librpm version 4.14.2.1 on Fedora 29 no longer contains the headerGetEntry method we are currently using. It was deprecated and then removed in version 4.14 (rpm-software-management/rpm@c68fa9a).

Also, the much older version 4.8.0 of librpm on CentOS 6.10 (Final) does not yet contain newer data structures for tags like rpm_tag_t/rpmTag/rpmTagVal.

This PR makes two changes that should allow this code to work on all three distros (CentOS 6.x, 7.x, Fedora 29 - and hopefully anything in between):

  1. Use headerGetString/headerGetNumber instead of headerGetEntry.
  2. Use int32_t instead of rpm_tag_t/rpmTag/rpmTagVal. Luckily, this seems to work on all three distros. I'd prefer something like a typedef, but unfortunately, C99 does not allow repeating a typedef (C11 does) and so backporting them is not easily possible.

It also makes the code more lenient with errors during data collection: Only when no package name can be found do we return an error.

Together with #10694 this will hopefully allow RPM package collection to work well.

…S 6.x, 7.x, and Fedora 29 (elastic#10796)

Librpm version 4.14.2.1 on Fedora 29 no longer contains the `headerGetEntry` method we are currently using. It was deprecated and then removed in version 4.14 (rpm-software-management/rpm@c68fa9a).

Also, the much older version 4.8.0 of librpm on CentOS 6.10 (Final) does not yet contain newer data structures for tags like `rpm_tag_t/rpmTag/rpmTagVal`.

This PR makes two changes that should allow this code to work on all three distros (CentOS 6.x, 7.x, Fedora 29 - and hopefully anything in between):

1. Use `headerGetString/headerGetNumber` instead of `headerGetEntry`.
2. Use `int32_t` instead of `rpm_tag_t/rpmTag/rpmTagVal`. Luckily, this seems to work on all three distros. I'd prefer something like a typedef, but unfortunately, C99 does not allow repeating a typedef (C11 does) and so backporting them is not easily possible.

It also makes the code more lenient with errors during data collection: Only when no package name can be found do we return an error.

Together with elastic#10694 this will hopefully allow RPM package collection to work well.

(cherry picked from commit e7ea5d7)
@cwurm cwurm requested a review from a team as a code owner February 20, 2019 12:35
@cwurm cwurm changed the title Cherry-pick #10796 to 7.x: [Auditbeat] Package dataset: Make librpm code compatible across CentOS 6.x, 7.x, and Fedora 29 [Auditbeat] Cherry-pick #10796 to 7.x: Package dataset: Make librpm code compatible across CentOS 6.x, 7.x, and Fedora 29 Feb 20, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/secops

Copy link
Contributor

@adriansr adriansr left a comment

Choose a reason for hiding this comment

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

A bit late, but, shouldn't this have a CHANGELOG entry?

@cwurm
Copy link
Contributor Author

cwurm commented Feb 22, 2019

A bit late, but, shouldn't this have a CHANGELOG entry?

You're right, it should have had one originally. I just spoke to Andrew, and we decided to backport this all the way to 6.7 (I just opened #10907). So the package dataset will include this from its first release. Since there will be no change to released functionality I think we should be fine without a changelog entry. But happy to add one if you think it makes sense.

@adriansr
Copy link
Contributor

Nevermind, I thought it had been released already. 👍

@cwurm cwurm merged commit 9180823 into elastic:7.x Feb 25, 2019
@cwurm cwurm deleted the backport_10796_7.x branch February 25, 2019 22:00
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.

3 participants