Skip to content

Commit 2acdf65

Browse files
authored
fix(linux): Don't setuid chrome-sandbox when not required (#8368)
This is not necessary in many environments, so we now test for whether this is required and then enable it only when necessary.
1 parent c653ebb commit 2acdf65

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

.changeset/purple-terms-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
fix: don't setuid chrome-sandbox when not required

packages/app-builder-lib/templates/linux/after-install.tpl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ else
1010
ln -sf '/opt/${sanitizedProductName}/${executable}' '/usr/bin/${executable}'
1111
fi
1212

13-
# SUID chrome-sandbox for Electron 5+
14-
chmod 4755 '/opt/${sanitizedProductName}/chrome-sandbox' || true
13+
# Check if user namespaces are supported by the kernel and working with a quick test:
14+
if ! { [[ -L /proc/self/ns/user ]] && unshare --user true; }; then
15+
# Use SUID chrome-sandbox only on systems without user namespaces:
16+
chmod 4755 '/opt/${sanitizedProductName}/chrome-sandbox' || true
17+
else
18+
chmod 0755 '/opt/${sanitizedProductName}/chrome-sandbox' || true
19+
fi
1520

1621
if hash update-mime-database 2>/dev/null; then
1722
update-mime-database /usr/share/mime || true

test/snapshots/linux/debTest.js.snap

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,13 @@ else
530530
ln -sf '/opt/foo/Boo' '/usr/bin/Boo'
531531
fi
532532
533-
# SUID chrome-sandbox for Electron 5+
534-
chmod 4755 '/opt/foo/chrome-sandbox' || true
533+
# Check if user namespaces are supported by the kernel and working with a quick test:
534+
if ! { [[ -L /proc/self/ns/user ]] && unshare --user true; }; then
535+
# Use SUID chrome-sandbox only on systems without user namespaces:
536+
chmod 4755 '/opt/foo/chrome-sandbox' || true
537+
else
538+
chmod 0755 '/opt/foo/chrome-sandbox' || true
539+
fi
535540
536541
if hash update-mime-database 2>/dev/null; then
537542
update-mime-database /usr/share/mime || true

0 commit comments

Comments
 (0)