From owner-freebsd-rc@FreeBSD.ORG Sun Jan 29 13:25:16 2012 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38DA2106566B; Sun, 29 Jan 2012 13:25:16 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 708E28FC13; Sun, 29 Jan 2012 13:25:15 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 28BB21DEDF2; Sun, 29 Jan 2012 14:25:14 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 0F01528468; Sun, 29 Jan 2012 14:25:14 +0100 (CET) Date: Sun, 29 Jan 2012 14:25:13 +0100 From: Jilles Tjoelker To: Garrett Cooper Message-ID: <20120129132513.GA97754@stack.nl> References: <4F14F4FF.902@erdgeist.org> <20120120230300.GE87357@lor.one-eyed-alien.net> <20120121233757.GB31224@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-rc@freebsd.org, simon , Brooks Davis Subject: Re: Bumping a pet bug X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jan 2012 13:25:16 -0000 On Sun, Jan 22, 2012 at 12:46:10PM -0800, Garrett Cooper wrote: > On Sun, Jan 22, 2012 at 5:46 AM, Dirk Engling wrote: > > Here is the output I get from not running the jail script as root: > > Starting jails:mount_nullfs: Operation not permitted > > devfs rule: ioctl DEVFSIO_RGETNEXT: Operation not permitted > > mount: dev : Operation not permitted > > /etc/rc.d/jail: WARNING: devfs_domount(): Unable to mount devfs on > > /usr/jails/foo.com/dev > > /etc/rc.d/jail: WARNING: devfs_mount_jail: devfs was not mounted on > > /usr/jails/foo.com/dev > > ln: log: Permission denied > > mount: /usr/jails/foo.com/dev/fd: No such file or directory > > mount: proc : Operation not permitted > >  cannot start jail "foo_com": > Probably a simple case of lack of set -e in the script with > appropriate error catching logic. The jailme and portsjail [*] scripts > had similar issues. You cannot use 'set -e' in rc.d scripts as it must be off both while sourcing /etc/rc.subr and while calling any function defined by it. Violating this may lead to unexpected exits of scripts. I think 'set -e' is not a "handle all my errors for me" panacea. If the script is any more complicated than just a sequence of commands, 'set -e' will very likely not do what you want. For example, if a compound command or function call is "tested", -e is ignored during all of it. The exact meaning of 'set -e' has changed several times, yet these problems have not been solved. I don't think it can be "fixed", so the least bad thing is to follow POSIX so the wrongness is at least consistent. (Unfortunately, there are still people trying to "fix" -e in POSIX in 2012.) Instead of -e, use explicit error checks such as with || or &&. -- Jilles Tjoelker