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

Fix systemd service enabled check #356

Merged
merged 1 commit into from
Jan 13, 2016
Merged

Fix systemd service enabled check #356

merged 1 commit into from
Jan 13, 2016

Conversation

jmccann
Copy link
Contributor

@jmccann jmccann commented Jan 11, 2016

I believe the wrong param from systemctl show is being checked to determine if a service is enabled/disabled in systemd.

Currently I have tests passing as enabled when I have a service disabled in systemd:

describe service('corosync') do
  it { should be_running }
  it { should be_enabled }
end

Is passing when I see the following from systemd:

[root@default-centos-71 ~]# systemctl status corosync
corosync.service - Corosync Cluster Engine
   Loaded: loaded (/usr/lib/systemd/system/corosync.service; disabled)
   Active: active (running) since Mon 2016-01-11 21:02:11 UTC; 32min ago
 Main PID: 13283 (corosync)
   CGroup: /system.slice/corosync.service
           └─13283 corosync

Notice how in Loaded at the end it shows 'disabled'.

Also, please see the ActiveState vs UnitFileState when enabling and disabling the service with systemd:

[root@default-centos-71 ~]# systemctl show --all corosync | grep -e UnitFileState -e ActiveState
ActiveState=active
UnitFileState=disabled
[root@default-centos-71 ~]# systemctl enable corosync
ln -s '/usr/lib/systemd/system/corosync.service' '/etc/systemd/system/multi-user.target.wants/corosync.service'
[root@default-centos-71 ~]# systemctl show --all corosync | grep -e UnitFileState -e ActiveState
ActiveState=active
UnitFileState=enabled
[root@default-centos-71 ~]# systemctl disable corosync
rm '/etc/systemd/system/multi-user.target.wants/corosync.service'
[root@default-centos-71 ~]# systemctl show --all corosync | grep -e UnitFileState -e ActiveState
ActiveState=active
UnitFileState=disabled

This PR addresses the issue by updating the check to use param UnitFileState to check if the service is enabled or disabled instead of ActiveState.

@chris-rock
Copy link
Contributor

Thanks for fixing this @jmccann

chris-rock added a commit that referenced this pull request Jan 13, 2016
@chris-rock chris-rock merged commit 3ef2156 into inspec:master Jan 13, 2016
@chris-rock chris-rock added this to the 0.9.9 milestone Jan 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants