Commit 2c42cf9
fix(launcher-standard): move PID/log to XDG dirs (security: symlink-attack hardening)
The standard specified `/tmp/{app-name}-server.pid` and
`/tmp/{app-name}-server.log` as the required runtime paths. Predictable
names in a world-writable directory are a symlink-attack target on any
shared host: an attacker can pre-create `/tmp/<app>-server.pid`
containing their own PID, after which the launcher's `is_running()`
returns true and `stop_server()` will `kill <attacker-pid>` — DoS or
signal-handling abuse vector. Similar for log: clobber attacks via
pre-symlinked log file, or info-disclosure if logs contain anything
sensitive (the standard already warns "don't log sensitive information"
but trust-but-verify).
Fix: route both to XDG dirs with documented fallback ladders.
- **PID** → `${XDG_RUNTIME_DIR:-${TMPDIR:-/tmp}}/<app>-server.pid`.
`$XDG_RUNTIME_DIR` is mode 0700 and user-scoped per the XDG Base
Directory spec (Linux). `$TMPDIR` covers macOS / BSDs (typically
`/var/folders/.../T`, per-user). `/tmp` remains only as a last-resort
fallback for hosts that set neither (rare).
- **Log** → `${XDG_STATE_HOME:-$HOME/.local/state}/<app>/server.log`.
Per-user, survives reboot, not world-writable. The `<app>` subdir
isolates each launcher's logs.
Updates to both files in the same commit per the lock-step requirement:
- `launcher/launcher-standard.a2ml`: `[runtime].pid-file-pattern` and
`log-file-pattern` updated with fallback ladders; `[disinteg].preserve`
updated to reference the new log dir.
- `docs/UX-standards/launcher-standard.adoc`:
- Standard Launcher Template snippet updated with XDG paths plus
`mkdir -p "$LOG_DIR"` for the state-dir
- §What --disinteg removes / does not remove: paths updated
- Desktop File Standard Exec= example log-arg updated
- Calling Convention daemon-chain example updated
- Debugging Checklist now uses $LOG_FILE / $PID_FILE variable refs
- §Best Practices > Logging: lead bullet rewritten with rationale
- §Best Practices > Security: new lead bullets explaining the
symlink-attack vector and the XDG choice
- §Compliance Checklist: "Log to predictable location (/tmp/...)"
replaced with the XDG requirement
Remaining `/tmp/` mentions in the prose are in forbidden-patterns text
that explicitly tells readers NOT to use /tmp — intentional.
Bash-expansion ladder format (`${VAR:-${VAR2:-/literal}}`) matches the
shell-expansion style already used elsewhere in the a2ml (e.g.
`$HOME/.local/share/applications` in `[integration.linux]`).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 431adbb commit 2c42cf9
2 files changed
Lines changed: 33 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
281 | 286 | | |
282 | 287 | | |
283 | 288 | | |
284 | | - | |
| 289 | + | |
285 | 290 | | |
286 | 291 | | |
287 | 292 | | |
288 | 293 | | |
289 | 294 | | |
290 | | - | |
| 295 | + | |
291 | 296 | | |
292 | 297 | | |
293 | 298 | | |
| |||
316 | 321 | | |
317 | 322 | | |
318 | 323 | | |
319 | | - | |
| 324 | + | |
320 | 325 | | |
321 | 326 | | |
322 | 327 | | |
| |||
390 | 395 | | |
391 | 396 | | |
392 | 397 | | |
393 | | - | |
| 398 | + | |
394 | 399 | | |
395 | 400 | | |
396 | 401 | | |
| |||
478 | 483 | | |
479 | 484 | | |
480 | 485 | | |
481 | | - | |
| 486 | + | |
482 | 487 | | |
483 | 488 | | |
484 | | - | |
| 489 | + | |
485 | 490 | | |
486 | 491 | | |
487 | 492 | | |
| |||
529 | 534 | | |
530 | 535 | | |
531 | 536 | | |
532 | | - | |
| 537 | + | |
533 | 538 | | |
534 | 539 | | |
535 | 540 | | |
| |||
540 | 545 | | |
541 | 546 | | |
542 | 547 | | |
543 | | - | |
| 548 | + | |
| 549 | + | |
544 | 550 | | |
545 | 551 | | |
546 | 552 | | |
| |||
559 | 565 | | |
560 | 566 | | |
561 | 567 | | |
562 | | - | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
563 | 571 | | |
564 | 572 | | |
565 | 573 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
64 | 74 | | |
65 | 75 | | |
66 | 76 | | |
| |||
121 | 131 | | |
122 | 132 | | |
123 | 133 | | |
124 | | - | |
| 134 | + | |
125 | 135 | | |
126 | 136 | | |
127 | 137 | | |
| |||
0 commit comments