Skip to content

Commit 4d9ef79

Browse files
committed
feat(electron): refine Linux sandbox handling and format copy filter
Improve sandbox handling on Linux by detecting Snap, Flatpak, and AppImage environments and applying appropriate Chromium command-line switches: - If running in Snap or Flatpak, disable Chromium's sandbox (--no-sandbox) to avoid conflicts with the distribution's own sandboxing. - Otherwise (traditional packages and AppImage), disable the SUID sandbox and prefer the user namespace sandbox (--disable-setuid-sandbox). This avoids requiring a SUID chrome-sandbox binary and aligns with modern Linux best practices. Also adjust apps/electron-backend/src/main.ts to only apply these changes on Linux (process.platform === 'linux'). Minor formatting: expand the package.json copy "filter" array to a multiline style for readability.
1 parent 3925b36 commit 4d9ef79

File tree

4 files changed

+57
-18
lines changed

4 files changed

+57
-18
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# See http://help.github.com/ignore-files/ for more about ignoring files.
22

33
#compiled output
4-
/dist
5-
/build
4+
/dist
65
/tmp
76
/out-tsc
87
/app-builds

apps/electron-backend/src/main.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,25 @@ import SquirrelEvents from './app/events/squirrel.events';
1414
import StalkerEvents from './app/events/stalker.events';
1515
import XtreamEvents from './app/events/xtream.events';
1616

17-
// Detect if running in Snap or AppImage environment
18-
const isSnap = process.env.SNAP !== undefined;
19-
const isAppImage = process.env.APPIMAGE !== undefined;
17+
// Handle sandboxing for Linux
18+
if (process.platform === 'linux') {
19+
// Detect if running in Snap, Flatpak, or AppImage environment
20+
const isSnap = process.env.SNAP !== undefined;
21+
const isFlatpak = process.env.FLATPAK_ID !== undefined;
22+
const isAppImage = process.env.APPIMAGE !== undefined;
2023

21-
// Handle sandbox for Snap and AppImage
22-
if (isSnap || isAppImage) {
23-
// Disable GPU sandbox which often conflicts with snap/AppImage confinement
24-
//app.commandLine.appendSwitch('disable-gpu-sandbox');
25-
app.commandLine.appendSwitch('--no-sandbox');
24+
if (isSnap || isFlatpak || isAppImage) {
25+
// Snap and Flatpak provide their own sandboxing
26+
// AppImage is a portable format that often has issues with chrome-sandbox permissions
27+
// Disable Chromium's sandbox for these environments
28+
app.commandLine.appendSwitch('--no-sandbox');
29+
} else {
30+
// For traditional packages (deb, rpm, pacman):
31+
// Use user namespace sandbox instead of SUID sandbox
32+
// This doesn't require chrome-sandbox to have SUID permissions (chmod 4755)
33+
// and is the recommended approach for modern Linux systems
34+
app.commandLine.appendSwitch('--disable-setuid-sandbox');
35+
}
2636
}
2737

2838
app.setName('iptvnator');

build/linux-postinstall.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# Post-install script for IPTVnator .deb package
3+
# Sets proper permissions on chrome-sandbox to enable sandboxing
4+
5+
if [ -f "/opt/IPTVnator/chrome-sandbox" ]; then
6+
# Set owner to root and permissions to 4755 (SUID)
7+
chown root:root "/opt/IPTVnator/chrome-sandbox" 2>/dev/null || true
8+
chmod 4755 "/opt/IPTVnator/chrome-sandbox" 2>/dev/null || true
9+
fi
10+
11+
exit 0

package.json

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
{
3232
"from": "dist/apps/remote-control-web",
3333
"to": "remote-control-web",
34-
"filter": ["**/*"]
34+
"filter": [
35+
"**/*"
36+
]
3537
},
3638
"electron-backend/**/*",
3739
"web/**/*",
@@ -67,31 +69,48 @@
6769
"target": [
6870
{
6971
"target": "AppImage",
70-
"arch": ["x64", "armv7l", "arm64"]
72+
"arch": [
73+
"x64",
74+
"armv7l",
75+
"arm64"
76+
]
7177
},
7278
{
7379
"target": "deb",
74-
"arch": ["x64", "armv7l", "arm64"]
80+
"arch": [
81+
"x64",
82+
"armv7l",
83+
"arm64"
84+
]
7585
},
7686
{
7787
"target": "Snap",
78-
"arch": ["x64"]
88+
"arch": [
89+
"x64"
90+
]
7991
},
8092
{
8193
"target": "rpm",
82-
"arch": ["x64"]
94+
"arch": [
95+
"x64"
96+
]
8397
},
8498
{
8599
"target": "pacman",
86-
"arch": ["x64"]
100+
"arch": [
101+
"x64"
102+
]
87103
},
88104
{
89105
"target": "flatpak",
90-
"arch": ["x64"]
106+
"arch": [
107+
"x64"
108+
]
91109
}
92110
],
93111
"artifactName": "${name}-${version}-${os}-${arch}.${ext}",
94-
"icon": "apps/web/src/assets/icons"
112+
"icon": "apps/web/src/assets/icons",
113+
"afterInstall": "build/linux-postinstall.sh"
95114
},
96115
"win": {
97116
"compression": "maximum",

0 commit comments

Comments
 (0)