From owner-freebsd-rc@FreeBSD.ORG Mon Oct 9 09:10:22 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F35B616A412 for ; Mon, 9 Oct 2006 09:10:21 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3D4D043D46 for ; Mon, 9 Oct 2006 09:10:21 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k999AKLI059256 for ; Mon, 9 Oct 2006 09:10:20 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k999AK28059255; Mon, 9 Oct 2006 09:10:20 GMT (envelope-from gnats) Date: Mon, 9 Oct 2006 09:10:20 GMT Message-Id: <200610090910.k999AK28059255@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Andrey Simonenko Cc: Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Andrey Simonenko 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: Mon, 09 Oct 2006 09:10:22 -0000 The following reply was made to PR bin/104044; it has been noted by GNATS. From: Andrey Simonenko To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly Date: Mon, 9 Oct 2006 12:07:16 +0300 Updated version of cleartmp: 1. Change "rm -rf ..." to "rm -rf -- ..." 2. Remove cleartmp_X() and createtmp_X() functions. --- cleartmp.orig Mon Apr 10 16:10:30 2006 +++ cleartmp Mon Oct 9 11:53:07 2006 @@ -14,43 +14,42 @@ start_cmd="${name}_start" -cleartmp_prestart() -{ - checkyesno clear_tmp_X || return - - local x11_socket_dirs="/tmp/.X11-unix /tmp/.ICE-unix /tmp/.font-unix \ - /tmp/.XIM-unix" - - # Remove X lock files, since they will prevent you from restarting X. - rm -f /tmp/.X[0-9]-lock - - # Create socket directories with correct permissions to avoid - # security problem. - # - rm -fr ${x11_socket_dirs} - mkdir -m 1777 ${x11_socket_dirs} -} +x11_socket_dirs="/tmp/.X11-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/.XIM-unix" cleartmp_start() { echo "Clearing /tmp." - # - # Prune quickly with one rm, then use find to clean up - # /tmp/[lq]* (this is not needed with mfs /tmp, but - # doesn't hurt anything). - # - (cd /tmp && rm -rf [a-km-pr-zA-Z]* && - find -x . ! -name . ! -name lost+found ! -name quota.user \ - ! -name quota.group ! -name .X11-unix ! -name .ICE-unix \ - ! -name .font-unix ! -name .XIM-unix \ + + # Try to remove files with rm, then use find to clean up the rest + # of files, including those, which do not fit in command line + # (this is not needed with mfs /tmp, but doesn't hurt anything). + (cd /tmp && rm -rf -- .[!.] .??* [!lq]* && + find -x . ! -name . \ + ! \( -name lost+found -type d -user root \) \ + ! \( \( -name quota.user -or -name quota.group \) \ + -type f -user root \) \ -exec rm -rf -- {} \; -type d -prune) + + if checkyesno clear_tmp_X; then + # Create X related directories. + mkdir -m 1777 ${x11_socket_dirs} + fi } load_rc_config $name # The clear_tmp_X variable should be tested even if clear_tmp_enable is NO case "$1" in -*start) cleartmp_prestart ;; +*start) + if ! checkyesno ${rcvar} && checkyesno clear_tmp_X; then + # Remove X lock files, since they will prevent you from + # restarting X. Remove other X related directories and + # create them again. + echo "Clearing /tmp (X related)." + rm -fr /tmp/.X[0-9]-lock ${x11_socket_dirs} + mkdir -m 1777 ${x11_socket_dirs} + fi + ;; esac run_rc_command "$1" From owner-freebsd-rc@FreeBSD.ORG Mon Oct 9 10:52:40 2006 Return-Path: X-Original-To: freebsd-rc@FreeBSD.org Delivered-To: freebsd-rc@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3058D16A417 for ; Mon, 9 Oct 2006 10:52:40 +0000 (UTC) (envelope-from flz@xbsd.org) Received: from smtp4-g19.free.fr (smtp4-g19.free.fr [212.27.42.30]) by mx1.FreeBSD.org (Postfix) with ESMTP id DA8AB43D5C for ; Mon, 9 Oct 2006 10:52:38 +0000 (GMT) (envelope-from flz@xbsd.org) Received: from smtp.xbsd.org (unknown [82.233.2.192]) by smtp4-g19.free.fr (Postfix) with ESMTP id D835D54954; Mon, 9 Oct 2006 12:52:37 +0200 (CEST) Received: from localhost (localhost.xbsd.org [127.0.0.1]) by smtp.xbsd.org (Postfix) with ESMTP id 378D91194F; Mon, 9 Oct 2006 12:52:37 +0200 (CEST) Received: from smtp.xbsd.org ([127.0.0.1]) by localhost (srv1.xbsd.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 48327-02; Mon, 9 Oct 2006 12:52:32 +0200 (CEST) Received: from mayday.esat.net (mayday.esat.net [193.95.134.156]) by smtp.xbsd.org (Postfix) with ESMTP id C5A311150D; Mon, 9 Oct 2006 12:52:31 +0200 (CEST) From: Florent Thoumie To: Andrey Simonenko In-Reply-To: <200610090910.k999AK28059255@freefall.freebsd.org> References: <200610090910.k999AK28059255@freefall.freebsd.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-38L7O+5cEGFWruKKRMNZ" Date: Mon, 09 Oct 2006 11:52:30 +0100 Message-Id: <1160391150.76522.33.camel@mayday.esat.net> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 FreeBSD GNOME Team Port X-Virus-Scanned: amavisd-new at xbsd.org Cc: freebsd-rc@FreeBSD.org Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly 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: Mon, 09 Oct 2006 10:52:40 -0000 --=-38L7O+5cEGFWruKKRMNZ Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Mon, 2006-10-09 at 09:10 +0000, Andrey Simonenko wrote: > The following reply was made to PR bin/104044; it has been noted by GNATS= . >=20 > From: Andrey Simonenko > To: bug-followup@FreeBSD.org > Cc: =20 > Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly > Date: Mon, 9 Oct 2006 12:07:16 +0300 >=20 > Updated version of cleartmp: > =20 > 1. Change "rm -rf ..." to "rm -rf -- ..." > =20 > 2. Remove cleartmp_X() and createtmp_X() functions. Haven't tested it yet but the patch looks good to me. Anybody else to have a look? --=20 Florent Thoumie flz@FreeBSD.org FreeBSD Committer --=-38L7O+5cEGFWruKKRMNZ Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.4 (FreeBSD) iD8DBQBFKinuMxEkbVFH3PQRAuMGAJ0RhbBYVdINJF5qH8BFQnz6D3EjHwCfXt0R 6p8a9DNpTqhcKO9WZ+2df5Q= =hB3D -----END PGP SIGNATURE----- --=-38L7O+5cEGFWruKKRMNZ-- From owner-freebsd-rc@FreeBSD.ORG Mon Oct 9 11:09:54 2006 Return-Path: X-Original-To: freebsd-rc@FreeBSD.org Delivered-To: freebsd-rc@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9096016A51A for ; Mon, 9 Oct 2006 11:09:54 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7502843D5A for ; Mon, 9 Oct 2006 11:08:54 +0000 (GMT) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (linimon@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k99B8ggx071654 for ; Mon, 9 Oct 2006 11:08:42 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from linimon@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k99B8fwk071650 for freebsd-rc@FreeBSD.org; Mon, 9 Oct 2006 11:08:41 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 9 Oct 2006 11:08:41 GMT Message-Id: <200610091108.k99B8fwk071650@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: linimon set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-rc@FreeBSD.org Cc: Subject: Current problem reports assigned to you 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: Mon, 09 Oct 2006 11:09:54 -0000 Current FreeBSD problem reports Critical problems Serious problems S Tracker Resp. Description -------------------------------------------------------------------------------- o conf/48881 rc [PATCH] The influence of /etc/start_ifname on /etc/rc. o conf/98734 rc [patch] /etc/rc.subr restart_postcmd is failing start_ o conf/98758 rc [patch] Templatize 'jail_fstab' in /etc/rc.d/jail o conf/98846 rc [patch] Templatize 'jail_rootdir' in /etc/rc.d/jail o bin/104044 rc [patch] rc.d/cleartmp works incorrectly 5 problems total. Non-critical problems S Tracker Resp. Description -------------------------------------------------------------------------------- o conf/45226 rc Fix for rc.network, ppp-user annoyance o conf/48870 rc [PATCH] rc.network: allow to cancel interface status d o conf/55916 rc [PATCH] ppp-user options o conf/58939 rc [patch] dumb little hack for /etc/rc.firewall{,6} o conf/73677 rc [patch] add support for powernow states to power_profi o conf/74817 rc [patch] network.subr: fixed automatic configuration of o conf/77663 rc Suggestion: add /etc/rc.d/addnetswap after addcritremo o conf/78906 rc [patch] Allow mixer_enable="NO" in rc.conf o conf/79196 rc [PATCH] configurable dummynet loading from /etc/rc.co o kern/81006 rc ipnat not working with tunnel interfaces on startup o conf/85363 rc syntax error in /etc/rc.d/devfs o conf/85819 rc [patch] script allowing multiuser mode in spite of fsc o conf/88913 rc [patch] wrapper support for rc.subr o conf/89061 rc [patch] IPv6 6to4 auto-configuration enhancement o conf/89870 rc [patch] feature request to make netif verbose rc.conf o conf/92523 rc [patch] allow rc scripts to kill process after a timeo o conf/93815 rc [patch] Adds in the ability to save ipfw rules to rc.d o conf/95162 rc [patch] Missing feature in rc.subr o conf/96343 rc [patch] rc.d order change to start inet6 before pf o conf/96766 rc run_rc_command doesn't work for Python scripts o conf/97311 rc [patch] /etc/rc.d/ipfilter reload can load bad files o conf/99444 rc [patch] Enhancement: rc.subr could easily support star o conf/99595 rc [PATCH] /etc/rc.d/dhclient doesn't interact well with o conf/99721 rc [patch] /etc/rc.initdiskless problem copy dotfile in s o bin/100287 rc /etc/rc.subr cannot deal properly with interpreted dae o conf/102700 rc [PATCH] Add encrypted /tmp support to GELI/GBDE rc.d s o conf/102722 rc kerberos5 server startupscript should use --detach o conf/102913 rc /etc/rc.d/named killall in jailed OS o conf/103486 rc [rc.d] [patch] rc.d/jail: mount fstab after devfs o conf/103489 rc [rc.d] [patch] named_chroot_autoupdate doesn't work in o conf/103976 rc rc.d/named restart failure 31 problems total. From owner-freebsd-rc@FreeBSD.ORG Mon Oct 9 12:09:40 2006 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DDF9416A40F; Mon, 9 Oct 2006 12:09:40 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id A031B43D8B; Mon, 9 Oct 2006 12:09:32 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.3) with ESMTP id k99C7w9x003507; Mon, 9 Oct 2006 16:07:58 +0400 (MSD) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.3/Submit) id k99C7viE003506; Mon, 9 Oct 2006 16:07:57 +0400 (MSD) (envelope-from yar) Date: Mon, 9 Oct 2006 16:07:56 +0400 From: Yar Tikhiy To: Florent Thoumie Message-ID: <20061009120756.GA2805@comp.chem.msu.su> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1160391150.76522.33.camel@mayday.esat.net> User-Agent: Mutt/1.5.9i Cc: Andrey Simonenko , freebsd-rc@freebsd.org, bug-followup@freebsd.org Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly 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: Mon, 09 Oct 2006 12:09:41 -0000 On Mon, Oct 09, 2006 at 11:52:30AM +0100, Florent Thoumie wrote: > On Mon, 2006-10-09 at 09:10 +0000, Andrey Simonenko wrote: > > The following reply was made to PR bin/104044; it has been noted by GNATS. > > > > From: Andrey Simonenko > > To: bug-followup@FreeBSD.org > > Cc: > > Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly > > Date: Mon, 9 Oct 2006 12:07:16 +0300 > > > > Updated version of cleartmp: > > > > 1. Change "rm -rf ..." to "rm -rf -- ..." > > > > 2. Remove cleartmp_X() and createtmp_X() functions. > > Haven't tested it yet but the patch looks good to me. Anybody else to > have a look? The patch looks _almost_ good to me. For the sake of style, I'd rather move the clear_tmp_X block to inside the start method. That would require renaming rcvar to, say, rcvar1 and checking it from the script. E.g.: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ... rcvar1=`set_rcvar clear_tmp` ... cleartmp_start() { if checkyesno ${rcvar1}; then echo "Clearing /tmp." ... elif checkyesno clear_tmp_X; then echo "Clearing /tmp (X related)." rm -rf /tmp/.X[0-9]-lock ${x11_socket_dirs} fi if checkyesno clear_tmp_X; then # Recreate X related directories. mkdir -m 1777 ${x11_socket_dirs} fi } run_rc_command "$1" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% My point is that well-behaved rc.d scripts don't do their job outside of their methods. -- Yar From owner-freebsd-rc@FreeBSD.ORG Mon Oct 9 12:10:57 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B20516A40F for ; Mon, 9 Oct 2006 12:10:57 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id DEDB443D97 for ; Mon, 9 Oct 2006 12:10:29 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k99CAT83080364 for ; Mon, 9 Oct 2006 12:10:29 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k99CATDm080360; Mon, 9 Oct 2006 12:10:29 GMT (envelope-from gnats) Date: Mon, 9 Oct 2006 12:10:29 GMT Message-Id: <200610091210.k99CATDm080360@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Yar Tikhiy Cc: Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Yar Tikhiy 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: Mon, 09 Oct 2006 12:10:57 -0000 The following reply was made to PR bin/104044; it has been noted by GNATS. From: Yar Tikhiy To: Florent Thoumie Cc: Andrey Simonenko , freebsd-rc@freebsd.org, bug-followup@freebsd.org Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly Date: Mon, 9 Oct 2006 16:07:56 +0400 On Mon, Oct 09, 2006 at 11:52:30AM +0100, Florent Thoumie wrote: > On Mon, 2006-10-09 at 09:10 +0000, Andrey Simonenko wrote: > > The following reply was made to PR bin/104044; it has been noted by GNATS. > > > > From: Andrey Simonenko > > To: bug-followup@FreeBSD.org > > Cc: > > Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly > > Date: Mon, 9 Oct 2006 12:07:16 +0300 > > > > Updated version of cleartmp: > > > > 1. Change "rm -rf ..." to "rm -rf -- ..." > > > > 2. Remove cleartmp_X() and createtmp_X() functions. > > Haven't tested it yet but the patch looks good to me. Anybody else to > have a look? The patch looks _almost_ good to me. For the sake of style, I'd rather move the clear_tmp_X block to inside the start method. That would require renaming rcvar to, say, rcvar1 and checking it from the script. E.g.: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ... rcvar1=`set_rcvar clear_tmp` ... cleartmp_start() { if checkyesno ${rcvar1}; then echo "Clearing /tmp." ... elif checkyesno clear_tmp_X; then echo "Clearing /tmp (X related)." rm -rf /tmp/.X[0-9]-lock ${x11_socket_dirs} fi if checkyesno clear_tmp_X; then # Recreate X related directories. mkdir -m 1777 ${x11_socket_dirs} fi } run_rc_command "$1" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% My point is that well-behaved rc.d scripts don't do their job outside of their methods. -- Yar From owner-freebsd-rc@FreeBSD.ORG Mon Oct 9 12:24:06 2006 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A9CA616A4E0 for ; Mon, 9 Oct 2006 12:24:06 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id D333243D58 for ; Mon, 9 Oct 2006 12:23:51 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.3) with ESMTP id k99CNh4S004023 for ; Mon, 9 Oct 2006 16:23:43 +0400 (MSD) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.3/Submit) id k99CNgm2004022 for freebsd-rc@freebsd.org; Mon, 9 Oct 2006 16:23:42 +0400 (MSD) (envelope-from yar) Date: Mon, 9 Oct 2006 16:23:42 +0400 From: Yar Tikhiy To: freebsd-rc@freebsd.org Message-ID: <20061009122342.GB2805@comp.chem.msu.su> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i Subject: Revised article on rc.d 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: Mon, 09 Oct 2006 12:24:06 -0000 Hi all, After a long delay, I got down to my article on rc.d again. Many thanks to Gary W. Swearingen for his valuable remarks. The new version is available at http://people.freebsd.org/~yar/rcng/ . I think this version can be added to our articles collection after a few corrections that may be suggested by the readers. ;-) -- Yar From owner-freebsd-rc@FreeBSD.ORG Mon Oct 9 18:55:53 2006 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 510F416A4E5 for ; Mon, 9 Oct 2006 18:55:53 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from mail2.fluidhosting.com (mx24.fluidhosting.com [204.14.89.7]) by mx1.FreeBSD.org (Postfix) with SMTP id 02E5143E8C for ; Mon, 9 Oct 2006 18:54:43 +0000 (GMT) (envelope-from dougb@FreeBSD.org) Received: (qmail 32307 invoked by uid 399); 9 Oct 2006 18:54:30 -0000 Received: from localhost (HELO ?156.154.4.170?) (dougb@dougbarton.us@127.0.0.1) by localhost with SMTP; 9 Oct 2006 18:54:30 -0000 Message-ID: <452A9AE0.8090606@FreeBSD.org> Date: Mon, 09 Oct 2006 11:54:24 -0700 From: Doug Barton Organization: http://www.FreeBSD.org/ User-Agent: Thunderbird 1.5.0.7 (Windows/20060909) MIME-Version: 1.0 To: Yar Tikhiy References: <20061009120756.GA2805@comp.chem.msu.su> In-Reply-To: <20061009120756.GA2805@comp.chem.msu.su> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Andrey Simonenko , freebsd-rc@freebsd.org Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly 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: Mon, 09 Oct 2006 18:55:53 -0000 Guys, I don't object if you (pl.) decide to tune this up, but please be aware that it took Brooks and I quite a bit of time to work out The Right Thing To Do for all the various combinations. Please don't forget to include both memory backed tmp and permanent disk based tmp in your testing. I'll try to chime in if I can find the time, but right now I'm working in other areas. One final request, please do not MFC this change before 6.2-RELEASE unless it has had _at least_ a couple of weeks to mature first. I feel strongly at this point that rushing this in right before the release would have more potential to do harm than good. Thanks, Doug Yar Tikhiy wrote: > On Mon, Oct 09, 2006 at 11:52:30AM +0100, Florent Thoumie wrote: >> On Mon, 2006-10-09 at 09:10 +0000, Andrey Simonenko wrote: >>> The following reply was made to PR bin/104044; it has been noted by GNATS. >>> >>> From: Andrey Simonenko >>> To: bug-followup@FreeBSD.org >>> Cc: >>> Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly >>> Date: Mon, 9 Oct 2006 12:07:16 +0300 >>> >>> Updated version of cleartmp: >>> >>> 1. Change "rm -rf ..." to "rm -rf -- ..." >>> >>> 2. Remove cleartmp_X() and createtmp_X() functions. >> Haven't tested it yet but the patch looks good to me. Anybody else to >> have a look? > > The patch looks _almost_ good to me. For the sake of style, I'd > rather move the clear_tmp_X block to inside the start method. That > would require renaming rcvar to, say, rcvar1 and checking it from > the script. E.g.: > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > ... > rcvar1=`set_rcvar clear_tmp` > ... > cleartmp_start() > { > if checkyesno ${rcvar1}; then > echo "Clearing /tmp." > ... > elif checkyesno clear_tmp_X; then > echo "Clearing /tmp (X related)." > rm -rf /tmp/.X[0-9]-lock ${x11_socket_dirs} > fi > if checkyesno clear_tmp_X; then > # Recreate X related directories. > mkdir -m 1777 ${x11_socket_dirs} > fi > } > > run_rc_command "$1" > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > My point is that well-behaved rc.d scripts don't do their job outside > of their methods. > -- This .signature sanitized for your protection From owner-freebsd-rc@FreeBSD.ORG Tue Oct 10 01:56:21 2006 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 276A916A416 for ; Tue, 10 Oct 2006 01:56:21 +0000 (UTC) (envelope-from dat1965@yahoo.com) Received: from web55109.mail.re4.yahoo.com (web55109.mail.re4.yahoo.com [206.190.58.158]) by mx1.FreeBSD.org (Postfix) with SMTP id E361F43D45 for ; Tue, 10 Oct 2006 01:56:19 +0000 (GMT) (envelope-from dat1965@yahoo.com) Received: (qmail 3494 invoked by uid 60001); 10 Oct 2006 01:56:19 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=cDlvjFGXi0J+yIa3XE3vXWmDvwmfxQzbiwdJ4K2nhcovB9uZmuy1mgao8Pbkt/1JgB8594hrXm2CI8kkg+sGpH/vpYzeep9e6wxKmUHg+JstK5wmZ4GsITLR4Kqu5YE1E1wl1soc72U/P0FZ8+00ftuIIdeFN1RlxX1xjvLFW4U= ; Message-ID: <20061010015619.3492.qmail@web55109.mail.re4.yahoo.com> Received: from [67.131.247.220] by web55109.mail.re4.yahoo.com via HTTP; Mon, 09 Oct 2006 18:56:19 PDT Date: Mon, 9 Oct 2006 18:56:19 -0700 (PDT) From: David Thompson To: Yar Tikhiy , freebsd-rc@freebsd.org In-Reply-To: <20061009122342.GB2805@comp.chem.msu.su> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: Subject: Re: Revised article on rc.d 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: Tue, 10 Oct 2006 01:56:21 -0000 --- Yar Tikhiy wrote: > After a long delay, I got down to my article on rc.d again. Many > thanks to Gary W. Swearingen for his valuable remarks. The new > version is available at http://people.freebsd.org/~yar/rcng/ . I > think this version can be added to our articles collection after a > few corrections that may be suggested by the readers. ;-) Regarding this paragraph, Note: An rc.d script must be written in the sh(1) language. It cannot be a binary executable because rc.d can opt to feed such scripts into a single instance of sh(1) instead of running each of them separately. This is controlled by an rc.conf(5) variable named rc_fast_and_loose. An rc.d script cannot be written in awk(1) or an interpreted language from ports for the same reason; in addition, it must be runnable early in the system startup sequence, before /usr has been mounted. This caveat is not really true in the strict technical sense. Consider if someone adds this line to their /etc/rc.d script, # KEYWORD: nostart then /etc/rc will not execute this script since rcorder is invoked with '-s nostart'. Thus the reasoning due to the $rc_fast_and_loose variable is not strictly accurate. That is, a script could technically be written in any interpreted language that happens to use '#' as its comment character; as long as the above comment line was added to the script. The problem is, of course, such scripts have to provide their own scaffolding, since rc.subr is written in sh(1); and the script cannot be run directly by /etc/rc due to the use of the sh(1) dot '.' operator (thus it needs 'KEYWORD: nostart' so that /etc/rc will skip it). Although not exactly clear in the above paragraph, the reason files in /etc/rc.d cannot be binary is because rc.d uses the sh(1) dot '.' operator *for all* invocations, like this, if [ -n "$rc_fast_and_loose" ]; then set $_arg; . $_file else ( trap "echo Script $_file interrupted; kill -QUIT $$" 3 trap "echo Script $_file interrupted; exit 1" 2 set $_arg; . $_file ) fi But for '.', files in /etc/rc.d *could* be binary, but even then rcorder expects to process text files, not binary files. rcorder uses fparseln() to read each file, but this doesn't really affect reading a binary file. Thus rcorder processes binary files benignly, try 'rcorder /bin/*' and you'll see consistent output. Also in that paragraph, when I read this, ... a binary executable because rc.d can opt to feed ... ^^^^ IMHO, it should probably say, ... a binary executable because /etc/rc can opt to feed ... ^^^^^^^ though I understand you're referring to the rc.d system, some clarity is gained in that sentence by using /etc/rc. -- David __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From owner-freebsd-rc@FreeBSD.ORG Tue Oct 10 08:30:31 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 83FE516A403 for ; Tue, 10 Oct 2006 08:30:31 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id CC3D143D49 for ; Tue, 10 Oct 2006 08:30:30 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k9A8UUkb098496 for ; Tue, 10 Oct 2006 08:30:30 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k9A8UU7r098495; Tue, 10 Oct 2006 08:30:30 GMT (envelope-from gnats) Date: Tue, 10 Oct 2006 08:30:30 GMT Message-Id: <200610100830.k9A8UU7r098495@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Andrey Simonenko Cc: Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Andrey Simonenko 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: Tue, 10 Oct 2006 08:30:31 -0000 The following reply was made to PR bin/104044; it has been noted by GNATS. From: Andrey Simonenko To: Yar Tikhiy Cc: Florent Thoumie , bug-followup@freebsd.org Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly Date: Tue, 10 Oct 2006 11:26:38 +0300 Another updated version: 1. Everything, what belongs to _start method, was moved to cleartmp_start(). 2. Ignore error code from rm and always run find, that is use "rm ... ; find ..." instead of "rm ... && find ...": one can create many files with long names and rm will not be called because of "Argument list too long" error, so find should do all of the work. --- /usr/src/etc/rc.d/cleartmp Mon Apr 10 16:10:30 2006 +++ cleartmp Tue Oct 10 10:03:07 2006 @@ -10,47 +10,37 @@ . /etc/rc.subr name="cleartmp" -rcvar=`set_rcvar clear_tmp` - +rcvar1=`set_rcvar clear_tmp` start_cmd="${name}_start" -cleartmp_prestart() +cleartmp_start() { - checkyesno clear_tmp_X || return - local x11_socket_dirs="/tmp/.X11-unix /tmp/.ICE-unix /tmp/.font-unix \ /tmp/.XIM-unix" - # Remove X lock files, since they will prevent you from restarting X. - rm -f /tmp/.X[0-9]-lock - - # Create socket directories with correct permissions to avoid - # security problem. - # - rm -fr ${x11_socket_dirs} - mkdir -m 1777 ${x11_socket_dirs} -} - -cleartmp_start() -{ - echo "Clearing /tmp." - # - # Prune quickly with one rm, then use find to clean up - # /tmp/[lq]* (this is not needed with mfs /tmp, but - # doesn't hurt anything). - # - (cd /tmp && rm -rf [a-km-pr-zA-Z]* && - find -x . ! -name . ! -name lost+found ! -name quota.user \ - ! -name quota.group ! -name .X11-unix ! -name .ICE-unix \ - ! -name .font-unix ! -name .XIM-unix \ - -exec rm -rf -- {} \; -type d -prune) + if checkyesno ${rcvar1}; then + # Remove files with rm, then use find to clean up the rest + # of files (there can be too many files for command line). + # This is not needed with mfs /tmp, but doesn't hurt anything. + echo "Clearing /tmp." + (cd /tmp && { rm -rf -- .[!.] .??* [!lq]* ; + find -x . ! -name . \ + ! \( -name lost+found -type d -user root \) \ + ! \( \( -name quota.user -or -name quota.group \) \ + -type f -user root \) \ + -exec rm -rf -- {} \; -type d -prune; } + ) + elif checkyesno clear_tmp_X; then + # Remove X lock files, since they will prevent you from + # restarting X. Remove other X related directories. + echo "Clearing /tmp (X related)." + rm -rf /tmp/.X[0-9]-lock ${x11_socket_dirs} + fi + if checkyesno clear_tmp_X; then + # Create X related directories. + mkdir -m 1777 ${x11_socket_dirs} + fi } load_rc_config $name - -# The clear_tmp_X variable should be tested even if clear_tmp_enable is NO -case "$1" in -*start) cleartmp_prestart ;; -esac - run_rc_command "$1" From owner-freebsd-rc@FreeBSD.ORG Tue Oct 10 10:40:27 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9531C16A407 for ; Tue, 10 Oct 2006 10:40:27 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1F7B643D53 for ; Tue, 10 Oct 2006 10:40:27 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k9AAeQim012241 for ; Tue, 10 Oct 2006 10:40:26 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k9AAeQgM012240; Tue, 10 Oct 2006 10:40:26 GMT (envelope-from gnats) Date: Tue, 10 Oct 2006 10:40:26 GMT Message-Id: <200610101040.k9AAeQgM012240@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Yar Tikhiy Cc: Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Yar Tikhiy 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: Tue, 10 Oct 2006 10:40:27 -0000 The following reply was made to PR bin/104044; it has been noted by GNATS. From: Yar Tikhiy To: Andrey Simonenko Cc: Florent Thoumie , bug-followup@freebsd.org Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly Date: Tue, 10 Oct 2006 14:34:43 +0400 On Tue, Oct 10, 2006 at 11:26:38AM +0300, Andrey Simonenko wrote: > Another updated version: > > 1. Everything, what belongs to _start method, was moved to > cleartmp_start(). Thanks! > 2. Ignore error code from rm and always run find, that is > use "rm ... ; find ..." instead of "rm ... && find ...": > one can create many files with long names and rm will not > be called because of "Argument list too long" error, so > find should do all of the work. By the way, did you consider omitting the first rm at all and just using "find ... -print0 | xargs -0 rm -rf" ? The first rm can be an optimization as long as we use find with -exec. OTOH, xargs -0 would buy us the same performance and robustness without hacks. Both find and xargs should be available to cleartmp. Here's the code. Note "type -d" omitted. if checkyesno ${rcvar1}; then # This is not needed with mfs /tmp, but doesn't hurt anything. echo "Clearing /tmp." find -x /tmp/. ! -name . \ ! \( -name lost+found -type d -user root \) \ ! \( \( -name quota.user -or -name quota.group \) \ -type f -user root \) \ -prune -print0 | xargs -0 rm -rf elif ... Another thought of mine was that cleartmp wouldn't handle files with an immutable flag set. Fortunately, rm -f appears to take care of files with uchg while those with schg on them should be left alone. So flags aren't an issue. -- Yar From owner-freebsd-rc@FreeBSD.ORG Tue Oct 10 10:42:55 2006 Return-Path: X-Original-To: freebsd-rc@FreeBSD.org Delivered-To: freebsd-rc@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3671A16A40F; Tue, 10 Oct 2006 10:42:55 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 39D4E43D6D; Tue, 10 Oct 2006 10:42:50 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.3) with ESMTP id k9AAgEtk022826; Tue, 10 Oct 2006 14:42:14 +0400 (MSD) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.3/Submit) id k9AAgEQR022825; Tue, 10 Oct 2006 14:42:14 +0400 (MSD) (envelope-from yar) Date: Tue, 10 Oct 2006 14:42:14 +0400 From: Yar Tikhiy To: Doug Barton Message-ID: <20061010104214.GF12320@comp.chem.msu.su> References: <20061009120756.GA2805@comp.chem.msu.su> <452A9AE0.8090606@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <452A9AE0.8090606@FreeBSD.org> User-Agent: Mutt/1.5.9i Cc: Andrey Simonenko , freebsd-rc@FreeBSD.org Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly 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: Tue, 10 Oct 2006 10:42:55 -0000 On Mon, Oct 09, 2006 at 11:54:24AM -0700, Doug Barton wrote: > Guys, > > I don't object if you (pl.) decide to tune this up, but please be > aware that it took Brooks and I quite a bit of time to work out The > Right Thing To Do for all the various combinations. Please don't > forget to include both memory backed tmp and permanent disk based tmp > in your testing. Luckily, the CVS history of cleartmp has kept the log of your cuts and tries for us :-) > I'll try to chime in if I can find the time, but right now I'm working > in other areas. One final request, please do not MFC this change > before 6.2-RELEASE unless it has had _at least_ a couple of weeks to > mature first. I feel strongly at this point that rushing this in right > before the release would have more potential to do harm than good. Fully agreed. I'd rather defer the MFC to after 6.2-RELEASE is out. -- Yar From owner-freebsd-rc@FreeBSD.ORG Tue Oct 10 11:41:09 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4487016A412 for ; Tue, 10 Oct 2006 11:41:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id CF61E43DBA for ; Tue, 10 Oct 2006 11:40:28 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k9ABeRLU018687 for ; Tue, 10 Oct 2006 11:40:27 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k9ABeRwZ018684; Tue, 10 Oct 2006 11:40:27 GMT (envelope-from gnats) Date: Tue, 10 Oct 2006 11:40:27 GMT Message-Id: <200610101140.k9ABeRwZ018684@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Yar Tikhiy Cc: Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Yar Tikhiy 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: Tue, 10 Oct 2006 11:41:09 -0000 The following reply was made to PR bin/104044; it has been noted by GNATS. From: Yar Tikhiy To: Andrey Simonenko Cc: Florent Thoumie , bug-followup@freebsd.org Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly Date: Tue, 10 Oct 2006 15:31:35 +0400 On Tue, Oct 10, 2006 at 02:34:43PM +0400, Yar Tikhiy wrote: > > > 2. Ignore error code from rm and always run find, that is > > use "rm ... ; find ..." instead of "rm ... && find ...": > > one can create many files with long names and rm will not > > be called because of "Argument list too long" error, so > > find should do all of the work. > > By the way, did you consider omitting the first rm at all and just > using "find ... -print0 | xargs -0 rm -rf" ? The first rm can be > an optimization as long as we use find with -exec. OTOH, xargs -0 > would buy us the same performance and robustness without hacks. > Both find and xargs should be available to cleartmp. Here's the > code. Note "type -d" omitted. > > if checkyesno ${rcvar1}; then > # This is not needed with mfs /tmp, but doesn't hurt anything. > echo "Clearing /tmp." > find -x /tmp/. ! -name . \ > ! \( -name lost+found -type d -user root \) \ > ! \( \( -name quota.user -or -name quota.group \) \ > -type f -user root \) \ > -prune -print0 | xargs -0 rm -rf ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > elif ... It seems we can use just "-delete" here. If run as root, find deletes entries with funny permissions or flags as well as rm does. BTW, find will descend into lost+found and delete its contents in both cases (rm w/ -prune, or -delete), which is good IMHO. -- Yar From owner-freebsd-rc@FreeBSD.ORG Thu Oct 12 10:40:21 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B67B916A416 for ; Thu, 12 Oct 2006 10:40:21 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7059E43D81 for ; Thu, 12 Oct 2006 10:40:21 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k9CAeLGO080085 for ; Thu, 12 Oct 2006 10:40:21 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k9CAeLB8080084; Thu, 12 Oct 2006 10:40:21 GMT (envelope-from gnats) Date: Thu, 12 Oct 2006 10:40:21 GMT Message-Id: <200610121040.k9CAeLB8080084@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Andrey Simonenko Cc: Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Andrey Simonenko 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: Thu, 12 Oct 2006 10:40:21 -0000 The following reply was made to PR bin/104044; it has been noted by GNATS. From: Andrey Simonenko To: Yar Tikhiy Cc: Florent Thoumie , bug-followup@freebsd.org Subject: Re: bin/104044: [patch] rc.d/cleartmp works incorrectly Date: Thu, 12 Oct 2006 13:36:29 +0300 On Tue, Oct 10, 2006 at 03:31:35PM +0400, Yar Tikhiy wrote: > On Tue, Oct 10, 2006 at 02:34:43PM +0400, Yar Tikhiy wrote: > > > > > 2. Ignore error code from rm and always run find, that is > > > use "rm ... ; find ..." instead of "rm ... && find ...": > > > one can create many files with long names and rm will not > > > be called because of "Argument list too long" error, so > > > find should do all of the work. > > > > By the way, did you consider omitting the first rm at all and just > > using "find ... -print0 | xargs -0 rm -rf" ? The first rm can be > > an optimization as long as we use find with -exec. OTOH, xargs -0 > > would buy us the same performance and robustness without hacks. > > Both find and xargs should be available to cleartmp. Here's the > > code. Note "type -d" omitted. > > > > if checkyesno ${rcvar1}; then > > # This is not needed with mfs /tmp, but doesn't hurt anything. > > echo "Clearing /tmp." > > find -x /tmp/. ! -name . \ > > ! \( -name lost+found -type d -user root \) \ > > ! \( \( -name quota.user -or -name quota.group \) \ > > -type f -user root \) \ > > -prune -print0 | xargs -0 rm -rf > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > elif ... > > It seems we can use just "-delete" here. If run as root, find > deletes entries with funny permissions or flags as well as rm does. > BTW, find will descend into lost+found and delete its contents in > both cases (rm w/ -prune, or -delete), which is good IMHO. --- cleartmp.orig Mon Apr 10 16:10:30 2006 +++ cleartmp Thu Oct 12 13:08:00 2006 @@ -10,47 +10,33 @@ . /etc/rc.subr name="cleartmp" -rcvar=`set_rcvar clear_tmp` - +rcvar1=`set_rcvar clear_tmp` start_cmd="${name}_start" -cleartmp_prestart() +cleartmp_start() { - checkyesno clear_tmp_X || return - local x11_socket_dirs="/tmp/.X11-unix /tmp/.ICE-unix /tmp/.font-unix \ /tmp/.XIM-unix" - # Remove X lock files, since they will prevent you from restarting X. - rm -f /tmp/.X[0-9]-lock - - # Create socket directories with correct permissions to avoid - # security problem. - # - rm -fr ${x11_socket_dirs} - mkdir -m 1777 ${x11_socket_dirs} -} - -cleartmp_start() -{ - echo "Clearing /tmp." - # - # Prune quickly with one rm, then use find to clean up - # /tmp/[lq]* (this is not needed with mfs /tmp, but - # doesn't hurt anything). - # - (cd /tmp && rm -rf [a-km-pr-zA-Z]* && - find -x . ! -name . ! -name lost+found ! -name quota.user \ - ! -name quota.group ! -name .X11-unix ! -name .ICE-unix \ - ! -name .font-unix ! -name .XIM-unix \ - -exec rm -rf -- {} \; -type d -prune) + if checkyesno ${rcvar1}; then + # This is not needed for mfs /tmp, but doesn't hurt anything. + echo "Clearing /tmp." + find -x /tmp/. ! -name . \ + ! \( -name lost+found -type d -user root \) \ + ! \( \( -name quota.user -or -name quota.group \) \ + -type f -user root \) \ + -delete + elif checkyesno clear_tmp_X; then + # Remove X lock files, since they will prevent you from + # restarting X. Remove other X related directories. + echo "Clearing /tmp (X related)." + rm -rf /tmp/.X[0-9]-lock ${x11_socket_dirs} + fi + if checkyesno clear_tmp_X; then + # Create X related directories. + mkdir -m 1777 ${x11_socket_dirs} + fi } load_rc_config $name - -# The clear_tmp_X variable should be tested even if clear_tmp_enable is NO -case "$1" in -*start) cleartmp_prestart ;; -esac - run_rc_command "$1" From owner-freebsd-rc@FreeBSD.ORG Thu Oct 12 23:04:30 2006 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2704E16A412 for ; Thu, 12 Oct 2006 23:04:30 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1D60443D6A for ; Thu, 12 Oct 2006 23:04:26 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.3) with ESMTP id k9CN4OOM077005; Fri, 13 Oct 2006 03:04:24 +0400 (MSD) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.3/Submit) id k9CN4OCt077002; Fri, 13 Oct 2006 03:04:24 +0400 (MSD) (envelope-from yar) Date: Fri, 13 Oct 2006 03:04:23 +0400 From: Yar Tikhiy To: David Thompson Message-ID: <20061012230423.GC72944@comp.chem.msu.su> References: <20061009122342.GB2805@comp.chem.msu.su> <20061010015619.3492.qmail@web55109.mail.re4.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20061010015619.3492.qmail@web55109.mail.re4.yahoo.com> User-Agent: Mutt/1.5.9i Cc: freebsd-rc@freebsd.org Subject: Re: Revised article on rc.d 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: Thu, 12 Oct 2006 23:04:30 -0000 On Mon, Oct 09, 2006 at 06:56:19PM -0700, David Thompson wrote: > --- Yar Tikhiy wrote: > > After a long delay, I got down to my article on rc.d again. Many > > thanks to Gary W. Swearingen for his valuable remarks. The new > > version is available at http://people.freebsd.org/~yar/rcng/ . I > > think this version can be added to our articles collection after a > > few corrections that may be suggested by the readers. ;-) > > Regarding this paragraph, > > Note: An rc.d script must be written in the sh(1) language. It > cannot be a binary executable because rc.d can opt to feed such > scripts into a single instance of sh(1) instead of running each > of them separately. This is controlled by an rc.conf(5) variable > named rc_fast_and_loose. An rc.d script cannot be written in > awk(1) or an interpreted language from ports for the same reason; > in addition, it must be runnable early in the system startup > sequence, before /usr has been mounted. > > This caveat is not really true in the strict technical sense. > Consider if someone adds this line to their /etc/rc.d script, > > # KEYWORD: nostart > > then /etc/rc will not execute this script since rcorder is > invoked with '-s nostart'. Thus the reasoning due to the > $rc_fast_and_loose variable is not strictly accurate. That > is, a script could technically be written in any interpreted > language that happens to use '#' as its comment character; > as long as the above comment line was added to the script. > The problem is, of course, such scripts have to provide their > own scaffolding, since rc.subr is written in sh(1); and the > script cannot be run directly by /etc/rc due to the use of the > sh(1) dot '.' operator (thus it needs 'KEYWORD: nostart' so > that /etc/rc will skip it). > > Although not exactly clear in the above paragraph, the reason > files in /etc/rc.d cannot be binary is because rc.d uses the > sh(1) dot '.' operator *for all* invocations, like this, > > if [ -n "$rc_fast_and_loose" ]; then > set $_arg; . $_file > else > ( trap "echo Script $_file interrupted; kill -QUIT $$" 3 > trap "echo Script $_file interrupted; exit 1" 2 > set $_arg; . $_file ) > fi > > But for '.', files in /etc/rc.d *could* be binary, but > even then rcorder expects to process text files, not binary > files. rcorder uses fparseln() to read each file, but this > doesn't really affect reading a binary file. Thus rcorder > processes binary files benignly, try 'rcorder /bin/*' and > you'll see consistent output. > > Also in that paragraph, when I read this, > > ... a binary executable because rc.d can opt to feed ... > ^^^^ > IMHO, it should probably say, > > ... a binary executable because /etc/rc can opt to feed ... > ^^^^^^^ > though I understand you're referring to the rc.d system, > some clarity is gained in that sentence by using /etc/rc. I'd sum all the above up as follows: I went on slippery ground when trying to give reasons for using sh(1) and only sh(1) :-) How about the following paragraph as a replacement? Note: The language of choice for rc.d scripting is sh(1). The tight integration between all rc.d components effectively prevents individual scripts from being written in a different language. -- Yar From owner-freebsd-rc@FreeBSD.ORG Fri Oct 13 01:26:09 2006 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BDD3916A403 for ; Fri, 13 Oct 2006 01:26:09 +0000 (UTC) (envelope-from dat1965@yahoo.com) Received: from web55110.mail.re4.yahoo.com (web55110.mail.re4.yahoo.com [206.190.58.159]) by mx1.FreeBSD.org (Postfix) with SMTP id EDDC743D45 for ; Fri, 13 Oct 2006 01:26:08 +0000 (GMT) (envelope-from dat1965@yahoo.com) Received: (qmail 83515 invoked by uid 60001); 13 Oct 2006 01:26:05 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=3Q+8df2BZWTntlslHn4icnf1xnjmPIKjwypvivolTD9GNfjaXInSpZUjhtTsrYHJoWrdMwX2AlHRDNSjDVQ3MRolDIOMM5MY/ERUoKZ4KupxevWhBYmgWzH5n0R2Qbo9Z6icUKUu+/wAHqNf00vi4fL5xG9AH7/teQ42Am7anqg= ; Message-ID: <20061013012604.83513.qmail@web55110.mail.re4.yahoo.com> Received: from [67.131.247.220] by web55110.mail.re4.yahoo.com via HTTP; Thu, 12 Oct 2006 18:26:03 PDT Date: Thu, 12 Oct 2006 18:26:03 -0700 (PDT) From: David Thompson To: Yar Tikhiy In-Reply-To: <20061012230423.GC72944@comp.chem.msu.su> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: freebsd-rc@freebsd.org Subject: Re: Revised article on rc.d 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: Fri, 13 Oct 2006 01:26:09 -0000 --- Yar Tikhiy wrote: > On Mon, Oct 09, 2006 at 06:56:19PM -0700, David Thompson wrote: > > --- Yar Tikhiy wrote: > > > After a long delay, I got down to my article on rc.d again. Many > > > thanks to Gary W. Swearingen for his valuable remarks. The new > > > version is available at http://people.freebsd.org/~yar/rcng/ . I > > > think this version can be added to our articles collection after a > > > few corrections that may be suggested by the readers. ;-) > > > > Regarding this paragraph, > > > > Note: An rc.d script must be written in the sh(1) language. It > > cannot be a binary executable because rc.d can opt to feed such > > scripts into a single instance of sh(1) instead of running each > > of them separately. This is controlled by an rc.conf(5) variable > > named rc_fast_and_loose. An rc.d script cannot be written in > > awk(1) or an interpreted language from ports for the same reason; > > in addition, it must be runnable early in the system startup > > sequence, before /usr has been mounted. > > > > This caveat is not really true in the strict technical sense. > > Consider if someone adds this line to their /etc/rc.d script, > > > > # KEYWORD: nostart > > > > then /etc/rc will not execute this script since rcorder is > > invoked with '-s nostart'. Thus the reasoning due to the > > $rc_fast_and_loose variable is not strictly accurate. That > > is, a script could technically be written in any interpreted > > language that happens to use '#' as its comment character; > > as long as the above comment line was added to the script. > > The problem is, of course, such scripts have to provide their > > own scaffolding, since rc.subr is written in sh(1); and the > > script cannot be run directly by /etc/rc due to the use of the > > sh(1) dot '.' operator (thus it needs 'KEYWORD: nostart' so > > that /etc/rc will skip it). > > > > Although not exactly clear in the above paragraph, the reason > > files in /etc/rc.d cannot be binary is because rc.d uses the > > sh(1) dot '.' operator *for all* invocations, like this, > > > > if [ -n "$rc_fast_and_loose" ]; then > > set $_arg; . $_file > > else > > ( trap "echo Script $_file interrupted; kill -QUIT $$" 3 > > trap "echo Script $_file interrupted; exit 1" 2 > > set $_arg; . $_file ) > > fi > > > > But for '.', files in /etc/rc.d *could* be binary, but > > even then rcorder expects to process text files, not binary > > files. rcorder uses fparseln() to read each file, but this > > doesn't really affect reading a binary file. Thus rcorder > > processes binary files benignly, try 'rcorder /bin/*' and > > you'll see consistent output. > > > > Also in that paragraph, when I read this, > > > > ... a binary executable because rc.d can opt to feed ... > > ^^^^ > > IMHO, it should probably say, > > > > ... a binary executable because /etc/rc can opt to feed ... > > ^^^^^^^ > > though I understand you're referring to the rc.d system, > > some clarity is gained in that sentence by using /etc/rc. > > I'd sum all the above up as follows: I went on slippery ground > when trying to give reasons for using sh(1) and only sh(1) :-) > How about the following paragraph as a replacement? > > Note: The language of choice for rc.d scripting is sh(1). > The tight integration between all rc.d components effectively > prevents individual scripts from being written in a different > language. Since not all rc.d scripts *have* to be executed by /etc/rc, a blurb that acknowledges that might satisfy things. With this in mind, I actually prefer the original note, worded something like this, Note: An rc.d script must be written in the sh(1) language, although this is only true for scripts that are designed to be invoked by /etc/rc. The reason is /etc/rc uses the sh(1) '.' command to execute an rc.d script, thus the syntax of the rc.d script must be sh(1). If you want to mention other details, like binary executables, or how 'rcorder -s nostart' allows 'KEYWORD: nostart' comments in an rc.d perl script, then this is good fodder for a follow-on paragraph, A special comment in your rc.d script can prevent /etc/rc from trying to execute it. Add this comment line to your rc.d script, the '#' must be column 1, # KEYWORD: nostart and your perl/python/ruby/sh rc.d script will be safely skipped by /etc/rc. But since almost all rc.d scripts are executed at system bootup, and therefore executed by /etc/rc, using a language other than sh(1) is almost never an option. Best Regards, David __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From owner-freebsd-rc@FreeBSD.ORG Fri Oct 13 03:33:45 2006 Return-Path: X-Original-To: freebsd-rc@FreeBSD.org Delivered-To: freebsd-rc@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6795E16A40F; Fri, 13 Oct 2006 03:33:45 +0000 (UTC) (envelope-from clsung@FreeBSD.csie.nctu.edu.tw) Received: from FreeBSD.csie.nctu.edu.tw (freebsd.csie.nctu.edu.tw [140.113.17.209]) by mx1.FreeBSD.org (Postfix) with ESMTP id 66FBE43D4C; Fri, 13 Oct 2006 03:33:44 +0000 (GMT) (envelope-from clsung@FreeBSD.csie.nctu.edu.tw) Received: from localhost (localhost.csie.nctu.edu.tw [127.0.0.1]) by FreeBSD.csie.nctu.edu.tw (Postfix) with ESMTP id 011347E952; Fri, 13 Oct 2006 11:34:09 +0800 (CST) Received: from FreeBSD.csie.nctu.edu.tw ([127.0.0.1]) by localhost (FreeBSD.csie.nctu.edu.tw [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t3f1WHIBQSem; Fri, 13 Oct 2006 11:34:08 +0800 (CST) Received: by FreeBSD.csie.nctu.edu.tw (Postfix, from userid 1038) id 724FF7E9BE; Fri, 13 Oct 2006 11:34:08 +0800 (CST) Date: Fri, 13 Oct 2006 11:34:08 +0800 From: Cheng-Lung Sung To: bug-followup@FreeBSD.org, llevier@argosnet.com Message-ID: <20061013033408.GA30695@FreeBSD.csie.nctu.edu.tw> MIME-Version: 1.0 Content-Type: text/plain; charset=big5 Content-Disposition: inline X-Fingerprint: E0BC 57F9 F44B 46C6 DB53 8462 F807 89F3 956E 8BC1 X-Public-Key: http://sungsung.dragon2.net/pubring.asc User-Agent: Mutt/1.5.13 (2006-08-11) Cc: freebsd-current@freebsd.org, freebsd-rc@FreeBSD.org Subject: Re: conf/102913: /etc/rc.d/named killall in jailed OS 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: Fri, 13 Oct 2006 03:33:45 -0000 try this patch? Index: etc/rc.d/named =================================================================== RCS file: /home/ncvs/src/etc/rc.d/named,v retrieving revision 1.26 diff -u -r1.26 named --- etc/rc.d/named 20 Apr 2006 12:30:12 -0000 1.26 +++ etc/rc.d/named 13 Oct 2006 03:30:41 -0000 @@ -91,9 +91,28 @@ if rndc stop 2>/dev/null; then echo . else - echo -n ": rndc failed, trying killall: " - if killall named; then - echo . + echo -n ": rndc failed, trying " + # If we are not inside a jail, killall will kill named in jail + # If we are inside a jail, killall is safe + # + if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then + echo -n "killall: " + if killall named; then + echo . + fi + else + # If we're not in a jail, try to kill named from pidfile + # Otherwise see if we can get from ps + echo -n "kill pid: " + if [ -f ${pidfile} ]; then + kill -TERM `cat ${pidfile}` + echo . + else + for i in `ps -axo command,pid,jid | awk '/^[^ ]+named/{if ($NF == 0) {print $(NF-1)}}'`; do + kill -TERM ${i} + echo . + done + fi fi fi } -- Cheng-Lung Sung - clsung@ From owner-freebsd-rc@FreeBSD.ORG Fri Oct 13 03:40:26 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 339C916A403 for ; Fri, 13 Oct 2006 03:40:26 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id F167043D49 for ; Fri, 13 Oct 2006 03:40:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k9D3ePdP074550 for ; Fri, 13 Oct 2006 03:40:25 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k9D3ePCF074549; Fri, 13 Oct 2006 03:40:25 GMT (envelope-from gnats) Date: Fri, 13 Oct 2006 03:40:25 GMT Message-Id: <200610130340.k9D3ePCF074549@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Cheng-Lung Sung Cc: Subject: Re: conf/102913: /etc/rc.d/named killall in jailed OS X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Cheng-Lung Sung 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: Fri, 13 Oct 2006 03:40:26 -0000 The following reply was made to PR conf/102913; it has been noted by GNATS. From: Cheng-Lung Sung To: bug-followup@FreeBSD.org, llevier@argosnet.com Cc: freebsd-rc@FreeBSD.org, freebsd-current@freebsd.org Subject: Re: conf/102913: /etc/rc.d/named killall in jailed OS Date: Fri, 13 Oct 2006 11:34:08 +0800 try this patch? Index: etc/rc.d/named =================================================================== RCS file: /home/ncvs/src/etc/rc.d/named,v retrieving revision 1.26 diff -u -r1.26 named --- etc/rc.d/named 20 Apr 2006 12:30:12 -0000 1.26 +++ etc/rc.d/named 13 Oct 2006 03:30:41 -0000 @@ -91,9 +91,28 @@ if rndc stop 2>/dev/null; then echo . else - echo -n ": rndc failed, trying killall: " - if killall named; then - echo . + echo -n ": rndc failed, trying " + # If we are not inside a jail, killall will kill named in jail + # If we are inside a jail, killall is safe + # + if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then + echo -n "killall: " + if killall named; then + echo . + fi + else + # If we're not in a jail, try to kill named from pidfile + # Otherwise see if we can get from ps + echo -n "kill pid: " + if [ -f ${pidfile} ]; then + kill -TERM `cat ${pidfile}` + echo . + else + for i in `ps -axo command,pid,jid | awk '/^[^ ]+named/{if ($NF == 0) {print $(NF-1)}}'`; do + kill -TERM ${i} + echo . + done + fi fi fi } -- Cheng-Lung Sung - clsung@ From owner-freebsd-rc@FreeBSD.ORG Fri Oct 13 07:00:15 2006 Return-Path: X-Original-To: freebsd-rc@FreeBSD.org Delivered-To: freebsd-rc@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 26BAD16A417; Fri, 13 Oct 2006 07:00:15 +0000 (UTC) (envelope-from llevier@argosnet.com) Received: from mx.levier.org (ns.argosnet.com [213.251.139.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id D5BC343D53; Fri, 13 Oct 2006 07:00:00 +0000 (GMT) (envelope-from llevier@argosnet.com) Received: from localhost (ns [213.251.139.26]) by mx.levier.org (Postfix) with ESMTP id 0B8BA14D8F0; Fri, 13 Oct 2006 08:59:50 +0200 (CEST) X-Virus-Scanned: amavisd-new at argosnet.com Received: from mx.levier.org ([213.251.139.26]) by localhost (ns.levier.org [213.251.139.26]) (amavisd-new, port 10024) with ESMTP id 37Qaf-X9y6Qp; Fri, 13 Oct 2006 08:59:46 +0200 (CEST) Received: from osgiliath.argosnet.com (tirion.argosnet.com [82.224.1.141]) by mx.levier.org (Postfix) with ESMTP id B30E814D8EE; Fri, 13 Oct 2006 08:59:45 +0200 (CEST) Message-Id: <7.0.1.0.2.20061013085800.01e91dc0@argosnet.com> X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Date: Fri, 13 Oct 2006 08:59:44 +0200 To: Cheng-Lung Sung ,bug-followup@FreeBSD.org From: Laurent LEVIER In-Reply-To: <20061013033408.GA30695@FreeBSD.csie.nctu.edu.tw> References: <20061013033408.GA30695@FreeBSD.csie.nctu.edu.tw> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Cc: freebsd-current@freebsd.org, freebsd-rc@FreeBSD.org Subject: Re: conf/102913: /etc/rc.d/named killall in jailed OS 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: Fri, 13 Oct 2006 07:00:15 -0000 Hi Cheng-Lung Sung At 05:34 13/10/2006, Cheng-Lung Sung wrote: >try this patch? thanks, I already patched my script. Now it kills pid, then if it fails, gets all named out of jail (J flag) and kill these. The bug report was just so you are aware of this and can take corrective action for next release ;-) And between you & me, this bug is nothing comparing to the other one I submitted months ago about IDE driver bug. Thanks!! Brgrds >Index: etc/rc.d/named >=================================================================== >RCS file: /home/ncvs/src/etc/rc.d/named,v >retrieving revision 1.26 >diff -u -r1.26 named >--- etc/rc.d/named 20 Apr 2006 12:30:12 -0000 1.26 >+++ etc/rc.d/named 13 Oct 2006 03:30:41 -0000 >@@ -91,9 +91,28 @@ > if rndc stop 2>/dev/null; then > echo . > else >- echo -n ": rndc failed, trying killall: " >- if killall named; then >- echo . >+ echo -n ": rndc failed, trying " >+ # If we are not inside a jail, killall will kill named in jail >+ # If we are inside a jail, killall is safe >+ # >+ if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then >+ echo -n "killall: " >+ if killall named; then >+ echo . >+ fi >+ else >+ # If we're not in a jail, try to kill named >from pidfile >+ # Otherwise see if we can get from ps >+ echo -n "kill pid: " >+ if [ -f ${pidfile} ]; then >+ kill -TERM `cat ${pidfile}` >+ echo . >+ else >+ for i in `ps -axo command,pid,jid | >awk '/^[^ ]+named/{if ($NF == 0) {print $(NF-1)}}'`; do >+ kill -TERM ${i} >+ echo . >+ done >+ fi > fi > fi > } > >-- >Cheng-Lung Sung - clsung@ Laurent LEVIER Systems & Networks Security Expert, CISSP CISM From owner-freebsd-rc@FreeBSD.ORG Fri Oct 13 07:01:08 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 04C6F16A416 for ; Fri, 13 Oct 2006 07:01:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id A603D43D73 for ; Fri, 13 Oct 2006 07:01:07 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k9D70Yii096466 for ; Fri, 13 Oct 2006 07:00:34 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k9D70Yj6096465; Fri, 13 Oct 2006 07:00:34 GMT (envelope-from gnats) Date: Fri, 13 Oct 2006 07:00:34 GMT Message-Id: <200610130700.k9D70Yj6096465@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Laurent LEVIER Cc: Subject: Re: conf/102913: /etc/rc.d/named killall in jailed OS X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Laurent LEVIER 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: Fri, 13 Oct 2006 07:01:08 -0000 The following reply was made to PR conf/102913; it has been noted by GNATS. From: Laurent LEVIER To: Cheng-Lung Sung ,bug-followup@FreeBSD.org Cc: freebsd-rc@FreeBSD.org,freebsd-current@freebsd.org Subject: Re: conf/102913: /etc/rc.d/named killall in jailed OS Date: Fri, 13 Oct 2006 08:59:44 +0200 Hi Cheng-Lung Sung At 05:34 13/10/2006, Cheng-Lung Sung wrote: >try this patch? thanks, I already patched my script. Now it kills pid, then if it fails, gets all named out of jail (J flag) and kill these. The bug report was just so you are aware of this and can take corrective action for next release ;-) And between you & me, this bug is nothing comparing to the other one I submitted months ago about IDE driver bug. Thanks!! Brgrds >Index: etc/rc.d/named >=================================================================== >RCS file: /home/ncvs/src/etc/rc.d/named,v >retrieving revision 1.26 >diff -u -r1.26 named >--- etc/rc.d/named 20 Apr 2006 12:30:12 -0000 1.26 >+++ etc/rc.d/named 13 Oct 2006 03:30:41 -0000 >@@ -91,9 +91,28 @@ > if rndc stop 2>/dev/null; then > echo . > else >- echo -n ": rndc failed, trying killall: " >- if killall named; then >- echo . >+ echo -n ": rndc failed, trying " >+ # If we are not inside a jail, killall will kill named in jail >+ # If we are inside a jail, killall is safe >+ # >+ if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then >+ echo -n "killall: " >+ if killall named; then >+ echo . >+ fi >+ else >+ # If we're not in a jail, try to kill named >from pidfile >+ # Otherwise see if we can get from ps >+ echo -n "kill pid: " >+ if [ -f ${pidfile} ]; then >+ kill -TERM `cat ${pidfile}` >+ echo . >+ else >+ for i in `ps -axo command,pid,jid | >awk '/^[^ ]+named/{if ($NF == 0) {print $(NF-1)}}'`; do >+ kill -TERM ${i} >+ echo . >+ done >+ fi > fi > fi > } > >-- >Cheng-Lung Sung - clsung@ Laurent LEVIER Systems & Networks Security Expert, CISSP CISM From owner-freebsd-rc@FreeBSD.ORG Sat Oct 14 18:59:57 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB83E16A40F; Sat, 14 Oct 2006 18:59:57 +0000 (UTC) (envelope-from linimon@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6FD6743D62; Sat, 14 Oct 2006 18:59:57 +0000 (GMT) (envelope-from linimon@FreeBSD.org) Received: from freefall.freebsd.org (linimon@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k9EIxMCj000664; Sat, 14 Oct 2006 18:59:22 GMT (envelope-from linimon@freefall.freebsd.org) Received: (from linimon@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k9EIxMqW000660; Sat, 14 Oct 2006 18:59:22 GMT (envelope-from linimon) Date: Sat, 14 Oct 2006 18:59:22 GMT From: Mark Linimon Message-Id: <200610141859.k9EIxMqW000660@freefall.freebsd.org> To: linimon@FreeBSD.org, freebsd-bugs@FreeBSD.org, freebsd-rc@FreeBSD.org Cc: Subject: Re: conf/104408: command not set in rc.d/isdnd, can't stop isdnd with this rc script 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: Sat, 14 Oct 2006 18:59:58 -0000 Synopsis: command not set in rc.d/isdnd, can't stop isdnd with this rc script Responsible-Changed-From-To: freebsd-bugs->freebsd-rc Responsible-Changed-By: linimon Responsible-Changed-When: Sat Oct 14 18:58:54 UTC 2006 Responsible-Changed-Why: Over to maintainer(s). http://www.freebsd.org/cgi/query-pr.cgi?pr=104408 From owner-freebsd-rc@FreeBSD.ORG Sat Oct 14 20:00:53 2006 Return-Path: X-Original-To: freebsd-rc@hub.freebsd.org Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B791116A403 for ; Sat, 14 Oct 2006 20:00:53 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4264243D60 for ; Sat, 14 Oct 2006 20:00:53 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k9EK0qlN006114 for ; Sat, 14 Oct 2006 20:00:52 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k9EK0qvM006113; Sat, 14 Oct 2006 20:00:52 GMT (envelope-from gnats) Date: Sat, 14 Oct 2006 20:00:52 GMT Message-Id: <200610142000.k9EK0qvM006113@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Yar Tikhiy Cc: Subject: Re: conf/102913: /etc/rc.d/named killall in jailed OS X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Yar Tikhiy 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: Sat, 14 Oct 2006 20:00:53 -0000 The following reply was made to PR conf/102913; it has been noted by GNATS. From: Yar Tikhiy To: Cheng-Lung Sung Cc: bug-followup@freebsd.org, llevier@argosnet.com Subject: Re: conf/102913: /etc/rc.d/named killall in jailed OS Date: Sat, 14 Oct 2006 23:57:29 +0400 On Fri, Oct 13, 2006 at 11:34:08AM +0800, Cheng-Lung Sung wrote: > try this patch? > > Index: etc/rc.d/named > =================================================================== > RCS file: /home/ncvs/src/etc/rc.d/named,v > retrieving revision 1.26 > diff -u -r1.26 named > --- etc/rc.d/named 20 Apr 2006 12:30:12 -0000 1.26 > +++ etc/rc.d/named 13 Oct 2006 03:30:41 -0000 > @@ -91,9 +91,28 @@ > if rndc stop 2>/dev/null; then > echo . > else > - echo -n ": rndc failed, trying killall: " > - if killall named; then Is it possible to use pkill(1) instead of killall(1)? The former was moved to /bin specifically for the benefit of rc.d scripts. > - echo . > + echo -n ": rndc failed, trying " > + # If we are not inside a jail, killall will kill named in jail > + # If we are inside a jail, killall is safe > + # > + if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then > + echo -n "killall: " > + if killall named; then Ditto here. > + echo . > + fi > + else > + # If we're not in a jail, try to kill named from pidfile > + # Otherwise see if we can get from ps > + echo -n "kill pid: " > + if [ -f ${pidfile} ]; then > + kill -TERM `cat ${pidfile}` > + echo . > + else > + for i in `ps -axo command,pid,jid | awk '/^[^ ]+named/{if ($NF == 0) {print $(NF-1)}}'`; do Hmm, pkill(1) can match a process by its jid, but 0 means any non-zero jid to it. Looks like a deficiency in the otherwise convenient tool. > + kill -TERM ${i} > + echo . > + done > + fi > fi > fi > } -- Yar From owner-freebsd-rc@FreeBSD.ORG Sat Oct 14 21:58:09 2006 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DA51C16A407 for ; Sat, 14 Oct 2006 21:58:09 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.FreeBSD.org (Postfix) with ESMTP id 06A6943D62 for ; Sat, 14 Oct 2006 21:58:08 +0000 (GMT) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.3) with ESMTP id k9ELw5s8017581; Sun, 15 Oct 2006 01:58:06 +0400 (MSD) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.3/Submit) id k9ELw56C017576; Sun, 15 Oct 2006 01:58:05 +0400 (MSD) (envelope-from yar) Date: Sun, 15 Oct 2006 01:58:05 +0400 From: Yar Tikhiy To: David Thompson Message-ID: <20061014215804.GB15046@comp.chem.msu.su> References: <20061012230423.GC72944@comp.chem.msu.su> <20061013012604.83513.qmail@web55110.mail.re4.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20061013012604.83513.qmail@web55110.mail.re4.yahoo.com> User-Agent: Mutt/1.5.9i Cc: freebsd-rc@freebsd.org Subject: Re: Revised article on rc.d 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: Sat, 14 Oct 2006 21:58:09 -0000 On Thu, Oct 12, 2006 at 06:26:03PM -0700, David Thompson wrote: > --- Yar Tikhiy wrote: > > On Mon, Oct 09, 2006 at 06:56:19PM -0700, David Thompson wrote: > > > --- Yar Tikhiy wrote: > > > > After a long delay, I got down to my article on rc.d again. Many > > > > thanks to Gary W. Swearingen for his valuable remarks. The new > > > > version is available at http://people.freebsd.org/~yar/rcng/ . I > > > > think this version can be added to our articles collection after a > > > > few corrections that may be suggested by the readers. ;-) > > > > > > Regarding this paragraph, > > > > > > Note: An rc.d script must be written in the sh(1) language. It > > > cannot be a binary executable because rc.d can opt to feed such > > > scripts into a single instance of sh(1) instead of running each > > > of them separately. This is controlled by an rc.conf(5) variable > > > named rc_fast_and_loose. An rc.d script cannot be written in > > > awk(1) or an interpreted language from ports for the same reason; > > > in addition, it must be runnable early in the system startup > > > sequence, before /usr has been mounted. > > > > > > This caveat is not really true in the strict technical sense. > > > Consider if someone adds this line to their /etc/rc.d script, > > > > > > # KEYWORD: nostart > > > > > > then /etc/rc will not execute this script since rcorder is > > > invoked with '-s nostart'. Thus the reasoning due to the > > > $rc_fast_and_loose variable is not strictly accurate. That > > > is, a script could technically be written in any interpreted > > > language that happens to use '#' as its comment character; > > > as long as the above comment line was added to the script. > > > The problem is, of course, such scripts have to provide their > > > own scaffolding, since rc.subr is written in sh(1); and the > > > script cannot be run directly by /etc/rc due to the use of the > > > sh(1) dot '.' operator (thus it needs 'KEYWORD: nostart' so > > > that /etc/rc will skip it). > > > > > > Although not exactly clear in the above paragraph, the reason > > > files in /etc/rc.d cannot be binary is because rc.d uses the > > > sh(1) dot '.' operator *for all* invocations, like this, > > > > > > if [ -n "$rc_fast_and_loose" ]; then > > > set $_arg; . $_file > > > else > > > ( trap "echo Script $_file interrupted; kill -QUIT $$" 3 > > > trap "echo Script $_file interrupted; exit 1" 2 > > > set $_arg; . $_file ) > > > fi > > > > > > But for '.', files in /etc/rc.d *could* be binary, but > > > even then rcorder expects to process text files, not binary > > > files. rcorder uses fparseln() to read each file, but this > > > doesn't really affect reading a binary file. Thus rcorder > > > processes binary files benignly, try 'rcorder /bin/*' and > > > you'll see consistent output. > > > > > > Also in that paragraph, when I read this, > > > > > > ... a binary executable because rc.d can opt to feed ... > > > ^^^^ > > > IMHO, it should probably say, > > > > > > ... a binary executable because /etc/rc can opt to feed ... > > > ^^^^^^^ > > > though I understand you're referring to the rc.d system, > > > some clarity is gained in that sentence by using /etc/rc. > > > > I'd sum all the above up as follows: I went on slippery ground > > when trying to give reasons for using sh(1) and only sh(1) :-) > > How about the following paragraph as a replacement? > > > > Note: The language of choice for rc.d scripting is sh(1). > > The tight integration between all rc.d components effectively > > prevents individual scripts from being written in a different > > language. > > Since not all rc.d scripts *have* to be executed by /etc/rc, > a blurb that acknowledges that might satisfy things. With this > in mind, I actually prefer the original note, worded something > like this, > > Note: An rc.d script must be written in the sh(1) language, > although this is only true for scripts that are designed to > be invoked by /etc/rc. The reason is /etc/rc uses the sh(1) > '.' command to execute an rc.d script, thus the syntax of the > rc.d script must be sh(1). > > If you want to mention other details, like binary executables, or how > 'rcorder -s nostart' allows 'KEYWORD: nostart' comments in an rc.d > perl script, then this is good fodder for a follow-on paragraph, > > A special comment in your rc.d script can prevent /etc/rc > from trying to execute it. Add this comment line to your > rc.d script, the '#' must be column 1, > > # KEYWORD: nostart > > and your perl/python/ruby/sh rc.d script will be safely > skipped by /etc/rc. But since almost all rc.d scripts are > executed at system bootup, and therefore executed by /etc/rc, > using a language other than sh(1) is almost never an option. Telling truth, only truth, and nothing but truth, eh? ;-) All right, we shouldn't hide the truth from readers even if we dislike it -- I stand on this point, too, when somebody else attemts to violate it. :-) However, I really doubt that a non-sh(1) rc.d script will ever be accepted for the base system or ports. So in the last version I chose to explain the details but still discourage readers from using anything but sh(1). -- Yar