Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171177969
D38826.id118090.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D38826.id118090.diff
View Options
diff --git a/libexec/rc/rc.d/jail b/libexec/rc/rc.d/jail
--- a/libexec/rc/rc.d/jail
+++ b/libexec/rc/rc.d/jail
@@ -10,6 +10,57 @@
. /etc/rc.subr
+
+## Note from antranigv
+#
+#### Terminology
+# jail.conf means the config format of jail.conf
+# /etc/jail.conf is the file itself
+# /etc/jail.*.conf is any file that matches that pattern
+# /etc/jail.conf.d/*.conf is any file that matches that pattern
+# "something" parameters means a parameters named "something" in jail.conf
+# "something=" is a parameter inside rc.conf
+# I know, I'm mostly repeating myself, but some people are new to this :)
+#
+#### Regarding jail file management ->
+# If you are reading this, then I've sent you this file for testing. Currently,
+# we need to test the following scenarios.
+# 1. a jail exists in /etc/jail.conf
+# 2. #1 + a jail in /etc/jail.anotherjail.conf
+# 3. #2 + a jail in /etc/jail.conf.d/yetanother.conf
+# 4. #3 + a jail at one of the jail.conf locations, that depends on another jail
+# using the "depend" parameter. Read more in jail(8), jail parameters.
+# 5. The above, used with/without "jail_parallel_start=" and/or "jail_reverse_stop="
+#
+# Technically, this rc.d/jail should be able to "merge" global configs from
+# /etc/jail.conf. Meaning, you can have your global vars in /etc/jail.conf and
+# the rest should be in their own files, without any global configs.
+#
+#### Regarding jail_list, "depend" parameter and start order ->
+# Before this patch, only the jails in /etc/jail.conf start
+# automatically if no jail is defined in "jail_list=".
+#
+# With this patch, all jails in /etc/jail.conf, /etc/jail.*.conf and
+# /etc/jail.conf.d/*.conf start automatically.
+#
+# Again, if "jail_list=" is defined, then only those jails would start.
+#
+# That being said, the best practice would be to define global variables in
+# /etc/jail.conf, and have a config file of each jail in
+# /etc/jail.conf.d/somejail.conf; this will give you the ability to do
+# mv /etc/jail.conf.d/somejail.conf /etc/jail.conf.d/somejail.conf.dis
+# which will disable the jail.
+#
+# ==> CAREFUL! always disable/edit the jail when it's NOT running, otherwise your
+# cleanup commands might not work.
+#
+#
+# You may file this script in patch/diff format at https://reviews.freebsd.org/P561
+#
+# Thank you for testing, if you have any more feedback, please email me at
+# jailtest@freebsd.am ; suggestions and bug reports are very welcome.
+# -- antranigv
+
name="jail"
desc="Manage system jails"
rcvar="jail_enable"
@@ -455,12 +506,14 @@
_ALL)
command=$jail_program
rc_flags=$jail_flags
- command_args="-f $jail_conf -c"
+ command_args='-f - -c'
if ! checkyesno jail_parallel_start; then
command_args="$command_args -p1"
fi
_tmp=`mktemp -t jail` || exit 3
- if $command $rc_flags $command_args >> $_tmp 2>&1; then
+ if cat $jail_conf $jail_conf_dir/*.conf \
+ /etc/jail.*.conf 2>/dev/null | \
+ $command $rc_flags $command_args >> $_tmp 2>&1; then
$jail_jls jid name | while read _id _name; do
startmsg -n " $_name"
echo $_id > /var/run/jail_${_name}.id
@@ -485,10 +538,12 @@
eval rc_flags=\${jail_${_jv}_flags:-$jail_flags}
eval command=\${jail_${_jv}_program:-$jail_program}
- command_args="-i -f $_conf -c $_j"
+ command_args="-i -f - -c $_j"
(
_tmp=`mktemp -t jail_${_j}` || exit 3
- if $command $rc_flags $command_args \
+ if cat $jail_conf $_conf $jail_conf_dir/*.conf \
+ /etc/jail.*.conf 2>/dev/null | \
+ $command $rc_flags $command_args \
>> $_tmp 2>&1 </dev/null; then
startmsg -n " ${_hostname:-${_j}}"
_jid=$($jail_jls -j $_j jid)
@@ -513,9 +568,11 @@
eval rc_flags=\${jail_${_jv}_flags:-$jail_flags}
eval command=\${jail_${_jv}_program:-$jail_program}
- command_args="-i -f $_conf -c $_j"
+ command_args="-i -f - -c"
_tmp=`mktemp -t jail` || exit 3
- if $command $rc_flags $command_args \
+ if (cat $_conf $jail_conf $jail_conf_dir/*.conf \
+ /etc/jail.*.conf 2>/dev/null | \
+ $command $rc_flags $command_args $_j) \
>> $_tmp 2>&1 </dev/null; then
startmsg -n " ${_hostname:-${_j}}"
_jid=$($jail_jls -j $_j jid)
@@ -543,7 +600,7 @@
_ALL)
command=$jail_program
rc_flags=$jail_flags
- command_args="-f $jail_conf -r"
+ command_args='-f - -r'
if checkyesno jail_reverse_stop; then
$jail_jls name | tail -r
else
@@ -551,6 +608,8 @@
fi | while read _j; do
echo -n " $_j"
_tmp=`mktemp -t jail` || exit 3
+ cat $jail_conf $jail_conf_dir/*.conf \
+ /etc/jail.*.conf 2>/dev/null | \
$command $rc_flags $command_args $_j >> $_tmp 2>&1
if $jail_jls -j $_j > /dev/null 2>&1; then
cat $_tmp
@@ -574,7 +633,9 @@
eval command=\${jail_${_jv}_program:-$jail_program}
echo -n " ${_hostname:-${_j}}"
_tmp=`mktemp -t jail` || exit 3
- $command -q -f $_conf -r $_j >> $_tmp 2>&1
+ cat $_conf $jail_conf $jail_conf_dir/*.conf \
+ /etc/jail.*.conf 2>/dev/null | \
+ $command -q -f - -r $_j >> $_tmp 2>&1
if $jail_jls -j $_j > /dev/null 2>&1; then
cat $_tmp
else
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Sep 10, 6:58 AM (11 m, 27 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38634307
Default Alt Text
D38826.id118090.diff (4 KB)
Attached To
Mode
D38826: Fix multiple rc.d/jail and jail.conf.d issues
Attached
Detach File
Event Timeline
Log In to Comment