macOS: Switch ChmodBPF to zsh.

Switch the ChmodBPF script to /bin/zsh since it

- Has known behavior, unlike /bin/sh, which execs whatever
  /private/var/select/sh points to.

- Supports 'read -n 0' and other nice features.

- Is unlikely to be deprecated, since it was made the default shell in
  Catalina[1].

- Exists in older macOS releases, unlike dash[2].

Closes #16826.

[1]https://support.apple.com/en-us/HT208050
[2]https://scriptingosx.com/2020/06/about-bash-zsh-sh-and-dash-in-macos-catalina-and-beyond/
This commit is contained in:
Gerald Combs 2020-09-16 11:47:10 -07:00
parent 888a8178f5
commit 59483604de
2 changed files with 5 additions and 3 deletions

View File

@ -3474,6 +3474,7 @@ if(SHELLCHECK_EXECUTABLE)
COMMAND shellcheck --external-sources
image/stock_icons/svg-to-png.sh
packaging/appimage/AppRun
"packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF"
packaging/macosx/osx-app.sh.in
packaging/macosx/osx-dmg.sh.in
packaging/source/git-export-release.sh.in

View File

@ -1,4 +1,5 @@
#! /bin/sh
#! /bin/zsh
# shellcheck shell=bash
#
# Unfortunately, macOS's devfs is based on the old FreeBSD
@ -27,12 +28,12 @@ if [ "$FORCE_CREATE_BPF_MAX" -gt "$SYSCTL_MAX" ] ; then
FORCE_CREATE_BPF_MAX=$SYSCTL_MAX
fi
syslog -s -l notice "ChmodBPF: Forcing creation and setting permissions for /dev/bpf*"
syslog -s -l notice "ChmodBPF: Forcing creation and setting permissions for /dev/bpf0-$(( FORCE_CREATE_BPF_MAX - 1))"
CUR_DEV=0
while [ "$CUR_DEV" -lt "$FORCE_CREATE_BPF_MAX" ] ; do
# Try to do the minimum necessary to trigger the next device.
: < /dev/bpf$CUR_DEV > /dev/null 2>&1
read -r -n 0 < /dev/bpf$CUR_DEV > /dev/null 2>&1
CUR_DEV=$(( CUR_DEV + 1 ))
done