Skip to content

Commit

Permalink
functions.sh: Also check for -c support in 'stat' before using
Browse files Browse the repository at this point in the history
Turns out it's not enough to check for the presence of the 'stat' binary;
OpenWrt also by default compiles it without support for the -c option. So
add a check for the option as well and bail out if it doesn't work.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
  • Loading branch information
tohojo committed Nov 6, 2022
1 parent d22bfa8 commit 5413154
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ check_state_dir() {
exit 1
fi

# OpenWrt doesn't have stat; for now just skip the remaining tests if it's
# not available
command -v stat >/dev/null 2>&1 || return 0
# OpenWrt doesn't have stat by default, and if it does have it, stat is
# usually built without support for the -c parameter. Check for these and
# skip the remaining tests if we don't have a usable 'stat' binary.
(command -v stat && stat -c '%a' /) >/dev/null 2>&1 || return 0

PERM="0$(stat -L -c '%a' "${SQM_STATE_DIR}")"
if [ "$((PERM & 0002))" -ne 0 ]; then
Expand Down

0 comments on commit 5413154

Please sign in to comment.