https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=287615

--- Comment #7 from Jim Long <[email protected]> ---
I spent some more time last week to take a more holistic approach to the
problem and implemented NUL-terminated output in jail.c.  If an empty delimiter
is used with the "exhibit" option (i.e., jail -e '') then jail will perform no
quoting whatsoever, and produce output lines in the form of:

variable=unquoted data string<NUL>

After the final output line for a jail, one additional NUL is written to
indicate the end of that jail's output.  These NUL-delimited lines can be
conveniently read by, e.g., bash's readarray built-in, and a script can source
all the jail info conveniently and accurately, with data validation performed
by jail(8).

For example, a script can be written to read the output of  jail -e ""  and
produce (nearly) eval-able output such as:

# /root/bin/jail-info.sh all all 
name='aarch64'
exec.start='/bin/sh /etc/rc'
exec.stop='/bin/sh /etc/rc.shutdown'
exec.consolelog='/var/log/jail_aarch64.log'
host.hostname='aarch64.chem.wwu.edu'
path='/jail/aarch64'
interface='private'
linux.osname='FreeBSD'
persist=''
ip4.addr='private|192.168.1.95/32'
allow.raw_sockets='1'
allow.chflags='1'
name='mailman2'
exec.start='/bin/sh /etc/rc'
exec.stop='/bin/sh /etc/rc.shutdown'
exec.consolelog='/var/log/jail_mailman2.log'
host.hostname='listhost.wwu.edu'
path='/jail/mailman2'
interface='private'
linux.osname='FreeBSD'
persist=''
ip_hostname=''
allow.raw_sockets='1'
name='rocky'
exec.start=''
exec.stop=''
exec.consolelog='/var/log/jail_rocky.log'
host.hostname='rocky'
path='/jail/rocky'
interface='private'
linux.osname=$'Rocky Linux 9.6\n(Blue Onyx)'
allow.raw_sockets=''
exec.clean=''
persist=''
sysvmsg='inherit'
sysvsem='inherit'
sysvshm='inherit'
enforce_statfs='1'
allow.mount='1'
allow.mount.zfs='1'
devfs_ruleset='7'
ip4.addr='private|192.168.1.9/24'
mount.fstab='/etc/fstab.rocky'
name='webwork2'
exec.start='/bin/sh /etc/rc'
exec.stop='/bin/sh /etc/rc.shutdown'
exec.consolelog='/var/log/jail_webwork2.log'
host.hostname='webwork2.chem.wwu.edu'
path='/jail/webwork2'
interface='private'
linux.osname='FreeBSD'
persist=''
ip_hostname=''
allow.raw_sockets='1'

This in turn makes jail(8) configuration data easily accessible to system
administration scripts for operations and maintenance.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to