Building electron linux 发行版:已找到 SUID 沙箱助手二进制文件,但配置不正确

Building electron linux distro : The SUID sandbox helper binary was found, but is not configured correctly

我正在为 linux 生成电子发行版。 这就是应用程序的构建方式 这就是应用程序在 packge.json

中的构建方式
 "builderForLinx": "electron-packager --out linx64 --overwrite --platform linux --appname myApp --asar"  

此应用程序结构 myApp -> myApp(linux 可执行文件),mian.js,资源 -> myApp.asar

这给出了一个 linux 版本的电子包。但是我必须 运行 以下命令 运行 应用

sudo chmod +x ./myApp
sudo chown root chrome-sandbox
sudo chmod 4755 chrome-sandbox

实际上我是从 tfs build artifact 获取应用程序的,当我下载这个应用程序时,我想直接 运行 ./myApp.

这是我的 tfs 定义,我 运行 所有这些都在 bash,不是我的 agent/build 机器是 windows 的。

#!/bin/bash 
cd "$(Build.ArtifactStagingDirectory)/myApp" ; pwd
chown <<username>> chrome-sandbox
chmod 4755 chrome-sandbox

注意:$(Build.ArtifactStagingDirectory) 是指向工件目录的 tfs 变量。 当我 运行 应用程序直接在 linux 机器上时,我看到这个错误

The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /home/staff/kjeeva/licregsNew/v211/licensingclient/linx64/ClientSettings-asar/chrome-sandbox is owned by root and has mode 4755.

我不熟悉 linux 环境,对此有任何帮助或建议都会有很大帮助。

The SUID sandbox helper binary was found ... 似乎是 Linux 中关于电子框架的一个热点问题。您可以查看 this discussion 了解更多详情。

以下是该讨论中可用的解决方法:

1.chown 并像您所做的那样首先对文件进行 chmod。

sudo chown root chrome-sandbox
chmod 4755 chrome-sandbox

2.If 你得到一个应用程序图像,你可以 运行 直接用 --no-sandbox arguemnt

3.sysctl kernel.unprivileged_userns_clone=1enable unprivileged access.

您已经使用了#1,但您也可以查看#2/#3是否更适合您的场景。

This is my tfs definition, I run all these in bash, not my agent/build machines are windows ones.

由于您的部分代理是 Linux,其他代理是 Windows,我建议您可以使用 Conditions 来管理 bash 任务。您可以有两个不同的 bash tasks/steps,一个用于 Linux,另一个用于 Windows。然后将它们的条件设置为 运行 有条件地正确命令。像这样:

- task: Bash@3
  inputs:
    targetType: 'inline'
    script: |
      # Write commands here
      # ...
  displayName: 'Bash command for Linux'
  condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))

- task: Bash@3
  inputs:
    targetType: 'inline'
    script: |
      # Write commands here
      # ...
  displayName: 'Bash command for Windows'
  condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))

关于预定义变量Agent.OS,您可以查看this document