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

Error replacing binary location #625

Open
sdvendramini opened this issue Feb 24, 2025 · 1 comment · May be fixed by #626
Open

Error replacing binary location #625

sdvendramini opened this issue Feb 24, 2025 · 1 comment · May be fixed by #626
Assignees
Labels

Comments

@sdvendramini
Copy link
Member

sdvendramini commented Feb 24, 2025

Description

An error was found in the CMake installation process. When executing:

cmake --install build --prefix /

The following line:

string(REPLACE "WAZUH_HOME" "${BIN_INSTALL_DIR}" FILE_CONTENTS "${FILE_CONTENTS}")

constructs the path to the executable incorrectly in the service files for macOS and Linux, missing the leading /.

Linux:

cat /usr/lib/systemd/system/wazuh-agent.service  
[Unit]  
Description=Wazuh agent  
Wants=network-online.target  
After=network.target network-online.target  

[Service]  
Type=simple  

ExecStart=/usr/bin/env usr/share/wazuh-agent/bin/wazuh-agent  
TimeoutStopSec=30s  

KillSignal=SIGTERM  

RemainAfterExit=yes  

[Install]  
WantedBy=multi-user.target  

macOS:

Image

This causes the following error when trying to start the service.

Image

Windows:

Additionally, it was identified that a / was added to the default paths, causing issues on Windows:

string(REPLACE "\\" "\\\\" DEFAULT_DATA_PATH "/${DATA_INSTALL_DIR}")
string(REPLACE "\\" "\\\\" DEFAULT_RUN_PATH "/${RUN_INSTALL_DIR}")
string(REPLACE "\\" "\\\\" DEFAULT_SHARED_CONFIG_PATH "/${SHARED_CONFIG_INSTALL_DIR}")
string(REPLACE "\\" "\\\\" DEFAULT_CONFIG_PATH "/${CONFIG_INSTALL_DIR}")

Image

@TomasTurina TomasTurina added level/subtask Subtask issue and removed level/task Task issue labels Feb 24, 2025
@wazuhci wazuhci moved this to Backlog in XDR+SIEM/Release 5.0.0 Feb 24, 2025
@wazuhci wazuhci moved this from Backlog to In progress in XDR+SIEM/Release 5.0.0 Feb 25, 2025
@sdvendramini sdvendramini linked a pull request Feb 25, 2025 that will close this issue
8 tasks
@wazuhci wazuhci moved this from In progress to In review in XDR+SIEM/Release 5.0.0 Feb 25, 2025
@wazuhci wazuhci moved this from In review to In progress in XDR+SIEM/Release 5.0.0 Feb 25, 2025
@sdvendramini
Copy link
Member Author

sdvendramini commented Feb 26, 2025

2025/02/25

I started working on the issue and created an initial version of the fix that works according to the tests performed. However, further investigation will be done to see if absolute paths can be defined in commonSettings.cmake.

2025/02/26

The changes introduced in the commonSettings.cmake and config.cmake files are used by the package generation workflows. Therefore, it will be necessary to refactor this, keeping the default paths as they were before, including the leading /.

It is likely that the use of --prefix in the cmake --install command will no longer be necessary after these changes. However, on Unix, its default behavior points to /usr/local, so some testing will be needed to confirm this.
The line: set(CMAKE_INSTALL_PREFIX "" CACHE PATH "Root directory for installation") needs to be modified to: set(CMAKE_INSTALL_PREFIX "" CACHE PATH "Root directory for installation" FORCE) in src/CMakeLists.txt
in order to properly change the default behavior.

Then, the workflows should be modified to perform the builds by overriding the necessary variables as parameters in the CMake commands to properly build the binaries and generate the packages.

Finally, it is necessary to review the package generation processes, as they use different paths during the cmake --install process.

@TomasTurina TomasTurina added level/task Task issue and removed level/subtask Subtask issue labels Feb 26, 2025
@wazuhci wazuhci moved this from In progress to Backlog in XDR+SIEM/Release 5.0.0 Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

2 participants