You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Auditd service fails to restart via systemd | Need an Alternative to manage it via legacy method like 'service', for example: service auditd restart #52256
Featurenew functionality including changes to functionality and code refactors, etc.PlatformRelates to OS, containers, platform-based utilities like FS, system based appsState-Module
While trying to manage auditd via service.running, it fails to restart whenever the conditional "watch" file has changes, due to a parameter RefuseManualStop which is set as "yes" by default.
Setup
(Please provide relevant configs and/or SLS files (Be sure to remove sensitive info).)
OS: CentOS 7.3 and above
You could also use a cmd.run to call out to the specific system you want to use to restart auditd.
That's also my initial thought. I'm not sure if there's a way to override the RefuseManualStop with systemd, but that might be something else worth looking into.
Another thought would be why it's not responding correctly to the restart. If you do the restart manually does it work as expected? Might be something to kick back to CentOS as an upstream bug.
First of all, I would like to thank all of you for the quick responses :)
Now, addressing each one of your solutions/workarounds,
@garethgreenaway manually, it works when I use the command 'service auditd restart', and when I use systemctl/systemd, it fails to start, with the message, "Operation refused, unit auditd.service may be requested by dependency only.". I know this can be changed by changing the value of RefuseManualStop to "no" or commenting it out altogether from the service, but as per RedHat, it is a feature and not a bug, because systemd communicates with the process via dbus, and the auid being logged via systemd is -1, leading to misleading audit logs, and I might not be able to figure which process/person performed the operation of restarting auditd, which is wrong as far as auditing is concerned. This has been addressed in detail in this link - https://www.redhat.com/archives/linux-audit/2013-July/msg00048.html
The document link you provided for module provider overriding looks good, and on reading it I think I can use this to manually override init though I'll have to read it further to understand how I can go about doing this.
@waynew@garethgreenaway yea, I know I can alter my sample sls and use cmd.run and use 'service auditd restart' in the name section based on some file (onchanges). We could also change the RefuseManualStop parameter while running the state for auditd, and go about these changes via the saltmaster on environment basis, but as I stated earlier, this is a feature and not a bug in auditd. Also, on discussing this with my seniors, and also stating my inner instincts, we want to go about this via service.running, as we have been using purely saltstack based providers in provisioning, and never needed to alter the provided functionalities and use some workarounds. This is somewhat of a rarest of the rare cases, and that is why I raised a request here. Ansible has addressed this though, as per their documents and discussion forums, and I was hoping this can be done with saltstack as well.
I would read the module provider override and further understand its functioning, in the meanwhile placing a request with you guys to see whether a functionality can be provided within salt to manage auditd separately.
The module provider override link says that the override can be done in the minion config file, and this would be a system level config, I assume. I want that for audit the legacy/traditional service command is used to manage, while for other services, it should be based on the detected OS. Module provider override might not work for my case.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
RedHat have done this on purpose in order to be able to capture the details of where the service calls are coming from.
It doesn't look like they're ever going to change it so you can manage auditd with systemctl.
Ansible solved this by adding a per-invocation override of the service system: ansible/ansible#22171
Salt could consider a similar feature, or continue with the workarounds given above.
@Beginner77 I am going to close this for now, given the potential solution above. If you still believe this is a valid issue, feel free to re-open it and I will investigate further :)
@MKLeb that changes the provider for everything. The feature request is to be able to change the provider for a single state, which is something Ansible has.
This is still a valid feature request, and there is no particular reason (outside of available time) not to implement it.
@OrangeDog , as per the documentation linked in one of my previous comments...
This change only affects this one state though. If it is necessary to make this override for most or every service, it is better to just override the provider in the minion config file, as described [here](https://docs.saltproject.io/en/latest/ref/modules/index.html#module-provider-override).
If you have other knowledge of this not working as intended, please let me know and we can work on getting an issue filed for a bug in that behavior.
auditd:
service.running:
- provider: service
- watch:
- file: /etc/audit/audit.rules
Unfortunately, while an excellent idea by itself, due to current implementation details, it won't work OOTB. For the start, we need to specify the rh_service provider, as service by itself is a generic dispatcher, which would again pick up systemd_service.
But, even after specifying the right provider, it wouldn't load, as the initialisation code for rh_service has constraints that block it on systemd enabled systems:
# Disable when booted with systemd
if __utils__["systemd.booted"](__context__):
return (
False,
"The rh_service execution module failed to load: this system was booted"
" with systemd.",
)
Moreover, even if we remove this check, there is another one below that won't let you run this module on anything greater than RHEL6:
if osrelease_major >= 7:
return (
False,
"RedHat-based distros >= version 7 use systemd, will not "
"load rh_service.py as virtual 'service'",
)
If we remove that constraint (overall, this logic should be implemented in the service dispatching module, IMHO), the provider override would actually get enabled. But that wouldn't solve this particular problem, as rh_service itself uses chkconfig --list service to verify that the given service is present. But on a systemd managed OS (almost) all services are not configured in init style, so the check will always fail:
[ERROR ] The named service auditd is not available
----------
ID: auditd_svc
Function: service.running
Result: False
Comment: The named service auditd is not available
Started: 02:38:56.775284
Duration: 132.034 ms
Changes:
At this point, I just gave up on the idea of overriding provider for auditd and implemented service.running functionality in a dumb way, like:
It's not ideal, but it solves the initial problem of restarting auditd on RHEL systems.
And, BTW, you need to run service auditd restart, without specifying .service extension, otherwise systemctl will be called directly with the bogus result.
Featurenew functionality including changes to functionality and code refactors, etc.PlatformRelates to OS, containers, platform-based utilities like FS, system based appsState-Module
Activity
garethgreenaway commentedon Mar 20, 2019
@Beginner77 Thanks for the report. A couple options I can think of, you can override the init system that is being used, this will override it for everything though: https://docs.saltstack.com/en/latest/ref/modules/index.html#module-provider-override
You could also use a cmd.run to call out to the specific system you want to use to restart auditd.
@saltstack/team-core Any other thoughts?
waynew commentedon Mar 20, 2019
That's also my initial thought. I'm not sure if there's a way to override the RefuseManualStop with systemd, but that might be something else worth looking into.
garethgreenaway commentedon Mar 20, 2019
Another thought would be why it's not responding correctly to the restart. If you do the restart manually does it work as expected? Might be something to kick back to CentOS as an upstream bug.
Beginner77 commentedon Mar 21, 2019
First of all, I would like to thank all of you for the quick responses :)
Now, addressing each one of your solutions/workarounds,
@garethgreenaway manually, it works when I use the command 'service auditd restart', and when I use systemctl/systemd, it fails to start, with the message, "Operation refused, unit auditd.service may be requested by dependency only.". I know this can be changed by changing the value of RefuseManualStop to "no" or commenting it out altogether from the service, but as per RedHat, it is a feature and not a bug, because systemd communicates with the process via dbus, and the auid being logged via systemd is -1, leading to misleading audit logs, and I might not be able to figure which process/person performed the operation of restarting auditd, which is wrong as far as auditing is concerned. This has been addressed in detail in this link - https://www.redhat.com/archives/linux-audit/2013-July/msg00048.html
The document link you provided for module provider overriding looks good, and on reading it I think I can use this to manually override init though I'll have to read it further to understand how I can go about doing this.
@waynew @garethgreenaway yea, I know I can alter my sample sls and use cmd.run and use 'service auditd restart' in the name section based on some file (onchanges). We could also change the RefuseManualStop parameter while running the state for auditd, and go about these changes via the saltmaster on environment basis, but as I stated earlier, this is a feature and not a bug in auditd. Also, on discussing this with my seniors, and also stating my inner instincts, we want to go about this via service.running, as we have been using purely saltstack based providers in provisioning, and never needed to alter the provided functionalities and use some workarounds. This is somewhat of a rarest of the rare cases, and that is why I raised a request here. Ansible has addressed this though, as per their documents and discussion forums, and I was hoping this can be done with saltstack as well.
I would read the module provider override and further understand its functioning, in the meanwhile placing a request with you guys to see whether a functionality can be provided within salt to manage auditd separately.
Beginner77 commentedon Mar 21, 2019
The module provider override link says that the override can be done in the minion config file, and this would be a system level config, I assume. I want that for audit the legacy/traditional service command is used to manage, while for other services, it should be based on the detected OS. Module provider override might not work for my case.
stale commentedon Jan 8, 2020
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
OrangeDog commentedon Nov 8, 2022
RedHat have done this on purpose in order to be able to capture the details of where the service calls are coming from.
It doesn't look like they're ever going to change it so you can manage auditd with systemctl.
Ansible solved this by adding a per-invocation override of the service system: ansible/ansible#22171
Salt could consider a similar feature, or continue with the workarounds given above.
MKLeb commentedon Nov 28, 2022
Does using something like a providers override help? This is unlike the module provider override in that it is more granular, only existing as an override for the state it is used in. As far as I can tell, it solves the problem in a similar way to how ansible does. I was able to get it to invoke
linux_serviceusing the method described here: https://docs.saltproject.io/en/latest/ref/states/providers.html (provider should belinux_service).Note: From what I can see, salt doesn't actually run the
servicecommand. Instead, it just wraps around the sysvinit scripts.MKLeb commentedon Aug 22, 2023
@Beginner77 I am going to close this for now, given the potential solution above. If you still believe this is a valid issue, feel free to re-open it and I will investigate further :)
OrangeDog commentedon Aug 22, 2023
@MKLeb that changes the provider for everything. The feature request is to be able to change the provider for a single state, which is something Ansible has.
This is still a valid feature request, and there is no particular reason (outside of available time) not to implement it.
MKLeb commentedon Aug 22, 2023
@OrangeDog , as per the documentation linked in one of my previous comments...
If you have other knowledge of this not working as intended, please let me know and we can work on getting an issue filed for a bug in that behavior.
OrangeDog commentedon Aug 22, 2023
Oh! Yes this feature was already added in 0.9.8.
FYI @garethgreenaway who also missed it.
Some documentation alterations may be necessary so people can find that.
OrangeDog commentedon Aug 22, 2023
@Beginner77 try this:
b-a-t commentedon Oct 16, 2025
I'll leave this for reference if someone stumbles upon this issue.
@OrangeDog wrote:
Unfortunately, while an excellent idea by itself, due to current implementation details, it won't work OOTB. For the start, we need to specify the
rh_serviceprovider, asserviceby itself is a generic dispatcher, which would again pick upsystemd_service.But, even after specifying the right provider, it wouldn't load, as the initialisation code for
rh_servicehas constraints that block it onsystemdenabled systems:Moreover, even if we remove this check, there is another one below that won't let you run this module on anything greater than RHEL6:
If we remove that constraint (overall, this logic should be implemented in the
servicedispatching module, IMHO), theprovideroverride would actually get enabled. But that wouldn't solve this particular problem, asrh_serviceitself useschkconfig --list serviceto verify that the given service is present. But on asystemdmanaged OS (almost) all services are not configured in init style, so the check will always fail:At this point, I just gave up on the idea of overriding
providerforauditdand implementedservice.runningfunctionality in a dumb way, like:It's not ideal, but it solves the initial problem of restarting
auditdon RHEL systems.And, BTW, you need to run
service auditd restart, without specifying.serviceextension, otherwisesystemctlwill be called directly with the bogus result.