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

Allow downgrades using RPM and DEB packages #2885

Merged

Conversation

jr0me
Copy link
Member

@jr0me jr0me commented Mar 19, 2024

Related issue
wazuh/wazuh#22522

Description

This PR modifies RPM and DEB scripts for Wazuh agent's packages.

The modifications make it possible to downgrade Wazuh to earlier versions, allowing to rollback upgrades or to undo transactions via package managers across more versions.

Tests

  • Build the package in any supported platform
    • Linux
  • Package installation
  • Package upgrade
  • Package downgrade
  • Package remove
  • Package install/remove/install
  • Change added to CHANGELOG.md

@jr0me jr0me changed the title 22522 dev allow rpm and deb downgrades Allow downgrades using RPM and DEB packages Mar 19, 2024
@jr0me jr0me added the type/enhancement Enhancement issue label Mar 19, 2024
@jr0me jr0me marked this pull request as draft March 19, 2024 13:02
@jr0me jr0me requested a review from TomasTurina March 19, 2024 13:02
jr0me added 3 commits March 22, 2024 13:57
In order to succesfuly downgrade to earlier versions of Wazuh, we need
to restore ownership of files to the ossec group and user.

RPM may also backup the client.keys file, making it impossible for the
agent to reconnect, for this reason we try to restore this backup of
the client.keys if none is found.
The removal of a previous installed pacakge can result in the ossec
group and user being deleted, leaving files orphaned.

Some of these files are needed to be owned by Wazuh to guarantee
the agent connection.
In soeme cases the service lingers and doesn't respond to more graceful attempts.

We then try kill the process if previous attempts didn't work.
@jr0me jr0me force-pushed the 22522-dev-allow-rpm-and-deb-downgrades branch from 11176d1 to 3b31814 Compare March 22, 2024 13:00
@jr0me jr0me changed the base branch from master to 4.9.0 March 22, 2024 13:06
@TomasTurina TomasTurina removed the type/enhancement Enhancement issue label Mar 25, 2024
@jr0me jr0me force-pushed the 22522-dev-allow-rpm-and-deb-downgrades branch from 3b31814 to 27f61ec Compare March 25, 2024 15:58
@jr0me jr0me changed the base branch from 4.9.0 to 21152-improve-wpks March 26, 2024 19:21
@jr0me jr0me marked this pull request as ready for review March 27, 2024 10:51
debs/SPECS/wazuh-agent/debian/postrm Show resolved Hide resolved
debs/SPECS/wazuh-agent/debian/postrm Show resolved Hide resolved
wpk/run.sh Show resolved Hide resolved
@TomasTurina TomasTurina linked an issue Mar 27, 2024 that may be closed by this pull request
@jr0me jr0me force-pushed the 22522-dev-allow-rpm-and-deb-downgrades branch from ed90d71 to c52cb29 Compare March 27, 2024 21:05
jr0me added 3 commits March 27, 2024 22:54
This works fine with newer versions of Wazuh that follow the same paths structure.

Older versions (ones with ossec group and user) require that we restore that expected
paths and ownership.
… need to reflect this on wazuh packages as well to find the correct script.
@jr0me jr0me force-pushed the 22522-dev-allow-rpm-and-deb-downgrades branch from c52cb29 to 8e72c3a Compare March 27, 2024 21:55
@TomasTurina TomasTurina merged commit e590d26 into 21152-improve-wpks Mar 27, 2024
48 checks passed
@TomasTurina TomasTurina deleted the 22522-dev-allow-rpm-and-deb-downgrades branch March 27, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adapt WPK script for Windows and MacOS Allow downgrades using RPM and DEB packages and adapt WPK script
2 participants