无痕溜年
uos^1
发表于2025-01-03 03:18linux: {
executableArgs: ["--no-sandbox"],
}
回复点赞0只看作者
linux: {
executableArgs: ["--no-sandbox"],
}
linux: {
executableArgs: ["--no-sandbox"],
}
谢谢回复,请问这个设置在哪里?我用的Electron Forge打包的,目前临时解决办法就是在桌面创建.desktop文件,然后在Exec的命令行中增加--no-sandbox参数。
在packagerConfig的api文档里貌似没找到
https://electron.github.io/packager/main/interfaces/Options.html
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
module.exports = {
packagerConfig: {
asar: true,
extraResource: [ "./conf/" ],
icon: './icon/Messenger'
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-deb',
config: {
options: {
icon: './icon/Messenger.png'
}
},
},
{
name: '@electron-forge/maker-rpm',
config: {
options: {
icon: './icon/Messenger.png'
}
},
},
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
没找到forge有类似的命令,项目改用electron-build组件了,等到了linux上打包测试一下再说,谢谢。
linux: {
executableArgs: ["--no-sandbox"],
}
研究了一下在electron-builder.yml里配置后的效果,其实就是在安装包安装后自动生成的启动器目录/usr/share/applications的.desktop文件里,在EXEC命令行后自动帮你加上--no-sandbox,直接执行应用该报还是报。
我看其他地方讨论是说Ubuntu新版本加了一个AppArmor的服务,限制了chrome-sandbox的权限,在/etc/apparmor.d中手动增加应用的配置文件,AppArmor服务我在UOS里没找到,想问下统信是否有类似的服务?
abi <abi/4.0>,
include <tunables/global>
profile ungoogled-chromium /usr/local/bin/ungoogled-chromium flags=(unconfined) {
userns,
include if exists <local/ungoogled-chromium>
}
光荣榜
打造操作系统创新生态
关注微信公众号
技术服务
操作系统:UOS(专业版1070),运行在vmware workstation pro 17
开发环境:VSCode + Electron 31.7.6 + ForgetCLI
问题:程序编译后,使用npm run start报错:node_module下chrome-sandbox需要root授权,并设置权限为4577,打包后在命令行运行也是同样报错。
我在网上查找了几天后,解决方案貌似有两种:
1:开启开发者模式,设置chrome-sandbox权限
这个不太可行,因为没法后续给每个用户设置
2:使用命令行启动应用,增加--no-sandbox参数
这个试过后可以启动,我考虑可以在deb安装后的.desktop文件中,增加Exec=xxx --no-sandbox,不过这个文件每台机器去修改也不太现实,是否可以在编译打包时指定Exec的命令行内容
最后我想问是否有正常的开发路径,可以让chrome-sandbox执行在沙盒模式,并且不需要到客户机单独设置,是否申请开发者证书,用系统应用商店分发安装的应用就没有这个问题