Skip to content

Commit 6fb3ba5

Browse files
lawliet89bestander
authored andcommitted
Fix User Namespace issues with untaring (#2898)
* removed entry.props.uid=0 for root after we switched from node-tar to tar-fs * removed root condition from tar extraction * Set UID and GID to zero when user is root * Add test to Circles CI and just set chown to false * Change test script * Fix sudo test
1 parent 664b6a4 commit 6fb3ba5

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

__tests__/commands/install/integration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function mockConstants(base: Config, mocks: Object, cb: (config: Config) =
2929
// the Yarn environment.
3030

3131
const opts = {};
32-
32+
3333
opts.binLinks = base.binLinks;
3434
opts.cwd = base.cwd;
3535
opts.globalFolder = base.globalFolder;

__tests__/commands/pack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export async function getFilesFromArchive(source, destination): Promise<Array<st
8787
strip: 1,
8888
dmode: 0o555, // all dirs should be readable
8989
fmode: 0o444, // all files should be readable
90+
chown: false, // don't chown. just leave as it is
9091
}))
9192
.on('finish', resolve)
9293
.on('error', reject);

circle.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ test:
3434
- yarn build-dist
3535
- node ./scripts/build-webpack.js
3636
- ./scripts/build-deb.sh
37+
# Test that installing as root works and that it also works
38+
# behind a user namespace which Circle CI tests are run under
39+
- sudo env "PATH=$PATH" bin/yarn install --force
3740

3841
deployment:
3942
release:

src/fetchers/git-fetcher.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default class GitFetcher extends BaseFetcher {
3737
const untarStream = tarFs.extract(this.dest, {
3838
dmode: 0o555, // all dirs should be readable
3939
fmode: 0o444, // all files should be readable
40+
chown: false, // don't chown. just leave as it is
4041
});
4142

4243
const hashStream = new crypto.HashStream();

src/fetchers/tarball-fetcher.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import * as constants from '../constants.js';
88
import * as crypto from '../util/crypto.js';
99
import BaseFetcher from './base-fetcher.js';
1010
import * as fsUtil from '../util/fs.js';
11-
import ROOT_USER from '../util/root-user.js';
1211

1312
const invariant = require('invariant');
1413
const path = require('path');
@@ -82,17 +81,12 @@ export default class TarballFetcher extends BaseFetcher {
8281
strip: 1,
8382
dmode: 0o555, // all dirs should be readable
8483
fmode: 0o444, // all files should be readable
84+
chown: false, // don't chown. just leave as it is
8585
});
8686

8787
extractorStream
8888
.pipe(untarStream)
8989
.on('error', reject)
90-
.on('entry', (entry: Object) => {
91-
if (ROOT_USER) {
92-
entry.props.uid = entry.uid = 0;
93-
entry.props.gid = entry.gid = 0;
94-
}
95-
})
9690
.on('finish', () => {
9791
const expectHash = this.hash;
9892
const actualHash = validateStream.getHash();

0 commit comments

Comments
 (0)