mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 11:24:00 +00:00
fix: spawn Apple /bin/chmod by absolute path when hardening credentials
The macOS credential hardener strips ACLs with `chmod -N`, spawning `chmod` by bare name. On machines where Nix home-manager or Homebrew coreutils sit ahead of /bin on PATH, that resolves to GNU chmod, which has no `-N` flag and exits non-zero. The hardener treated that as a failure and refused every save from the Provider Settings panel with "could not restrict the credential file to your account; nothing was saved". Spawn /bin/chmod by absolute path instead, matching how the Windows branch already resolves its native tools without consulting PATH, and add a regression test that pins the absolute path.
This commit is contained in:
1 parent
0d41b6be54
commit
2a47bdb8e7
2 files changed
+20
-1
No files matched your search
@@ -123,7 +123,11 @@ export function hardenCredentialFile(
|
|||||||
if (platform !== 'win32') {
|
if (platform !== 'win32') {
|
||||||
try {
|
try {
|
||||||
if (platform === 'darwin') {
|
if (platform === 'darwin') {
|
||||||
const aclRemoval = spawn('chmod', ['-N', filepath], {
|
// `-N` (strip the ACL) is Apple-only. Spawn /bin/chmod by absolute
|
||||||
|
// path, never by name: a Nix/Homebrew coreutils profile puts GNU chmod
|
||||||
|
// first on PATH, and GNU chmod rejects `-N` — which read as a
|
||||||
|
// hardening failure and refused every save on such machines.
|
||||||
|
const aclRemoval = spawn('/bin/chmod', ['-N', filepath], {
|
||||||
stdio: 'ignore',
|
stdio: 'ignore',
|
||||||
});
|
});
|
||||||
if (!commandCompletedSuccessfully(aclRemoval)) return false;
|
if (!commandCompletedSuccessfully(aclRemoval)) return false;
|
||||||
|
|||||||
@@ -55,6 +55,21 @@ test('macOS ACL removal failure stops before chmod and fails closed', () => {
|
|||||||
assert.deepEqual(fileSystem.calls, [], 'mode bits must not disguise an ACL-removal failure');
|
assert.deepEqual(fileSystem.calls, [], 'mode bits must not disguise an ACL-removal failure');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('macOS ACL removal spawns Apple /bin/chmod by absolute path, not via PATH', () => {
|
||||||
|
const spawned = [];
|
||||||
|
hardenCredentialFile(FILE, {
|
||||||
|
platform: 'darwin',
|
||||||
|
fileSystem: fileSystemWithMode(0o100600),
|
||||||
|
spawn(command, args) {
|
||||||
|
spawned.push([command, args]);
|
||||||
|
return { status: 0, signal: null };
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// A coreutils-first PATH (Nix home-manager, Homebrew) resolves bare `chmod`
|
||||||
|
// to GNU chmod, which has no `-N` and would fail every save.
|
||||||
|
assert.deepEqual(spawned, [['/bin/chmod', ['-N', FILE]]]);
|
||||||
|
});
|
||||||
|
|
||||||
test('POSIX hardening verifies the resulting 0600 mode', () => {
|
test('POSIX hardening verifies the resulting 0600 mode', () => {
|
||||||
const goodFs = fileSystemWithMode(0o100600);
|
const goodFs = fileSystemWithMode(0o100600);
|
||||||
assert.equal(hardenCredentialFile(FILE, {
|
assert.equal(hardenCredentialFile(FILE, {
|
||||||
|
|||||||
Reference in new issue
Block a user