strawberry/scripts/strawberry.service
trvon fb6b905860
Some checks failed
Build and Test / build (debug, clang) (push) Has been cancelled
Build and Test / build (debug, gcc) (push) Has been cancelled
Build and Test / build (release, clang) (push) Has been cancelled
Build and Test / build (release, gcc) (push) Has been cancelled
Build and Test / docker (push) Has been cancelled
CLI: yams-style commands, with doctor and doctor fix
strawberry [--config PATH] [--json] <command> [<subcommand>] [args] [--flags]

status, doctor, doctor fix <action>, daemon run, findings list/show/
correlate, process search/trace/trace-node/suspend/resume/kill, scan
file/processes/memory, rules reload/update/check/fetch, policy show/set,
opensnitch enable-checksums, store verify/compact, replay, demo seed,
help [command], version.

One table in src/cli_commands.cpp defines each command (words,
positionals, flags, help) and how it maps onto the existing flag form,
which main() still parses; help is generated from the same table.
Unknown options and wrong arity print the command's usage. Process
actions validate node ids before building their JSON payload.

The older flag form (strawberry --status, strawberry <config>) still
works. The systemd units now run `strawberry daemon run --config ...` and
`strawberry rules fetch --config ...`. README, AGENTS.md and the
false-positive guide use the command form.

doctor renders the daemon's checks with their fixes; doctor fix runs a
maintenance action (with --dry-run). Against an older daemon the CLI says
to reinstall rather than "unknown command". replay explains that
telemetry is root-only instead of reporting zeros, and keeps config
output out of --json.

tests/test_cli.cpp: translations, flag-form passthrough, errors, help.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 09:32:02 -06:00

82 lines
3.1 KiB
Desktop File

[Unit]
Description=Strawberry Security Scanner
Documentation=https://github.com/trvon/strawberry
After=local-fs.target
[Service]
Type=simple
ExecStart=/usr/local/bin/strawberry daemon run --config /etc/strawberry/strawberry.conf
Environment=XDG_DATA_HOME=/var/lib
Environment=STRAWBERRY_BPF_OBJECT=/usr/local/share/strawberry/process_monitor.bpf.o
Restart=on-failure
RestartSec=10
StandardOutput=journal
StandardError=journal
# Runs as root but keeps only the capabilities it needs:
# CAP_BPF + CAP_PERFMON load and attach the exec tracepoints
# CAP_SYS_RESOURCE raise RLIMIT_MEMLOCK for BPF maps on older kernels
# CAP_SYS_PTRACE read /proc/<pid>/exe and cmdline of every process
# CAP_DAC_READ_SEARCH read any executable image for hashing/YARA
# CAP_SYS_ADMIN fanotify permission events (execution prevention)
# CAP_KILL suspend/kill a process from the app (response)
User=root
# Files and the control socket are group-owned by `strawberry`: members can
# read findings (read-only) and use the desktop app's controls.
Group=strawberry
CapabilityBoundingSet=CAP_BPF CAP_PERFMON CAP_SYS_RESOURCE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_SYS_ADMIN CAP_KILL
AmbientCapabilities=CAP_BPF CAP_PERFMON CAP_SYS_RESOURCE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_SYS_ADMIN CAP_KILL
NoNewPrivileges=true
# Filesystem: read-only view of the host, writable state dir only.
# /home and /tmp stay visible (read-only) on purpose: malware is commonly
# dropped and run from there, and the scanner must be able to read it.
ProtectSystem=strict
ProtectHome=read-only
PrivateTmp=false
StateDirectory=strawberry
StateDirectoryMode=0750
# OpenSnitch integration: Strawberry writes only strawberry-*.json rules here
# (ignored if OpenSnitch is not installed).
ReadWritePaths=-/etc/opensnitchd/rules
RuntimeDirectory=strawberry
RuntimeDirectoryMode=0750
UMask=0027
ProtectKernelModules=true
ProtectKernelLogs=true
ProtectControlGroups=true
ProtectClock=true
ProtectHostname=true
RestrictRealtime=true
RestrictSUIDSGID=true
RestrictNamespaces=true
LockPersonality=true
MemoryDenyWriteExecute=true
PrivateNetwork=true
RestrictAddressFamilies=AF_UNIX
SystemCallArchitectures=native
SystemCallFilter=@system-service bpf perf_event_open fanotify_init fanotify_mark
SystemCallErrorNumber=EPERM
LimitNOFILE=65536
# Resource limits (scan_profile=balanced). The daemon also paces itself (see
# the resource governor); these are the kernel-enforced backstop so a scan can
# never take the desktop down. For another profile: `systemctl edit strawberry`.
# efficient: CPUWeight=20 IOWeight=20 MemoryHigh=384M MemoryMax=768M
# aggressive: CPUWeight=100 IOWeight=100 MemoryHigh=1536M MemoryMax=3G
CPUWeight=50
IOWeight=50
MemoryHigh=768M
MemoryMax=1536M
TasksMax=64
# Prefer reclaiming elsewhere before killing the scanner; MemoryMax still bounds it.
OOMScoreAdjust=-100
# Never core-dump: the dump helper is an exec, and execs wait on this daemon's
# fanotify permission events (2026-10-25 freeze). The daemon also marks itself
# non-dumpable and releases those events first on any fatal error.
LimitCORE=0
[Install]
WantedBy=multi-user.target