Bug 207811

Summary: service -e doesn't show all enabled services
Product: Base System Reporter: Miroslav Lachman <000.fbsd>
Component: miscAssignee: freebsd-bugs mailing list <bugs>
Status: New ---    
Severity: Affects Some People CC: ak, amd64, emaste, jilles, jonaspalm, junovitch, kevans, marius.halden, vsasjason, zi
Priority: --- Keywords: patch
Version: 10.3-RELEASE   
Hardware: amd64   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=213463
Description Flags
service.patch none

Description Miroslav Lachman 2016-03-08 15:38:29 UTC
I have seen this few times before on another machines. This time I came to file a PR for it.
I have isc-dhcp41-server-4.1.e_10,2 installed and enabled in rc.conf but service -e doesn't show it:

root@xyza ~/# service -e | grep local

The rc file is there

root@xyza ~/# /usr/local/etc/rc.d/isc-dhcpd
Usage: /usr/local/etc/rc.d/isc-dhcpd [fast|force|one|quiet](start|stop|restart|rcvar|enabled|uninstall|configtest|status|poll)

It can be started, I can request status etc.
root@xyza ~/# service isc-dhcpd start
Starting dhcpd.

root@xyza ~/# service isc-dhcpd status
dhcpd is running as pid 74802.

rc.conf contains these lines


All listed services on this machine

root@xyza ~/# service -e

root@xyza ~/# uname -srmi
FreeBSD 10.2-RELEASE-p10 amd64 GENERIC

I don't know why some services (isc-dhcpd in this case) are not shown.

How can I track it down?
Comment 1 Miroslav Lachman 2016-06-28 14:16:45 UTC
I did upgrade from FreeBSD 10.2 to 10.3 and upgraded ISC DHCP from 4.1 to 4.3 but problem remains: 

service -e doesn't show isc-dhcpd
service -l shows isc-dhcpd

Can somebody look on to this annoying bug?
Comment 2 Jason Unovitch freebsd_committer 2016-07-01 00:49:03 UTC
Add isc-dhcp maintainer to CC.

This is because the isc-dhcp script uses parameter expansion to strip the isc- off of $name.  See below from a 'sh -x /usr/sbin/service -e'.  Note that 'eval name' fails because $name is still defined as whatever service was before it.

+ echo $'foreman_proxy_enable=\'YES\''
+ eval $'foreman_proxy_enable=\'YES\''
+ foreman_proxy_enable=YES
+ checkyesno foreman_proxy_enable
+ echo /usr/local/etc/rc.d/isc-dhcpd
+ grep -q ^rcvar /usr/local/etc/rc.d/isc-dhcpd6
+ grep '^name=' /usr/local/etc/rc.d/isc-dhcpd6
+ eval 'name=${name##*/isc-}'
+ name=foreman_proxy
Comment 3 Marius Halden 2017-09-18 14:21:33 UTC
Created attachment 186509 [details]


We ran into the same issue with tomcat 8 and 8.5. The attached patch fixes the issue in service itself by querying the service with `run_rc_script … enabled` to figure out if it's enabled or not.

I think the way name is defined in tomcat 8 should not be considered an error as it's from what I understand done to make it easier to have multiple instances of tomcat running. Which is done by linking/copying the original rc script and defining the new variables in rc.conf using the name of the new file instead of the old.
Comment 4 Marius Halden 2017-09-19 13:40:27 UTC
Created attachment 186540 [details]

I realised the original patch had an issue with rcvar being empty. Here is an updated patch which works around this by defining a default dummy rcvar incase it's not set in the rc script. Although hacky, it does seem to work.
Comment 5 Marius Halden 2017-09-19 13:43:56 UTC
(In reply to Marius Halden from comment #4)

Argh, seems like I messed up when I tested this first. It har the same behaviour as earlier.
Comment 6 Kyle Evans freebsd_committer 2018-08-09 02:14:00 UTC
CC jilles@, one of our resident gurus.