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

macOS Wazuh agent uninstall step fails #7109

Closed
rauldpm opened this issue Mar 7, 2024 · 4 comments · Fixed by #7123
Closed

macOS Wazuh agent uninstall step fails #7109

rauldpm opened this issue Mar 7, 2024 · 4 comments · Fixed by #7123
Assignees
Labels
level/task Task issue type/bug Bug issue

Comments

@rauldpm
Copy link
Member

rauldpm commented Mar 7, 2024

Description


When uninstalling the macOS agent, an error is obtained when the following command is executed:

sh-3.2# /bin/launchctl unload /Library/LaunchDaemons/com.wazuh.agent.plist
/Library/LaunchDaemons/com.wazuh.agent.plist: Could not find specified service
Unload failed: 113: Could not find specified service

We need to fix the documentation with the correct command

sh-3.2# installer -pkg agent.pkg -target /
installer: Package name is Wazuh Agent
installer: Upgrading at base path /
installer: The upgrade was successful.
sh-3.2# ls -l /Library/LaunchDaemons/com.wazuh.agent.plist 
-rw-r--r--  1 root  wheel  461 Mar  7 14:42 /Library/LaunchDaemons/com.wazuh.agent.plist

If this error is related to the package or the source code, please migrate the issue to the related repository

@rauldpm rauldpm added level/task Task issue type/bug Bug issue labels Mar 7, 2024
@vikman90
Copy link
Member

vikman90 commented Mar 8, 2024

@rauldpm I've tested the install/uninstall procedure, and I got no errors:

System

macOS Sonoma 14.3.1 (23D60) @ arm64

Procedure

Install

installer -pkg wazuh-agent-4.8.0-1.arm64.pkg -target /

installer: Package name is Wazuh Agent
installer: Installing at base path /
installer: The install was successful.

Uninstall

/Library/Ossec/bin/wazuh-control stop

wazuh-modulesd not running...
wazuh-logcollector not running...
wazuh-syscheckd not running...
wazuh-agentd not running...
wazuh-execd not running...
Wazuh v4.8.0 Stopped

/bin/rm -r /Library/Ossec
/bin/launchctl unload /Library/LaunchDaemons/com.wazuh.agent.plist
/bin/rm -f /Library/LaunchDaemons/com.wazuh.agent.plist
/bin/rm -rf /Library/StartupItems/WAZUH
/usr/bin/dscl . -delete "/Users/wazuh"
/usr/bin/dscl . -delete "/Groups/wazuh"
/usr/sbin/pkgutil --forget com.wazuh.pkg.wazuh-agent

Forgot package 'com.wazuh.pkg.wazuh-agent' on '/'.

@vikman90 vikman90 self-assigned this Mar 8, 2024
@rauldpm
Copy link
Member Author

rauldpm commented Mar 11, 2024

@vikman90 I used a macOS 12 Monterey ARM instance

I was able to reproduce it in our M1 Monterey machine

sh-3.2# ls -l wazuh-agent-4.8.0-1.arm64.pkg 
-rw-r--r--  1 root  staff  6274253 Mar 11 21:32 wazuh-agent-4.8.0-1.arm64.pkg
sh-3.2# installer -pkg wazuh-agent-4.8.0-1.arm64.pkg -target /
installer: Package name is Wazuh Agent
installer: Installing at base path /
installer: The install was successful.
sh-3.2# /Library/Ossec/bin/wazuh-control stop
wazuh-modulesd not running...
wazuh-logcollector not running...
wazuh-syscheckd not running...
wazuh-agentd not running...
wazuh-execd not running...
Wazuh v4.8.0 Stopped
sh-3.2# /bin/rm -r /Library/Ossec
sh-3.2# /bin/launchctl unload /Library/LaunchDaemons/com.wazuh.agent.plist
/Library/LaunchDaemons/com.wazuh.agent.plist: Could not find specified service
Unload failed: 113: Could not find specified service
sh-3.2# sw_vers
ProductName:	macOS
ProductVersion:	12.1
BuildVersion:	21C52

@nmkoremblum
Copy link
Contributor

nmkoremblum commented Mar 13, 2024

The problem seems to be that you have installed the package and immediately tried to unload the service.

On this issue: wazuh/wazuh#21636, the service has been modified to not be loaded automatically after the installation but after a system reset. If you try to unload such a service when it hasn't yet been loaded, then it will throw an error. Now, if you try the same but after rebooting the system, or after manually loading the service, then you don't get any errors.

@vikman90
Copy link
Member

According to this post:

launchctl stop tries to stop the daemons and their subprocesses, so it's similar to wazuh-control stop. It this is correct:

  • It is a duplicate action.
  • Running this after removing /Library/Ossec has no sense.

Thus, I propose either one of the following changes:

  • Run launchctl stop before wazuh-control stop and ignore the output.
  • Delete the launchctl stop command from the documentation as wazuh-control stop already performs the same action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue type/bug Bug issue
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants