From 59483604de93a222713506c96aacbc3832daca58 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 16 Sep 2020 11:47:10 -0700 Subject: [PATCH] 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/ --- CMakeLists.txt | 1 + .../Application Support/Wireshark/ChmodBPF/ChmodBPF | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da1c19c070..ab49c673dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF b/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF index eaf160bf1b..1dc12e7a05 100755 --- a/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF +++ b/packaging/macosx/ChmodBPF/root/Library/Application Support/Wireshark/ChmodBPF/ChmodBPF @@ -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