[RFC][Change-Request] Create usefulness in rc.subr etc/rc.conf.d/*.conf namespace.

Devin Teske dteske at vicor.com
Sun May 8 22:43:34 UTC 2011


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:
> 
>>>> find /etc/rc.conf.d/ -type f -name '*.conf' -mindepth 1 -maxdepth 1 -perm +111 | while read _modular_conf; do
>>>> 	debug "Sourcing $_modular_conf"
>>>> 	. "$_modular_conf"
>>>> done
> 
>>>> 	might be better. There's some more magic that could ultimately be done to make this more secure/robust using "-print0" | xargs, but it's up to you 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 necessarily the best course of action.
> 
>>> Yeah I see what you are getting at there and I came across thinking the 
>>> same thing. Fortunately /etc/rc.conf.d/*.conf is only one level deep 
>>> without using find(1).
> 
>> 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.
> 
> I would say the opposite. jhell's original loop
> 
> +		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.
-- 
Cheers,
Devin



> +			if [ -f "$_modular_conf" -a -x "$_modular_conf" ]; then
> +				debug "Sourcing $_modular_conf"
> +				. $_modular_conf
> +			fi
> +		done
> 
> with a small change
> -				. $_modular_conf
> +				. "$_modular_conf"
> 
> 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.
> 
> 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.
> 
> 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.
> 
> -- 
> Jilles Tjoelker
> _______________________________________________
> freebsd-rc at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-rc
> To unsubscribe, send any mail to "freebsd-rc-unsubscribe at freebsd.org"


_____________

The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
_____________


More information about the freebsd-rc mailing list