From owner-svn-src-head@FreeBSD.ORG Sat Apr 23 04:26:31 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE079106564A; Sat, 23 Apr 2011 04:26:31 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AC0928FC13; Sat, 23 Apr 2011 04:26:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3N4QV2e071496; Sat, 23 Apr 2011 04:26:31 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3N4QVsK071489; Sat, 23 Apr 2011 04:26:31 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201104230426.p3N4QVsK071489@svn.freebsd.org> From: Doug Barton Date: Sat, 23 Apr 2011 04:26:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220962 - in head: etc etc/defaults etc/rc.d share/man/man5 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Apr 2011 04:26:31 -0000 Author: dougb Date: Sat Apr 23 04:26:31 2011 New Revision: 220962 URL: http://svn.freebsd.org/changeset/base/220962 Log: Introduce to rc.subr get_pidfile_from_conf(). It does just what it sounds like, determines the path to a pid file as it is specified in a conf file. Use the new feature for rc.d/named and rc.d/devd, the 2 services in the base that list their pid files in their conf files. Remove the now-obsolete named_pidfile, and warn users if they have it set. Modified: head/etc/defaults/rc.conf head/etc/rc.d/devd head/etc/rc.d/named head/etc/rc.subr head/share/man/man5/rc.conf.5 Modified: head/etc/defaults/rc.conf ============================================================================== --- head/etc/defaults/rc.conf Sat Apr 23 02:10:38 2011 (r220961) +++ head/etc/defaults/rc.conf Sat Apr 23 04:26:31 2011 (r220962) @@ -274,7 +274,6 @@ named_enable="NO" # Run named, the DNS named_program="/usr/sbin/named" # Path to named, if you want a different one. named_conf="/etc/namedb/named.conf" # Path to the configuration file #named_flags="" # Use this for flags OTHER than -u and -c -named_pidfile="/var/run/named/pid" # Must set this in named.conf as well named_uid="bind" # User to run named as named_chrootdir="/var/named" # Chroot directory (or "" not to auto-chroot it) named_chroot_autoupdate="YES" # Automatically install/update chrooted Modified: head/etc/rc.d/devd ============================================================================== --- head/etc/rc.d/devd Sat Apr 23 02:10:38 2011 (r220961) +++ head/etc/rc.d/devd Sat Apr 23 04:26:31 2011 (r220962) @@ -13,12 +13,23 @@ name="devd" rcvar=`set_rcvar` command="/sbin/${name}" -pidfile=/var/run/${name}.pid start_precmd=${name}_prestart +stop_precmd=find_pidfile + +find_pidfile() +{ + if get_pidfile_from_conf pid-file /etc/devd.conf; then + pidfile="$_pidfile_from_conf" + else + pidfile="/var/run/${name}.pid" + fi +} devd_prestart () { + find_pidfile + # If devd is disabled, turn it off in the kernel to avoid memory leaks. if ! checkyesno ${rcvar}; then $SYSCTL hw.bus.devctl_disable=1 Modified: head/etc/rc.d/named ============================================================================== --- head/etc/rc.d/named Sat Apr 23 02:10:38 2011 (r220961) +++ head/etc/rc.d/named Sat Apr 23 04:26:31 2011 (r220962) @@ -112,8 +112,19 @@ named_reload() ${command%/named}/rndc reload } +find_pidfile() +{ + if get_pidfile_from_conf pid-file $named_conf; then + pidfile="$_pidfile_from_conf" + else + pidfile="/var/run/named/pid" + fi +} + named_stop() { + find_pidfile + # This duplicates an undesirably large amount of code from the stop # routine in rc.subr in order to use rndc to shut down the process, # and to give it a second chance in case rndc fails. @@ -156,6 +167,12 @@ create_file () { named_prestart() { + find_pidfile + + if [ -n "$named_pidfile" ]; then + warn 'named_pidfile: now determined from the conf file' + fi + command_args="-u ${named_uid:=root}" if [ ! "$named_conf" = '/etc/namedb/named.conf' ]; then @@ -279,7 +296,6 @@ load_rc_config $name # required_dirs="$named_chrootdir" # if it is set, it must exist -pidfile="${named_pidfile:-/var/run/named/pid}" named_confdir="${named_chrootdir}${named_conf%/*}" run_rc_command "$1" Modified: head/etc/rc.subr ============================================================================== --- head/etc/rc.subr Sat Apr 23 02:10:38 2011 (r220961) +++ head/etc/rc.subr Sat Apr 23 04:26:31 2011 (r220962) @@ -384,6 +384,45 @@ wait_for_pids() } # +# get_pidfile_from_conf string file +# +# Takes a string to search for in the specified file. +# Ignores lines with traditional comment characters. +# +# Example: +# +# if get_pidfile_from_conf string file; then +# pidfile="$_pidfile_from_conf" +# else +# pidfile='appropriate default' +# fi +# +get_pidfile_from_conf() +{ + local string file line + + string="$1" ; file="$2" + + if [ -z "$string" -o -z "$file" ] || [ ! -s "$file" ]; then + err 3 'USAGE: get_pidfile_from_conf string file' + fi + + while read line; do + case "$line" in + *[#\;]*${string}*) continue ;; + *${string}*) break ;; + esac + done < $file + + if [ -n "$line" ]; then + line=${line#*/} + _pidfile_from_conf="/${line%%[\"\;]*}" + else + return 1 + fi +} + +# # check_startmsgs # If rc_quiet is set (usually as a result of using faststart at # boot time) check if rc_startmsgs is enabled. Modified: head/share/man/man5/rc.conf.5 ============================================================================== --- head/share/man/man5/rc.conf.5 Sat Apr 23 02:10:38 2011 (r220961) +++ head/share/man/man5/rc.conf.5 Sat Apr 23 04:26:31 2011 (r220962) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 7, 2011 +.Dd April 22, 2011 .Dt RC.CONF 5 .Os .Sh NAME @@ -1832,13 +1832,6 @@ is set to .Dq Li YES , these are the flags to pass to .Xr named 8 . -.It Va named_pidfile -.Pq Vt str -This is the default path to the -.Xr named 8 -daemon's PID file. -This must match the location in -.Xr named.conf 5 . .It Va named_uid .Pq Vt str The user that the