wazuh-packages icon indicating copy to clipboard operation
wazuh-packages copied to clipboard

Investigate RHEL9 service installation error

Open alberpilot opened this issue 2 years ago • 3 comments

The Wazuh agent installation have the following error on RHEL9:

Failed to execute /usr/lib/systemd/systemd-sysv-instal: No such file or directory

We need to determine the root cause and try to fix it.

alberpilot avatar Jun 06 '22 14:06 alberpilot

Update

This issue appears when enabling the service in RHEL9

[root@rhel9 vagrant]# systemctl enable wazuh-agent
Synchronizing state of wazuh-agent.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable wazuh-agent
Failed to execute /usr/lib/systemd/systemd-sysv-install: No such file or director

The problem appears because in RHEL9 the file /usr/lib/systemd/systemd-sysv-install was removed. Here RHEL indicates the following:

SYSV INIT.D SCRIPTS:
        When calling "systemctl enable/disable/is-enabled" on a unit which is a
        SysV init.d script, it calls /usr/lib/systemd/systemd-sysv-install;
        this needs to translate the action into the distribution specific
        mechanism such as chkconfig or update-rc.d. Packagers need to provide
        this script if you need this functionality (you don't if you disabled
        SysV init support).

        Please see src/systemctl/systemd-sysv-install.SKELETON for how this
        needs to look like, and provide an implementation at the marked places.

So we will need to add the systemd-sysv-install to the packages or not install the init.d script in rhel9 systems.

DFolchA avatar Jun 09 '22 16:06 DFolchA

Related: https://github.com/wazuh/wazuh/issues/13602

snaow avatar Jun 15 '22 08:06 snaow

@alberpilot @okynos Please reopen, as this issue also occurs on e.g. AlmaLinux 9 (an RHEL9 derivative), and probably on all other derivatives (e.g. Rocky Linux 9) too.

The fix in https://github.com/wazuh/wazuh-packages/pull/1675/files/e2ddbef5a383b9a81d216fe959cda7dcae009662#r988236307 only checks for {NAME}" = "Red Hat Enterprise Linux"

AlmaLinux 9 /etc/os-release example :

NAME="AlmaLinux"
VERSION="9.0 (Emerald Puma)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.0"
PLATFORM_ID="platform:el9"
PRETTY_NAME="AlmaLinux 9.0 (Emerald Puma)"
ANSI_COLOR="0;34"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:almalinux:almalinux:9::baseos"
HOME_URL="https://almalinux.org/"
DOCUMENTATION_URL="https://wiki.almalinux.org/"
BUG_REPORT_URL="https://bugs.almalinux.org/"

ALMALINUX_MANTISBT_PROJECT="AlmaLinux-9"
ALMALINUX_MANTISBT_PROJECT_VERSION="9.0"
REDHAT_SUPPORT_PRODUCT="AlmaLinux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.0"

didierm avatar Oct 05 '22 18:10 didierm

Related: https://github.com/wazuh/wazuh-packages/issues/1918

rauldpm avatar Nov 02 '22 15:11 rauldpm

As said in previous comments, not installing init.d when it is not needed would solve this problem. Issue #1918 would so solve this problem for any distribution. As a temporary workaround, the fix that was done for Red Hat Enterprise Linux 9> is being extended to the rest of its derivative OS's. The only Red Hat Enterprise Linux derivatives that have released a version based on version 9 are Alma Linux, Rocky Linux , as seen here. The rest of distributions have been checked one by one and at date 19/01/2023 none have a version based on RHEL 9. Oracle version does have a version 9 based off of Red Hat Enterprise Linux 9, but has been tested and does not replicate the error, for whatever reason.

Replicated in each distribution

  • Alma Linux 9:
[root@alma9 vagrant]# systemctl enable wazuh-agent
Synchronizing state of wazuh-agent.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable wazuh-agent
Failed to execute /usr/lib/systemd/systemd-sysv-install: No such file or directory
  • Rocky LInux 9:
[root@rocky9 vagrant]# systemctl enable wazuh-agent
Synchronizing state of wazuh-agent.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable wazuh-agent
Failed to execute /usr/lib/systemd/systemd-sysv-install: No such file or directory
[root@rocky9 vagrant]# 

  • Oracle Linux 9:
[root@oracle9 vagrant]# systemctl enable wazuh-agent
Synchronizing state of wazuh-agent.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable wazuh-agent
Created symlink /etc/systemd/system/multi-user.target.wants/wazuh-agent.service → /usr/lib/systemd/system/wazuh-agent.service.
[root@oracle9 vagrant]#  

verdx avatar Jan 19 '23 18:01 verdx

After some problems with the debugging for the Github Actions test, finally using act made it possible to see the errors, a file wrongly typed and the fact that the variables used in the ubuntu docker aren't accessible in the docker created inside it. Both errors are now fixed in commit https://github.com/wazuh/wazuh-packages/pull/2053/commits/163d3b65402d0cb5a58f94288da44430f6e7eab5 and the tests have been launched again.

verdx avatar Jan 23 '23 16:01 verdx

Waiting for the checks in https://github.com/wazuh/wazuh-packages/actions/runs/3988318050/jobs/6839306896

verdx avatar Jan 23 '23 17:01 verdx

As per this commentary in the Pull Request, both CentOS 9 Stream and Fedora 34 have been tested and the error has been discovered in both of them. Both have been added to the fix.

verdx avatar Feb 02 '23 16:02 verdx