Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

doctor: report a too-open restricted log even when it is then refused

Claude5bb72a0aa9b5
diff --git a/cli/beacon/internal/endpoint/diagnostics/logaccess.go b/cli/beacon/internal/endpoint/diagnostics/logaccess.go
index d3c5ba49..9657bbce 100644
--- a/cli/beacon/internal/endpoint/diagnostics/logaccess.go
+++ b/cli/beacon/internal/endpoint/diagnostics/logaccess.go
@@ -183,11 +183,17 @@ func ingestSocketPath(ingest localingest.Deliverer) string {
// checkRestrictedLogACL is checkRestrictedLogPermissions on Windows, where file modes say nothing:
// the directory and every file of the log family must grant nobody but SYSTEM, Administrators and
// the readers group (who may only read) anything at all. Run unelevated it cannot open the
-// directory, which is the restricted mode working.
+// directory, which is the restricted mode working, unless it found a problem before it was refused.
func checkRestrictedLogACL(path string) Check {
dir := filepath.Dir(path)
problems, err := restrictedLogProblems(path)
switch {
+ // Before the errors: an account that can read the directory's ACL but not open what is in it
+ // still found a directory too open, and that is the answer, not "as intended".
+ case len(problems) > 0:
+ return Check{Name: "runtime_log_permissions", Target: dir, Status: StatusFail, Severity: SeverityHigh,
+ Message: "the restricted log lets accounts outside SYSTEM, Administrators and the " + loggroup.Name + " group reach it: " + strings.Join(problems, "; "),
+ Evidence: "restricted_log_too_open", Action: repairSystemAction}
case errors.Is(err, fs.ErrPermission):
return Check{Name: "runtime_log_permissions", Target: dir, Status: StatusOK, Severity: SeverityInfo,
Message: "this account cannot open the restricted log, as intended; run doctor " + elevated() + " to inspect it",
@@ -198,10 +204,6 @@ func checkRestrictedLogACL(path string) Check {
case err != nil:
return Check{Name: "runtime_log_permissions", Target: dir, Status: StatusWarn, Severity: SeverityLow,
Message: "could not read the restricted log's ACL: " + err.Error(), Evidence: "acl_unreadable"}
- case len(problems) > 0:
- return Check{Name: "runtime_log_permissions", Target: dir, Status: StatusFail, Severity: SeverityHigh,
- Message: "the restricted log lets accounts outside SYSTEM, Administrators and the " + loggroup.Name + " group reach it: " + strings.Join(problems, "; "),
- Evidence: "restricted_log_too_open", Action: repairSystemAction}
}
return Check{Name: "runtime_log_permissions", Target: dir, Status: StatusOK, Severity: SeverityInfo,
Message: "restricted: only SYSTEM, Administrators and the " + loggroup.Name + " group can reach the log", Evidence: "restricted_acl"}
diff --git a/cli/beacon/internal/endpoint/diagnostics/logaccess_acl_test.go b/cli/beacon/internal/endpoint/diagnostics/logaccess_acl_test.go
index c26e82cc..0547ffb1 100644
--- a/cli/beacon/internal/endpoint/diagnostics/logaccess_acl_test.go
+++ b/cli/beacon/internal/endpoint/diagnostics/logaccess_acl_test.go
@@ -19,6 +19,7 @@ func TestCheckRestrictedLogACL(t *testing.T) {
{"as install leaves it", nil, nil, StatusOK, "restricted_acl"},
{"a leftover grant", []string{`runtime.jsonl: grants S-1-5-32-545 access (0x1200a9)`}, nil, StatusFail, "restricted_log_too_open"},
{"run without elevation", nil, &fs.PathError{Op: "open", Path: "logs", Err: fs.ErrPermission}, StatusOK, "restricted_log_not_readable_by_caller"},
+ {"too open, then refused", []string{`logs: grants S-1-5-32-545 access (0x120089)`}, &fs.PathError{Op: "open", Path: "logs", Err: fs.ErrPermission}, StatusFail, "restricted_log_too_open"},
{"no directory", nil, &fs.PathError{Op: "open", Path: "logs", Err: fs.ErrNotExist}, StatusFail, "log_dir_missing"},
{"the readers group is gone", nil, errors.New("the beacon-log group does not exist"), StatusWarn, "acl_unreadable"},
}