Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Feb 2013 02:57:10 -0800
From:      Jeremy Chadwick <jdc@koitsu.org>
To:        Alfred Bartsch <bartsch@dssgmbh.de>
Cc:        freebsd-stable@FreeBSD.org
Subject:   Re: some issues with /usr/sbin/service
Message-ID:  <20130215105710.GA6130@icarus.home.lan>
In-Reply-To: <511E0D43.6070900@dssgmbh.de>
References:  <511E0D43.6070900@dssgmbh.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Feb 15, 2013 at 11:26:11AM +0100, Alfred Bartsch wrote:
> we want to use this script for server administration purposes. After
> doing some testing, for now there are following issues left:
> 
> 1) every execution of "service -e"  casts a bunch of unnecessary
> warnings into /var/log/messages:
>     "... /usr/sbin/service: WARNING: $<name>_enable is not set
> properly - see rc.conf(5)."
>    This is caused by calling "checkyesno()", provided by /etc/subr. It
> could be solved by using a local function, named "checkyes" or similar.
> 
> The following patch prohibits these annoying messages:
> {snip}

Your patch, in effectively, "rewrites" checkyesno() to remove the warn()
call in cases where xxx_enable variables are set to values other than
yes/true/on/1 or no/false/off/0.

Here's a better idea:

Fix your /etc/rc.conf xxx_enable variables which contain values that
aren't permitted.  That's what the warn() is for -- to tell you to fix
them.  :-)

If there are ports (or worse, rc.d scripts) out there which recommend
xxx_enable variables with non-permitted values, then these ports need to
be fixed, not rc.subr(8) nor service(8).  Please disclose what those are
so they can be fixed.

However, "service -e" does not emit warnings on my 2 systems:

root@icarus:~ # service -e
/etc/rc.d/hostid
/etc/rc.d/zvol
/etc/rc.d/ddb
/etc/rc.d/hostid_save
/etc/rc.d/zfs
/etc/rc.d/cleanvar
/etc/rc.d/ip6addrctl
/etc/rc.d/devd
/etc/rc.d/netwait
/etc/rc.d/newsyslog
/etc/rc.d/syslogd
/etc/rc.d/named
/etc/rc.d/ntpdate
/etc/rc.d/dmesg
/etc/rc.d/virecover
/etc/rc.d/motd
/etc/rc.d/ntpd
/etc/rc.d/powerd
/usr/local/etc/rc.d/samba
/usr/local/etc/rc.d/postfix
/usr/local/etc/rc.d/mysql-server
/usr/local/etc/rc.d/apache22
/etc/rc.d/sshd
/etc/rc.d/cron
/etc/rc.d/mixer
/etc/rc.d/inetd
/etc/rc.d/gptboot

root@omake:~ # service -e
/etc/rc.d/hostid
/etc/rc.d/ddb
/etc/rc.d/hostid_save
/etc/rc.d/cleanvar
/etc/rc.d/ip6addrctl
/etc/rc.d/devd
/etc/rc.d/pflog
/etc/rc.d/pf
/etc/rc.d/netwait
/etc/rc.d/newsyslog
/etc/rc.d/syslogd
/etc/rc.d/named
/etc/rc.d/ntpdate
/etc/rc.d/dmesg
/etc/rc.d/virecover
/etc/rc.d/motd
/etc/rc.d/ntpd
/usr/local/etc/rc.d/sa-spamd
/usr/local/etc/rc.d/postfix
/usr/local/etc/rc.d/dovecot
/usr/local/etc/rc.d/apache22
/etc/rc.d/sshd
/etc/rc.d/cron
/etc/rc.d/mixer
/etc/rc.d/inetd
/etc/rc.d/gptboot

Regardless: the permitted values (see above) should be documented in
rc.conf(5) somewhere; I don't see any values other than "yes"
documented, but I'm probably overlooking it.

> 2) "service -e" does not show ALL enabled services, but only those who
> are explicitly enabled in /etc/defaults/rc.conf or /etc/rc.conf.
> Is that expected behavior?

It is the expected behaviour as I understand it per the man page.  You
should also see rc(8).

As I understand it, an "enabled service" is not a process that's
running, but something that has a yes/true/on/1 value for its
xxx_enabled variable in rc.conf/related file.  That's just how it works.
If you're used to, for example, Solaris "svcs" then yes things are
different here.

> To catch all enabled services where the <name>_enabled variable is set
> within the service procedure itself, perhaps a call like "service
> <name> status" could help.

There is already "service <name> status".  See rc(8) (search for
"status") or try it yourself on a running service.  Example:

root@icarus:~ # service postfix status
postfix is running as pid 1378.

Can you rephrase or give an example of what you want?

-- 
| Jeremy Chadwick                                   jdc@koitsu.org |
| UNIX Systems Administrator                http://jdc.koitsu.org/ |
| Mountain View, CA, US                                            |
| Making life hard for others since 1977.             PGP 4BD6C0CB |



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130215105710.GA6130>