Skip to main content
← Back to list
01Issue
BugOpenExtensionsPublic
AssigneesNone

Relationships

#1655 @adam/cfgmgmt/directory: uses GNU stat -c, silently non-compliant on FreeBSD and macOS targets

Opened by josephholsten · 8/14/2026

Summary

@adam/cfgmgmt/directory uses stat -c '%F|%U|%G|%a' in its gather() function to read directory state on remote hosts. This is GNU coreutils syntax. BSD stat (FreeBSD, macOS) uses -f for format strings, not -c.

Impact

When the model targets a FreeBSD or macOS host, the stat command exits 0 but produces no output. The gather() function interprets this as "NOTFOUND" and returns exists: false. As a result:

  • check always reports non_compliant even when the directory exists
  • apply runs mkdir idempotently but subsequent check still reports non_compliant
  • No error is surfaced — the failure is silent

Reproduction

Configure a @adam/cfgmgmt/directory model against a FreeBSD host. Run check against a directory that exists. Result: status: non_compliant, current.exists: false.

Root cause

In directory.ts, the gather function:

const statResult = await execSudo(
  client,
  `stat -c '%F|%U|%G|%a' ${shellEscape(path)} 2>/dev/null || echo 'NOTFOUND'`,
  so,
);

On BSD, stat -c is an unknown option; the command fails and the || echo 'NOTFOUND' branch fires.

Fix

Use a POSIX-compatible alternative. Options:

  1. Detect platform and branch on stat syntax (stat -c on Linux, stat -f on BSD)
  2. Use ls -ld + awk which is POSIX and works on all platforms
  3. Document that @adam/cfgmgmt/directory requires GNU coreutils on the target host

Notes

Discovered during LIM-82 (lilwoods-corde) while managing directories on a FreeBSD 14 host. @adam/cfgmgmt/line and @adam/cfgmgmt/authorized_key use test -f, cat, and getent — all POSIX-compatible and working correctly on FreeBSD.

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED

Open

8/14/2026, 10:10:20 PM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.