https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=284777
Bug ID: 284777 Summary: usr.sbin/periodic/etc/weekly/340.noid: unhandled newline parsing jail output Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: bin Assignee: b...@freebsd.org Reporter: ports.maintai...@evilphi.com Created attachment 257458 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=257458&action=edit fix jail output parsing in 340.noid I was getting this error in the periodic weekly email: Check for files with an unknown user or group: find: name=pkgbuild: unknown primary or operator That's from 340.noid, which appears to not handle jail -e output correctly when there is more than one jail and path is the last jail variable defined. The code in question: 28 sep=: 29 OIFS="$IFS" 30 IFS="$sep" 31 for param in $(jail -f "$jail_conf" -e "$sep" 2>/dev/null) 32 do 33 case "$param" in 34 path=*) 35 _p=${param#path=} 36 if [ -z "$_p" -o "$_p" = / ]; then 37 continue 38 fi 39 40 exclude="$exclude -path $_p -prune -or" [...] 47 rc=$(find -H ${weekly_noid_dirs:-/} \ 48 \( $exclude ! -fstype local -prune -or -name \* \) -and \ 49 \( -nogroup -o -nouser \) -print | sed 's/^/ /' | 50 tee /dev/stderr | wc -l) Adding 'echo "_p=$_p"' at line 39 and running 340.noid gives: # ./340.noid Check for files with an unknown user or group: _p=/jails/containers/nginx name=pkgbuild _p=/jails/containers/pkgbuild name=postgres _p=/jails/containers/postgres find: name=pkgbuild: unknown primary or operator This is because I have three jails on my system, and the output of that jail command is: # jail -f /etc/jail.conf -e ":" name=nginx:allow.raw_sockets:allow.sysvipc:exec.clean:exec.start="/bin/sh /etc/rc":exec.stop="/bin/sh /etc/rc.shutdown":host.hostname=nginx.amnesiac.local:ip4=inherit:ip6=inherit:mount.devfs:mount.fstab=/jails/etc/fstab.nginx:path=/jails/containers/nginx name=pkgbuild:allow.raw_sockets:allow.sysvipc:exec.clean:exec.start="/bin/sh /etc/rc":exec.stop="/bin/sh /etc/rc.shutdown":host.hostname=pkgbuild.amnesiac.local:ip4=inherit:ip6=inherit:mount.devfs:mount.fstab=/jails/etc/fstab.pkgbuild:path=/jails/containers/pkgbuild name=postgres:allow.raw_sockets:allow.sysvipc:exec.clean:exec.start="/bin/sh /etc/rc":exec.stop="/bin/sh /etc/rc.shutdown":host.hostname=postgres.amnesiac.local:ip4=inherit:ip6=inherit:mount.devfs:mount.fstab=/jails/etc/fstab.postgres:path=/jails/containers/postgres I'm not sure what the best fix would be, but inserting _p=${_p%$'\n'*} after line 35 appears to fix it. Discovered in 13.4-R, but 340.noid appears to be the same in -CURRENT. Patch against main attached. Workaround: This only happens if path is the last variable in a jail -e output line, which only happens if it's the last variable defined for a jail in /etc/jail.conf. This bug can be worked around by changing the order of variables in /etc/jail.conf so that path is not the last variable defined. -- You are receiving this mail because: You are the assignee for the bug.