-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Systemd control #895
base: master
Are you sure you want to change the base?
Systemd control #895
Conversation
execution order. dbd, agentless, and csyslog only start after everything else, but I did not concern myself with the execution order of those 3.
I have no doubts the logic can improve, but I want to get a PoC in place.
systemd know when to start these programs.
actually start the daemons
src/init/ossec-server.sh
Outdated
## XXX - system paths and exact execution are probably wrong. | ||
if [ X`uname` == "XLinux" ]; then | ||
if [ -x /sbin/systemctl ]; then | ||
/sbin/ssytemctl start ossec-server.service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ssytemctl
Think this might need to be systemctl
Fixed the ssytemctl typo. |
…into systemd_combined
…stemd_combined
Add the same stuff for ossec-agent
…s/git/github/ddpbsd/ossec-hids into systemd_control
I'm lightly testing the agent bits on Ubuntu 16.whatever LTS. Seems to be going well-ish so far. |
actually in /bin. Try to make it less location dependent.
I think restart isn't working. Will test later and update. |
@@ -1,6 +1,7 @@ | |||
[Unit] | |||
Description=OSSEC Execd | |||
PartOf=ossec-agent.target | |||
Before=ossec-ossec-syscheckd.service ossec-agentd.service ossec-logcollector.service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo here ? should be ossec-syscheckd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting those mistakes. They should be corrected now.
src/init/ossec-server.sh
Outdated
${SYSTEMCTL} stop ossec-server.target | ||
fi | ||
exit 0 | ||
if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fi
@ddpbsd I'm not sure if you want this kind of behavior: if one of the member services (such as execd, syscheckd, etc) is killed/crashed by some reason, the server/agent target should be stopped.
|
And also there is one concern in this part of signal handle code: If the exit code is always 1, then service's Active state is always failed instead of 'inactive (dead)' if we use 'systemctl stop' to stop the target or any service. client-syscheckd.service - OSSEC syscheckd Loaded: loaded (/usr/lib/systemd/system/client-syscheckd.service; static; vendor preset: disabled) Active: failed (Result: exit-code) since Thu 2018-08-23 09:06:30 CEST; 39s ago Process: 5235 ExecStart=/usr/bin/env ${DIRECTORY}/bin/ossec-syscheckd -f (code=exited, status=1/FAILURE) Process: 5225 ExecStartPre=/usr/bin/env ${DIRECTORY}/bin/ossec-syscheckd -t (code=exited, status=0/SUCCESS) Main PID: 5235 (code=exited, status=1/FAILURE) |
For the reload option in ossec-control.sh, you can apply the same thing in systemd using below option https://www.freedesktop.org/software/systemd/man/systemd.unit.html#PropagatesReloadTo= However, it is applied for systemd version 235 and later only. |
@@ -1,6 +1,8 @@ | |||
[Unit] | |||
Description=OSSEC syscheckd | |||
PartOf=ossec-server.target | |||
After=ossec-maild.service ossec-execd.service ossec-analysisd.service ossec-remoted.service | |||
Before=ossec-agentless.service ossec-csyslog.service ossec-dbd.service ossec-monitord.service ossec-remoted.service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ossec-remoted has been in "After" section
@@ -1,6 +1,8 @@ | |||
[Unit] | |||
Description=OSSEC remoted | |||
PartOf=ossec-server.target | |||
After=ossec-maild.service ossec-execd.service ossec-analysisd.service ossec-logcollector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ossec-logcollector.service
Requires/includes PR #894
This should allow ossec-control to utilize systemd to manage the ossec processes. Also untested, and kind of unsure if I finished it.
This change is