(unknown charset) rc.subr: disabling globbing while processing devfs rules

From: (unknown charset) Andriy Gapon <avg_at_FreeBSD.org>
Date: Sat, 23 Mar 2013 10:41:41 +0200
Any objections / concerns for the following change?

An example.
This rule in devfs.rules:
add path da* mode 660 group operator
and this directory:
/data
result in the following rule being actually installed:
100 path data group operator mode 660

Of course, I could refine the pattern in the rule, but I shouldn't have to do
it, because the pattern is for /dev/ entries, not arbitrary files in the
filesystem namespace.

commit 7ce5e9ca5c107e2669f18efa472c1ab14999247c
Author: Andriy Gapon <avg_at_icyb.net.ua>
Date:   Sat Mar 23 10:29:39 2013 +0200

    rc.subr: disabling globbing while processing devfs rules in
devfs_rulesets_from_file()

    The rules themselves typically have shell-like patterns and it is incorrect
    when they get replaced with matching filesystem entries.

    Shell magic by:	jilles

diff --git a/etc/rc.subr b/etc/rc.subr
index f37ede7..9952c82 100644
--- a/etc/rc.subr
+++ b/etc/rc.subr
_at__at_ -1301,7 +1301,7 _at__at_ make_symlink()
 #
 devfs_rulesets_from_file()
 {
-	local file _err _me
+	local file _err _me _opts
 	file="$1"
 	_me="devfs_rulesets_from_file"
 	_err=0
_at__at_ -1314,6 +1314,11 _at__at_ devfs_rulesets_from_file()
 		debug "$_me: no such file ($file)"
 		return 0
 	fi
+
+	# Disable globbing so that the rule patterns are not expanded
+	# by accident with matching filesystem entries.
+	_opts=$-; set -f
+
 	debug "reading rulesets from file ($file)"
 	{ while read line
 	do
_at__at_ -1360,6 +1365,7 _at__at_ devfs_rulesets_from_file()
 			break
 		fi
 	done } < $file
+	case $_opts in *f*) ;; *) set +f ;; esac
 	return $_err
 }


-- 
Andriy Gapon
Received on Sat Mar 23 2013 - 07:41:56 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:36 UTC