packaging/macos/ holds the ES entitlement and two LaunchDaemons: the scanner (root, group strawberry, umask 027, XDG_DATA_HOME=/var/db so evidence lands in /var/db/strawberry) and the rule updater (daily, and on feeds/update-requested like strawberry-update.path). scripts/macos_install.sh creates the group with dseditgroup, the config (/run paths moved to /var/run), state directories, signs the binary with the entitlement and bootstraps both jobs. make macos-sign (IDENTITY=- ad hoc, or a Developer ID), make macos-install, and make macos-live-tests (signs and runs macos_es_live under sudo). An ad hoc signature carries the ES entitlement only with SIP disabled; the install script says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
3.9 KiB
Bash
Executable file
97 lines
3.9 KiB
Bash
Executable file
#!/bin/bash
|
|
# macOS installation (counterpart of scripts/install.sh). Run as root from
|
|
# the repository root after `make build`.
|
|
#
|
|
# Endpoint Security needs, at run time:
|
|
# 1. root (the launchd job runs as root);
|
|
# 2. the com.apple.developer.endpoint-security.client entitlement: either a
|
|
# Developer ID signature Apple approved for it (SIGN_IDENTITY=...), or an
|
|
# ad hoc signature (the default) on a Mac with SIP disabled;
|
|
# 3. Full Disk Access for /usr/local/bin/strawberry (System Settings >
|
|
# Privacy & Security > Full Disk Access).
|
|
# Without them the daemon still runs: libproc polling for process events,
|
|
# exec prevention and file watching report "unavailable" in --status.
|
|
|
|
set -euo pipefail
|
|
|
|
if [ "$(uname -s)" != "Darwin" ]; then
|
|
echo "macos_install.sh is for macOS; use scripts/install.sh on Linux" >&2
|
|
exit 1
|
|
fi
|
|
if [ "$EUID" -ne 0 ]; then
|
|
echo "Please run as root (sudo)" >&2
|
|
exit 1
|
|
fi
|
|
if [ ! -x builddir/src/strawberry ]; then
|
|
echo "Error: builddir/src/strawberry not found; build first (make build)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
SIGN_IDENTITY="${SIGN_IDENTITY:--}"
|
|
PREFIX=/usr/local
|
|
STATE=/var/db/strawberry
|
|
DAEMONS=/Library/LaunchDaemons
|
|
|
|
echo "=== Strawberry Security Scanner installation (macOS) ==="
|
|
|
|
# Access group: members can read findings and use the app's controls.
|
|
if ! dscl . -read /Groups/strawberry >/dev/null 2>&1; then
|
|
echo "Creating 'strawberry' group..."
|
|
dseditgroup -o create -r "Strawberry scanner" strawberry
|
|
fi
|
|
|
|
echo "Creating directories..."
|
|
install -d -m 0755 /etc/strawberry
|
|
install -d -m 0700 /etc/strawberry/rules
|
|
install -d -m 0750 -g strawberry "$STATE" "$STATE/feeds"
|
|
install -d -m 0750 -g strawberry /var/run/strawberry
|
|
|
|
if [ -f /etc/strawberry/strawberry.conf ]; then
|
|
echo " keeping existing /etc/strawberry/strawberry.conf"
|
|
else
|
|
# macOS has no /run; everything else in the default config applies.
|
|
sed -e 's#^pid_file=/run/#pid_file=/var/run/#' \
|
|
-e 's#^control_socket_path=/run/#control_socket_path=/var/run/#' \
|
|
-e 's#^enable_bpf_monitoring=true#enable_bpf_monitoring=false#' \
|
|
config/strawberry.conf > /etc/strawberry/strawberry.conf
|
|
chmod 0644 /etc/strawberry/strawberry.conf
|
|
fi
|
|
[ -f config/example_rules.yar ] && install -m 0600 config/example_rules.yar /etc/strawberry/rules/example_rules.yar
|
|
|
|
echo "Installing binaries..."
|
|
install -d -m 0755 "$PREFIX/bin"
|
|
install -m 0755 builddir/src/strawberry "$PREFIX/bin/strawberry"
|
|
codesign --force --options runtime --entitlements packaging/macos/strawberry.entitlements \
|
|
--sign "$SIGN_IDENTITY" "$PREFIX/bin/strawberry"
|
|
if [ -x builddir/mcp/strawberry-mcp ]; then
|
|
install -m 0755 builddir/mcp/strawberry-mcp "$PREFIX/bin/strawberry-mcp"
|
|
fi
|
|
if [ -x builddir/app/strawberry-tray ]; then
|
|
install -m 0755 builddir/app/strawberry-tray "$PREFIX/bin/strawberry-tray"
|
|
fi
|
|
|
|
echo "Installing launchd jobs..."
|
|
for job in com.strawberry.daemon com.strawberry.update; do
|
|
install -m 0644 -o root -g wheel "packaging/macos/$job.plist" "$DAEMONS/$job.plist"
|
|
launchctl bootout "system/$job" 2>/dev/null || true
|
|
launchctl bootstrap system "$DAEMONS/$job.plist"
|
|
done
|
|
|
|
if [ "$SIGN_IDENTITY" = "-" ] && csrutil status 2>/dev/null | grep -q enabled; then
|
|
echo
|
|
echo "Note: ad hoc signature with SIP enabled: Endpoint Security will refuse the"
|
|
echo "entitlement, so the daemon uses libproc polling (detection only)."
|
|
echo "Use a Developer ID identity with the ES entitlement: SIGN_IDENTITY='Developer ID Application: ...'"
|
|
fi
|
|
echo
|
|
echo "Grant Full Disk Access to $PREFIX/bin/strawberry in System Settings, then:"
|
|
echo " sudo launchctl kickstart -k system/com.strawberry.daemon"
|
|
echo " strawberry --status"
|
|
|
|
if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != "root" ]; then
|
|
if dseditgroup -o checkmember -m "$SUDO_USER" strawberry >/dev/null 2>&1; then
|
|
echo "User '$SUDO_USER' is already in the strawberry group."
|
|
else
|
|
echo "To use the desktop app: sudo dseditgroup -o edit -a $SUDO_USER -t user strawberry"
|
|
fi
|
|
fi
|