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

check status before stopping service #12846

Merged
merged 1 commit into from
Apr 25, 2024
Merged

check status before stopping service #12846

merged 1 commit into from
Apr 25, 2024

Conversation

petiepooo
Copy link
Contributor

Resolves #12811 so-verify detects rare false error

If salt is uninstalled prior to a call to so-setup where it detects a previous install, the "Failed" keyword from "systemctl stop $service" causes so-verify to falsely detect an installation error. This might happen if the user removes the salt packages between calls to so-setup, or if upgrading from Ubuntu 20.04 to 22.04 then installing 2.4.xx on top of a 2.3.xx installation.

The fix is to wrap the call to stop the service within a check if the service is running.

This fix ignores the setting of pid var, as the next use of pid is within a while loop that will not execute for the same reason the systemctl stop call was not launched in the background.

resolves #12811 so-verify detects rare false error

If salt is uninstalled during call to so-setup where it detects a previous install, the "Failed" keyword from "systemctl stop $service" causes so-verify to falsely detect an installation error.  This might happen if the user removes the salt packages between calls to so-setup, or if upgrading from Ubuntu 20.04 to 22.04 then installing 2.4.xx on top of a 2.3.xx installation.

The fix is to wrap the call to stop the service in a check if the service is running.

This ignores the setting of pid var, as the next use of pid is within a while loop that will not execute for the same reason the systemctl stop call was not launched in the background.
@petiepooo
Copy link
Contributor Author

Suggested testing method:
run sudo so-setup-network to setup Security Onion (OS should not matter)
run sudo apt purge salt-{minion,master,common} to uninstall salt
run sudo so-setup-network to setup again

Before patch: sosetup.log shows:

2024-04-17T16:15:12Z | INFO | Executing command: salt-call state.apply ssl.remove -linfo --local --file-root=../salt
2024-04-17T16:15:12Z | INFO | Executing command: salt-call state.apply ssl.remove -linfo --local --file-root=../salt
./so-functions: line 40: salt-call: command not found
./so-functions: line 40: salt-call: command not found
2024-04-17T16:15:12Z | INFO | Checking service salt-minion status
2024-04-17T16:15:12Z | INFO | Checking service salt-minion status
Failed to stop salt-minion.service: Unit salt-minion.service not loaded.
2024-04-17T16:15:12Z | INFO | salt-minion is not running
2024-04-17T16:15:12Z | INFO | salt-minion is not running

Also, so-verify at end of setup detects "Failed" keyword and reports installation error.

After patch: sosetup.log show:

2024-04-23T21:04:36Z | INFO | Executing command: salt-call state.apply ssl.remove -linfo --local --file-root=../salt
2024-04-23T21:04:36Z | INFO | Executing command: salt-call state.apply ssl.remove -linfo --local --file-root=../salt
./so-functions: line 40: salt-call: command not found
./so-functions: line 40: salt-call: command not found
2024-04-23T21:04:36Z | INFO | Checking service salt-minion status
2024-04-23T21:04:36Z | INFO | Checking service salt-minion status
2024-04-23T21:04:36Z | INFO | salt-minion is not running
2024-04-23T21:04:36Z | INFO | salt-minion is not running

so-verify reports successful installation.

@TOoSmOotH TOoSmOotH merged commit b5c5c78 into Security-Onion-Solutions:2.4/dev Apr 25, 2024
2 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 25, 2024
@petiepooo petiepooo deleted the fix/check-srvc-status branch April 26, 2024 13:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants