mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 19:41:20 -05:00
aece2e7e16
* fix(process): revalidate ownership before signaling * fix(process): retain cleanup ownership until completion * fix(process): keep omitted live descendants unresolved A non-empty process table that omits a retained live PID cannot authorize a signal or certify cleanup. An empty table can still describe a token-verified owner. * fix(process): read omitted Darwin run tokens by PID A live identity that ps omitted was still validated through Darwin environment(), which rejects any PID absent from a second process table. Ask the native reader for that PID directly so the launch token can bind. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { matchesOwnedProcessCommand } from "./ProcessCommandIdentity.js";
|
|
import type {
|
|
OwnedProcessGroup,
|
|
ProcessTableEntry,
|
|
} from "./ProcessOwnership.js";
|
|
|
|
/** Compare a live launcher against the identity committed at process launch. */
|
|
export const launcherIdentityFailure = (
|
|
launcher: Pick<ProcessTableEntry, "parentPid" | "processGroupId"> & {
|
|
readonly command?: string;
|
|
},
|
|
ownership: OwnedProcessGroup,
|
|
): string | null => {
|
|
if (launcher.processGroupId !== ownership.processGroupId)
|
|
return "owned launcher process-group identity did not match";
|
|
if (
|
|
ownership.expectedParentPid !== undefined &&
|
|
launcher.parentPid !== ownership.expectedParentPid
|
|
)
|
|
return "owned launcher parent identity did not match";
|
|
if (ownership.expectedCommand !== undefined) {
|
|
if (launcher.command === undefined)
|
|
return "owned launcher command identity could not be verified";
|
|
if (
|
|
!matchesOwnedProcessCommand(launcher.command, ownership.expectedCommand)
|
|
)
|
|
return `owned launcher command identity did not match (observed=${launcher.command}; expected=${ownership.expectedCommand})`;
|
|
}
|
|
return null;
|
|
};
|