Skip to content

Commit 92999c3

Browse files
authored
fix: setuid helper permission (microsoft#126798)
* ci: fix setuid helper binary permission * ci: allow privilege for CLONE_NEWPID | CLONE_NEWNET * ci: fix chrome-sandbox permission with rpm * ci: fix permissions on snap * ci: download electron earlier for arm builds
1 parent 70c2130 commit 92999c3

File tree

9 files changed

+29
-16
lines changed

9 files changed

+29
-16
lines changed

build/azure-pipelines/linux/product-build-linux.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,18 @@ steps:
129129
VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
130130
yarn npm-run-all -lp "electron $(VSCODE_ARCH)" "playwright-install"
131131
displayName: Download Electron and Playwright
132-
condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
132+
133+
- script: |
134+
set -e
135+
APP_ROOT=$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)
136+
ELECTRON_ROOT=.build/electron
137+
sudo chown root $APP_ROOT/chrome-sandbox
138+
sudo chown root $ELECTRON_ROOT/chrome-sandbox
139+
sudo chmod 4755 $APP_ROOT/chrome-sandbox
140+
sudo chmod 4755 $ELECTRON_ROOT/chrome-sandbox
141+
stat $APP_ROOT/chrome-sandbox
142+
stat $ELECTRON_ROOT/chrome-sandbox
143+
displayName: Change setuid helper binary permission
133144
134145
- script: |
135146
set -e
@@ -183,7 +194,7 @@ steps:
183194
- script: |
184195
set -e
185196
APP_PATH=$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)
186-
yarn smoketest-no-compile --build "$APP_PATH" --electronArgs="--disable-setuid-sandbox --disable-dev-shm-usage --use-gl=swiftshader"
197+
yarn smoketest-no-compile --build "$APP_PATH" --electronArgs="--disable-dev-shm-usage --use-gl=swiftshader"
187198
timeoutInMinutes: 5
188199
displayName: Run smoke tests (Electron)
189200
condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
@@ -192,15 +203,15 @@ steps:
192203
set -e
193204
APP_PATH=$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)
194205
VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/vscode-reh-linux-$(VSCODE_ARCH)" \
195-
yarn smoketest-no-compile --build "$APP_PATH" --remote --electronArgs="--disable-setuid-sandbox --disable-dev-shm-usage --use-gl=swiftshader"
206+
yarn smoketest-no-compile --build "$APP_PATH" --remote --electronArgs="--disable-dev-shm-usage --use-gl=swiftshader"
196207
timeoutInMinutes: 5
197208
displayName: Run smoke tests (Remote)
198209
condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
199210
200211
- script: |
201212
set -e
202213
VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/vscode-reh-web-linux-$(VSCODE_ARCH)" \
203-
yarn smoketest-no-compile --web --headless --electronArgs="--disable-setuid-sandbox --disable-dev-shm-usage --use-gl=swiftshader"
214+
yarn smoketest-no-compile --web --headless --electronArgs="--disable-dev-shm-usage --use-gl=swiftshader"
204215
timeoutInMinutes: 5
205216
displayName: Run smoke tests (Browser)
206217
condition: and(succeeded(), eq(variables['VSCODE_ARCH'], 'x64'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

build/azure-pipelines/product-build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ resources:
126126
- container: vscode-x64
127127
image: vscodehub.azurecr.io/vscode-linux-build-agent:bionic-x64
128128
endpoint: VSCodeHub
129-
options: --user 0:0
129+
options: --user 0:0 --cap-add SYS_ADMIN
130130
- container: vscode-arm64
131131
image: vscodehub.azurecr.io/vscode-linux-build-agent:stretch-arm64
132132
endpoint: VSCodeHub
133+
options: --user 0:0 --cap-add SYS_ADMIN
133134
- container: vscode-armhf
134135
image: vscodehub.azurecr.io/vscode-linux-build-agent:stretch-armhf
135136
endpoint: VSCodeHub
137+
options: --user 0:0 --cap-add SYS_ADMIN
136138
- container: snapcraft
137139
image: snapcore/snapcraft:stable
138140

build/lib/compilation.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ function createCompile(src, build, emitError) {
3737
const sourcemaps = require('gulp-sourcemaps');
3838
const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json');
3939
const overrideOptions = Object.assign(Object.assign({}, getTypeScriptCompilerOptions(src)), { inlineSources: Boolean(build) });
40-
if (!build) {
41-
overrideOptions.inlineSourceMap = true;
42-
}
40+
if (!build) {
41+
overrideOptions.inlineSourceMap = true;
42+
}
4343
const compilation = tsb.create(projectPath, overrideOptions, false, err => reporter(err));
4444
function pipeline(token) {
4545
const bom = require('gulp-bom');

resources/linux/rpm/code.spec.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ update-mime-database /usr/share/mime &> /dev/null || :
6565

6666
%files
6767
%defattr(-,root,root)
68+
%attr(4755, root, root) /usr/share/@@NAME@@/chrome-sandbox
6869

6970
/usr/share/@@NAME@@/
7071
/usr/share/applications/@@NAME@@.desktop

resources/linux/snap/snapcraft.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ parts:
2727
- gnome
2828
plugin: dump
2929
source: .
30+
override-build: |
31+
snapcraftctl build
32+
chmod 4755 $SNAPCRAFT_PART_INSTALL/usr/share/@@NAME@@/chrome-sandbox
3033
stage-packages:
3134
- ibus-gtk3
3235
- fcitx-frontend-gtk3

scripts/test-integration.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
66
ROOT=$(dirname $(dirname $(realpath "$0")))
77
else
88
ROOT=$(dirname $(dirname $(readlink -f $0)))
9-
# --disable-setuid-sandbox: setuid sandboxes requires root and is used in containers so we disable this
109
# --disable-dev-shm-usage --use-gl=swiftshader: when run on docker containers where size of /dev/shm
1110
# partition < 64MB which causes OOM failure for chromium compositor that uses the partition for shared memory
12-
LINUX_EXTRA_ARGS="--disable-setuid-sandbox --disable-dev-shm-usage --use-gl=swiftshader"
11+
LINUX_EXTRA_ARGS="--disable-dev-shm-usage --use-gl=swiftshader"
1312
fi
1413

1514
VSCODEUSERDATADIR=`mktemp -d 2>/dev/null`

scripts/test.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
66
ROOT=$(dirname $(dirname $(realpath "$0")))
77
else
88
ROOT=$(dirname $(dirname $(readlink -f $0)))
9-
# --disable-setuid-sandbox: setuid sandboxes requires root and is used in containers so we disable this
109
# --disable-dev-shm-usage --use-gl=swiftshader: when run on docker containers where size of /dev/shm
1110
# partition < 64MB which causes OOM failure for chromium compositor that uses the partition for shared memory
12-
LINUX_EXTRA_ARGS="--disable-setuid-sandbox --disable-dev-shm-usage --use-gl=swiftshader"
11+
LINUX_EXTRA_ARGS="--disable-dev-shm-usage --use-gl=swiftshader"
1312
fi
1413

1514
cd $ROOT

test/integration/browser/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ const height = 800;
3333
type BrowserType = 'chromium' | 'firefox' | 'webkit';
3434

3535
async function runTestsInBrowser(browserType: BrowserType, endpoint: url.UrlWithStringQuery, server: cp.ChildProcess): Promise<void> {
36-
const args = process.platform === 'linux' && browserType === 'chromium' ? ['--disable-setuid-sandbox'] : undefined; // setuid sandboxes requires root and is used in containers so we disable this to support our CI
37-
const browser = await playwright[browserType].launch({ headless: !Boolean(optimist.argv.debug), args });
36+
const browser = await playwright[browserType].launch({ headless: !Boolean(optimist.argv.debug) });
3837
const context = await browser.newContext();
3938
const page = await context.newPage();
4039
await page.setViewportSize({ width, height });

test/unit/browser/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ function consoleLogFn(msg) {
146146
}
147147

148148
async function runTestsInBrowser(testModules, browserType) {
149-
const args = process.platform === 'linux' && browserType === 'chromium' ? ['--disable-setuid-sandbox'] : undefined; // setuid sandboxes requires root and is used in containers so we disable this to support our CI
150-
const browser = await playwright[browserType].launch({ headless: !Boolean(argv.debug), args });
149+
const browser = await playwright[browserType].launch({ headless: !Boolean(argv.debug) });
151150
const context = await browser.newContext();
152151
const page = await context.newPage();
153152
const target = url.pathToFileURL(path.join(__dirname, 'renderer.html'));

0 commit comments

Comments
 (0)