-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Do not drop perms in git when not root
Fix: npm/cli#476 PR-URL: #23 Credit: @isaacs Close: #23 Reviewed-by: @darcyclarke
- Loading branch information
Showing
2 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict' | ||
const t = require('tap') | ||
const { _mkOpts: mkOpts } = require('../lib/util/git.js') | ||
const getuid = process.getuid | ||
|
||
t.test('mkOpts sets perms when root', t => { | ||
t.teardown(() => { | ||
process.getuid = getuid | ||
}) | ||
process.getuid = () => 0 | ||
t.match(mkOpts({}, { uid: 1234, gid: 1234 }), { uid: 1234, gid: 1234 }) | ||
t.end() | ||
}) | ||
|
||
t.test('mkOpts does not set perms when not root', t => { | ||
t.teardown(() => { | ||
process.getuid = getuid | ||
}) | ||
process.getuid = () => 4321 | ||
t.match(mkOpts({}, { uid: 1234, gid: 1234 }), { uid: undefined, gid: undefined }) | ||
t.end() | ||
}) |