Bug 699027 - systemctl --is-enabled does not report properly
systemctl --is-enabled does not report properly
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: systemd (Show other bugs)
15
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Michal Schmidt
Fedora Extras Quality Assurance
RejectedNTH
:
: 712818 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-04-22 13:25 EDT by Mark Sobell
Modified: 2011-07-26 10:27 EDT (History)
15 users (show)

See Also:
Fixed In Version: systemd-26-4.fc15
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-06-21 13:25:03 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Mark Sobell 2011-04-22 13:25:10 EDT
Description of problem:
The systemctl --is-enabled option should return a non-zero exit code if none of the specified unit files is enabled. It always returns a zero exit code.


Version-Release number of selected component (if applicable):
# systemctl --version
systemd 25
fedora
+PAM +LIBWRAP +AUDIT +SELINUX +SYSVINIT +LIBCRYPTSETUP

How reproducible:
Always

Steps to Reproduce:

# systemctl disable NetworkManager.service
rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service'
rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service'
# 
# systemctl is-enabled NetworkManager.service || echo NetworkManager is not enabled
# 
# ls /etc/systemd/system/*.wants/NetworkManager.service
ls: cannot access /etc/systemd/system/*.wants/NetworkManager.service: No such file or directory
  
Actual results:
As above

Expected results:

# systemctl is-enabled NetworkManager.service || echo NetworkManager is not enabled
NetworkManager is not enabled

Additional info:
The final ls shows that NetworkManager is not enabled.
Comment 1 Lennart Poettering 2011-04-26 22:03:00 EDT
hmm, weird... do you have any additional links to NM in /etc/systemd or /lib/systemd?

This works fine here...
Comment 2 Mark Sobell 2011-04-27 12:56:09 EDT
Yes, in /lib/systemd:

[root@plum ~]# systemctl disable NetworkManager.service
rm '/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service'
rm '/etc/systemd/system/multi-user.target.wants/NetworkManager.service'
rm '/etc/systemd/system/network.target.wants/NetworkManager.service'

[root@plum ~]# systemctl is-enabled NetworkManager.service || echo NetworkManager is not enabled

[root@plum ~]# find /etc/systemd /lib/systemd -name "*Manager*"
/lib/systemd/system/NetworkManager-wait-online.service
/lib/systemd/system/NetworkManager.service
Comment 3 Lennart Poettering 2011-04-27 22:59:58 EDT
Hmm, this is really weird, and I cannot reproduce this here...

If you downgrade to systemd 24, do things work there?
Comment 4 Mark Sobell 2011-04-27 23:37:43 EDT
Oh. It works fine with systemd-24-1.
Fails with systemd-25-1.
Comment 5 Jiri Popelka 2011-05-02 11:18:15 EDT
Exactly the same problem here.
I see the same problem with all services (dhcpd,atd,ntpd) I have tried it with.
I've just wanted to create a new bug and found this one.

It's a clear installation in VM.
systemd-24-1 works fine.
Fails with systemd-25-1 and systemd-26-1.
Comment 6 Michal Schmidt 2011-05-04 15:31:46 EDT
I can reproduce with "systemctl is-enabled ntpd.service". strace shows that systemctl opens the unit file, but it never reads anything from it:

open("/etc/systemd/system/ntpd.service", O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib/systemd/system/ntpd.service", O_RDONLY|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC) = 4
fcntl(4, F_GETFL)                       = 0xa8000 (flags O_RDONLY|O_LARGEFILE|O_NOFOLLOW|O_CLOEXEC)
fstat(4, {st_mode=S_IFREG|0644, st_size=209, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f806fcc1000
lseek(4, 0, SEEK_CUR)                   = 0
close(3)                                = 0
exit_group(0)                           = ?

This is the problem in install_info_apply():

        /* Consider unit files stored in /lib and /usr always enabled
         * if they have no [Install] data. */
        if (streq(verb, "is-enabled") &&
            strv_isempty(i->aliases) &&
            strv_isempty(i->wanted_by) &&
            !path_startswith(filename, "/etc"))
                return 1;

If systemctl never reads the file, it cannot know whether there is an [Install] section or not. config_parse() is called only after the above test.
Comment 7 Tim Flink 2011-05-06 15:17:28 EDT
Discussed in the 2011-05-06 blocker review meeting. Rejected as NTH as there is no clear rationale for accepting it.

If the fix does not get pushed to stable before the freeze, this can be re-proposed as NTH.
Comment 8 Bill Nottingham 2011-05-06 15:43:32 EDT
The rationale is that it's a command used by both admins and scripts to take action (Is this service enabled, if so, do something...) and it's not working properly. Admittedly, this may not be in the boot path or the release criteria.
Comment 9 Tim Flink 2011-05-06 15:55:51 EDT
(In reply to comment #7)
> Discussed in the 2011-05-06 blocker review meeting. Rejected as NTH as there is
> no clear rationale for accepting it.
> 
> If the fix does not get pushed to stable before the freeze, this can be
> re-proposed as NTH.

Apparently, I have too many tabs open - this comment went into the wrong bug.

Still discussed in the 2011-05-06 blocker meeting. Rejected as NTH because there was no clear scenario for something for which a post-release update wouldn't be an acceptable fix.

This can be re-proposed as NTH later if there is a more specific reason as to why it can't be fixed with a post-release update.
Comment 10 John Florian 2011-06-01 13:44:21 EDT
This problem is adversely affecting puppet where service resources are to be disabled.  For example, the following manifest snippet to enforce that ntpd runs on all but kvm guests (which have clocks inherently sync'd to their host):

    service { "ntpd":
        enable          => $virtual ? {
            "kvm"       => false,
            default     => true,
        },
        ensure          => $virtual ? {
            "kvm"       => stopped,
            default     => running,
        },
    }

With Fedora 15 and the above, puppet will perpetually ask systemd (via chkconfig) to disable the service, even if it's already disabled and this generates lots of email/log noise.  Puppet essentially calls 'chkconfig SERVICE_NAME' to learn if the service is enabled or not.

An update to resolve this would be most appreciated.
Comment 11 Michal Schmidt 2011-06-13 05:41:31 EDT
*** Bug 712818 has been marked as a duplicate of this bug. ***
Comment 12 Michal Hlavinka 2011-06-13 11:28:59 EDT
"Common F15 Bugs" page mentions this command for fixing service-not-enabled-after-update issue, so it's quite important that this command works fine. This bug should be high priority

https://fedoraproject.org/wiki/Common_F15_bugs#upgrade-disabled-services
Comment 14 Fedora Update System 2011-06-15 17:57:56 EDT
systemd-26-4.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/systemd-26-4.fc15
Comment 15 Fedora Update System 2011-06-15 19:53:40 EDT
Package systemd-26-4.fc15:
* should fix your issue,
* was pushed to the Fedora 15 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing systemd-26-4.fc15'
as soon as you are able to, then reboot.
Please go to the following url:
https://admin.fedoraproject.org/updates/systemd-26-4.fc15
then log in and leave karma (feedback).
Comment 16 John Florian 2011-06-20 11:49:02 EDT
This latest update does not seem to fix the problem for me.  As shown below, is-enabled now always returns 1:

$ rpm -q systemd
systemd-26-4.fc15.x86_64
$ systemctl status ntpd.service 
ntpd.service - Network Time Service
          Loaded: loaded (/lib/systemd/system/ntpd.service)
          Active: active (running) since Mon, 20 Jun 2011 11:40:55 -0400; 5min ago
        Main PID: 24358 (ntpd)
          CGroup: name=systemd:/system/ntpd.service
                  └ 24358 /usr/sbin/ntpd -n -u ntp:ntp -g -x
$ systemctl is-enabled ntpd.service ; echo $?
1
$ sudo systemctl stop ntpd.service 
$ systemctl status ntpd.service 
ntpd.service - Network Time Service
          Loaded: loaded (/lib/systemd/system/ntpd.service)
          Active: inactive (dead)
          CGroup: name=systemd:/system/ntpd.service
$ systemctl is-enabled ntpd.service ; echo $?
1
Comment 17 John Florian 2011-06-20 11:54:22 EDT
(In reply to comment #16)
> This latest update does not seem to fix the problem for me.  As shown below,
> is-enabled now always returns 1

Please disregard.  I just realized I was stop/starting the service for my test when I really meant to be enable/disable 'ing the service.  Works fine for me.
Comment 18 Fedora Update System 2011-06-21 13:24:46 EDT
systemd-26-4.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 19 cornel panceac 2011-07-26 10:27:53 EDT
still not fixed as reported here:

https://bugzilla.redhat.com/show_bug.cgi?id=725745

Note You need to log in before you can comment on or make changes to this bug.