From owner-freebsd-rc@FreeBSD.ORG Sun May 8 22:43:34 2011 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 BC10E106564A for ; Sun, 8 May 2011 22:43:34 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mx1.fisglobal.com (mx1.fisglobal.com [199.200.24.190]) by mx1.freebsd.org (Postfix) with ESMTP id 839B08FC12 for ; Sun, 8 May 2011 22:43:34 +0000 (UTC) Received: from sbhfislrext01.fnfis.com ([192.168.249.167]) by SCSFISLTC02 (8.14.3/8.14.3) with ESMTP id p48MhXx8011123; Sun, 8 May 2011 17:43:33 -0500 Received: from SBHFISLTCGW04.FNFIS.COM (Not Verified[10.132.248.123]) by sbhfislrext01.fnfis.com with MailMarshal (v6, 5, 4, 7535) id ; Sun, 08 May 2011 17:43:34 -0500 Received: from SBHFISLTCGW04.FNFIS.COM ([10.132.248.123]) by SBHFISLTCGW04.FNFIS.COM with Microsoft SMTPSVC(6.0.3790.4675); Sun, 8 May 2011 17:43:33 -0500 Received: from [10.0.0.102] ([10.132.254.136]) by SBHFISLTCGW04.FNFIS.COM over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Sun, 8 May 2011 17:43:32 -0500 Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Devin Teske In-Reply-To: <20110508221129.GA89657@stack.nl> Date: Sun, 8 May 2011 15:43:29 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20110508191336.GC3527@DataIX.net> <20110508202636.GF3527@DataIX.net> <20110508221129.GA89657@stack.nl> To: Jilles Tjoelker X-Mailer: Apple Mail (2.1084) X-OriginalArrivalTime: 08 May 2011 22:43:33.0112 (UTC) FILETIME=[5C152F80:01CC0DD1] Cc: Garrett Cooper , Jason Hellenthal , freebsd-rc@freebsd.org Subject: Re: [RFC][Change-Request] Create usefulness in rc.subr etc/rc.conf.d/*.conf namespace. 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, 08 May 2011 22:43:34 -0000 Jilles, On May 8, 2011, at 3:11 PM, Jilles Tjoelker wrote: > On Sun, May 08, 2011 at 02:19:17PM -0700, Garrett Cooper wrote: >>>> Doing: >=20 >>>> find /etc/rc.conf.d/ -type f -name '*.conf' -mindepth 1 -maxdepth 1 -p= erm +111 | while read _modular_conf; do >>>> debug "Sourcing $_modular_conf" >>>> . "$_modular_conf" >>>> done >=20 >>>> might be better. There's some more magic that could ultimately be don= e to make this more secure/robust using "-print0" | xargs, but it's up to y= ou how you might want to go about solving that problem. >>>> Also, I don't know if depending on a .conf file to be executable is n= ecessarily the best course of action. >=20 >>> Yeah I see what you are getting at there and I came across thinking the= =20 >>> same thing. Fortunately /etc/rc.conf.d/*.conf is only one level deep=20 >>> without using find(1). >=20 >> Yes, but the above method used avoids simple E2BIG problems. It just >> doesn't properly deal with filenames that break on IFS, etc though >> (that's part of where I was leading, but I said "security" instead. >=20 > I would say the opposite. jhell's original loop >=20 > + for _modular_conf in /etc/rc.conf.d/*.conf; do NICE! I'm tucking that one away in the frontal lobes. I didn't know `for' could glob directory contents like that. Even works all the way back to FreeBSD-4.11. --=20 Cheers, Devin > + if [ -f "$_modular_conf" -a -x "$_modular_conf" ]; then > + debug "Sourcing $_modular_conf" > + . $_modular_conf > + fi > + done >=20 > with a small change > - . $_modular_conf > + . "$_modular_conf" >=20 > does not have any E2BIG problems, and also no problems with special > characters. This is because the list of pathnames stays within sh; it is > not passed to another program. If there is no matching file, the loop > runs once for /etc/rc.conf.d/*.conf which does not exist and is > therefore not sourced. >=20 > Any 'while read...' loop will handle pathnames with newlines > incorrectly, and the simple ones also handle backslashes and certain > whitespace incorrectly. Also, the proposed pipeline does not even work > as the while loop is executed in a subshell, so the assignments in the > sourced files are lost. >=20 > This post is not an endorsement of jhell's idea. I am not really > convinced it is useful. For experimenting, the for command can be placed > in /etc/rc.conf. >=20 > --=20 > Jilles Tjoelker > _______________________________________________ > freebsd-rc@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-rc > To unsubscribe, send any mail to "freebsd-rc-unsubscribe@freebsd.org" _____________ The information contained in this message is proprietary and/or confidentia= l. If you are not the intended recipient, please: (i) delete the message an= d all copies; (ii) do not disclose, distribute or use the message in any ma= nner; and (iii) notify the sender immediately. In addition, please be aware= that any message addressed to our domain is subject to archiving and revie= w by persons other than the intended recipient. Thank you. _____________