Skip to content

Conversation

kraken-jim
Copy link

@kraken-jim kraken-jim commented Sep 3, 2025

Specifiying an empty string as the argument to "-e" will cause this version of jail(8) to output NUL-terminated lines, to make string quoting unambiguous. The NUL-terminated lines are the exact verbatim values of the variables defined in jail.conf(5). man page jail(8) is also updated to reflect the change in behavior.

specifiying an empty string as the argument to "-e".  Update man page to
reflect the change in behavior.
Copy link

github-actions bot commented Sep 3, 2025

Thank you for taking the time to contribute to FreeBSD!
There is an issue that needs to be fixed:

Please review CONTRIBUTING.md, then update and push your branch again.

@kraken-jim
Copy link
Author

Sample output scenarios:

# cat /etc/jail.conf.d/test.conf 
test {
    host.hostname = "test.example.edu";
    ip4.addr  = "vlan3|192.168.1.50/32";
    ip4.addr += "private|192.168.1.95-99/32";

    allow.raw_sockets   = 1;

    mount  = "/filesystem-a   $path/mnt/a nullfs  ro  0   0";
    mount += "/filesystem-b   $path/mnt/b nullfs  ro  0   0";
    mount += "/filesystem-c   $path/mnt/c nullfs  ro  0   0";
    mount += "/filesystem-d   $path/mnt/d nullfs  ro  0   0";
    mount += "/filesystem-e   $path/mnt/e nullfs  ro  0   0";
}

Existing behavior:

# jail.old -e $'\n'; jail.old -e $'\n' | sha256sum
name=test
exec.start="/bin/sh /etc/rc"
exec.stop="/bin/sh /etc/rc.shutdown"
exec.consolelog=/var/log/jail_test.log
host.hostname=test.example.edu
path=/jail/test
interface=private
linux.osname=FreeBSD
mount.devfs
ip4.addr=vlan3|192.168.1.50/32,private|192.168.1.95-99/32
allow.raw_sockets=1
mount="/filesystem-a    /jail/test/mnt/a    nullfs  ro  0   0","/filesystem-b   /jail/test/mnt/b    nullfs  ro  0   0","/filesystem-c    /jail/test/mnt/c    nullfs  ro  0   0","/filesystem-d   /jail/test/mnt/d    nullfs  ro  0   0","/filesystem-e   /jail/test/mnt/e nullfs  ro  0   0"
1078af124c2a887aed44377860543a96e656f6213e492430d646727c3beb8670  -

New behavior (unchanged):

# jail -e $'\n'; jail -e $'\n' | sha256sum
name=test
exec.start="/bin/sh /etc/rc"
exec.stop="/bin/sh /etc/rc.shutdown"
exec.consolelog=/var/log/jail_test.log
host.hostname=test.example.edu
path=/jail/test
interface=private
linux.osname=FreeBSD
mount.devfs
ip4.addr=vlan3|192.168.1.50/32,private|192.168.1.95-99/32
allow.raw_sockets=1
mount="/filesystem-a    /jail/test/mnt/a    nullfs  ro  0   0","/filesystem-b   /jail/test/mnt/b    nullfs  ro  0   0","/filesystem-c    /jail/test/mnt/c    nullfs  ro  0   0","/filesystem-d   /jail/test/mnt/d    nullfs  ro  0   0","/filesystem-e   /jail/test/mnt/e nullfs  ro  0   0"
1078af124c2a887aed44377860543a96e656f6213e492430d646727c3beb8670  -

New behavior (NUL-delimited):

# jail -e '' | xargs -0 -Ixx echo xx
name=test
exec.start=/bin/sh /etc/rc
exec.stop=/bin/sh /etc/rc.shutdown
exec.consolelog=/var/log/jail_test.log
host.hostname=test.example.edu
path=/jail/test
interface=private
linux.osname=FreeBSD
mount.devfs
ip4.addr=vlan3|192.168.1.50/32
private|192.168.1.95-99/32
allow.raw_sockets=1
mount=/filesystem-a /jail/test/mnt/a    nullfs  ro  0   0
/filesystem-b   /jail/test/mnt/b    nullfs  ro  0   0
/filesystem-c   /jail/test/mnt/c    nullfs  ro  0   0
/filesystem-d   /jail/test/mnt/d    nullfs  ro  0   0
/filesystem-e   /jail/test/mnt/e    nullfs  ro  0   0

# jail -e '' | hexdump -Cv
00000000  6e 61 6d 65 3d 74 65 73  74 00 65 78 65 63 2e 73  |name=test.exec.s|
00000010  74 61 72 74 3d 2f 62 69  6e 2f 73 68 20 2f 65 74  |tart=/bin/sh /et|
00000020  63 2f 72 63 00 65 78 65  63 2e 73 74 6f 70 3d 2f  |c/rc.exec.stop=/|
00000030  62 69 6e 2f 73 68 20 2f  65 74 63 2f 72 63 2e 73  |bin/sh /etc/rc.s|
00000040  68 75 74 64 6f 77 6e 00  65 78 65 63 2e 63 6f 6e  |hutdown.exec.con|
00000050  73 6f 6c 65 6c 6f 67 3d  2f 76 61 72 2f 6c 6f 67  |solelog=/var/log|
00000060  2f 6a 61 69 6c 5f 74 65  73 74 2e 6c 6f 67 00 68  |/jail_test.log.h|
00000070  6f 73 74 2e 68 6f 73 74  6e 61 6d 65 3d 74 65 73  |ost.hostname=tes|
00000080  74 2e 65 78 61 6d 70 6c  65 2e 65 64 75 00 70 61  |t.example.edu.pa|
00000090  74 68 3d 2f 6a 61 69 6c  2f 74 65 73 74 00 69 6e  |th=/jail/test.in|
000000a0  74 65 72 66 61 63 65 3d  70 72 69 76 61 74 65 00  |terface=private.|
000000b0  6c 69 6e 75 78 2e 6f 73  6e 61 6d 65 3d 46 72 65  |linux.osname=Fre|
000000c0  65 42 53 44 00 6d 6f 75  6e 74 2e 64 65 76 66 73  |eBSD.mount.devfs|
000000d0  00 69 70 34 2e 61 64 64  72 3d 76 6c 61 6e 33 7c  |.ip4.addr=vlan3||
000000e0  31 39 32 2e 31 36 38 2e  31 2e 35 30 2f 33 32 0a  |192.168.1.50/32.|
000000f0  70 72 69 76 61 74 65 7c  31 39 32 2e 31 36 38 2e  |private|192.168.|
00000100  31 2e 39 35 2d 39 39 2f  33 32 00 61 6c 6c 6f 77  |1.95-99/32.allow|
00000110  2e 72 61 77 5f 73 6f 63  6b 65 74 73 3d 31 00 6d  |.raw_sockets=1.m|
00000120  6f 75 6e 74 3d 2f 66 69  6c 65 73 79 73 74 65 6d  |ount=/filesystem|
00000130  2d 61 09 2f 6a 61 69 6c  2f 74 65 73 74 2f 6d 6e  |-a./jail/test/mn|
00000140  74 2f 61 09 6e 75 6c 6c  66 73 09 72 6f 09 30 09  |t/a.nullfs.ro.0.|
00000150  30 0a 2f 66 69 6c 65 73  79 73 74 65 6d 2d 62 09  |0./filesystem-b.|
00000160  2f 6a 61 69 6c 2f 74 65  73 74 2f 6d 6e 74 2f 62  |/jail/test/mnt/b|
00000170  09 6e 75 6c 6c 66 73 09  72 6f 09 30 09 30 0a 2f  |.nullfs.ro.0.0./|
00000180  66 69 6c 65 73 79 73 74  65 6d 2d 63 09 2f 6a 61  |filesystem-c./ja|
00000190  69 6c 2f 74 65 73 74 2f  6d 6e 74 2f 63 09 6e 75  |il/test/mnt/c.nu|
000001a0  6c 6c 66 73 09 72 6f 09  30 09 30 0a 2f 66 69 6c  |llfs.ro.0.0./fil|
000001b0  65 73 79 73 74 65 6d 2d  64 09 2f 6a 61 69 6c 2f  |esystem-d./jail/|
000001c0  74 65 73 74 2f 6d 6e 74  2f 64 09 6e 75 6c 6c 66  |test/mnt/d.nullf|
000001d0  73 09 72 6f 09 30 09 30  0a 2f 66 69 6c 65 73 79  |s.ro.0.0./filesy|
000001e0  73 74 65 6d 2d 65 09 2f  6a 61 69 6c 2f 74 65 73  |stem-e./jail/tes|
000001f0  74 2f 6d 6e 74 2f 65 09  6e 75 6c 6c 66 73 09 72  |t/mnt/e.nullfs.r|
00000200  6f 09 30 09 30 00 00                              |o.0.0..|
00000207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant