在 EXEC 生成步骤失败...权限被拒绝

Sto*_*rch 14 linux permissions fedora exec systemd

我已经阅读了很多关于此的内容,但仍然不确定为什么这不起作用。据我所知,所有目录都有正确的权限,即使所有内容都是 777,我在尝试将此程序作为服务运行时仍然被拒绝。我试图作为伺服系统运行的程序称为 xTeVe。我尝试在所有不同的目录、用户下运行它,但似乎没有任何效果。

这是单元文件:

[Unit]
Description=XTeVe For Plex
After=network.target network-online.target

[Service]
ExecStart=/root/IPTV/xteve
user=root
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3

[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)

我知道这不应该以 root 身份运行,但这只是我尝试的最后一个用户

当我尝试启动服务时,我得到了这个:

14:20 xteve.service: Failed with result 'exit-code'.
14:02 xteve.service: Main process exited, code=exited, status=203/EXEC
14:02 xteve.service: Failed at step EXEC spawning /root/IPTV/xteve: Permission denied
14:02 xteve.service: Failed to execute command: Permission denied
14:02 Started XTeVe For Plex.
Run Code Online (Sandbox Code Playgroud)

这是文件权限:

[root@skynet IPTV]# ls -la
total 12084
drwxr-xr-x. 2 root root       19 Mar  6 13:58 .
dr-xr-x---. 5 root root      175 Mar  6 13:58 ..
-rwxr-xr-x. 1 root root 12370316 Mar  6 13:58 xteve
Run Code Online (Sandbox Code Playgroud)

结果file

[root@skynet IPTV]# file xteve
xteve: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, Go BuildID=lt4S9w02Ylf_MXsFeRkj/jdmwTx5YSsQSDaa6tfuz/vCzfZlCyl5qUEBD7IuD0/AEI-OmWm1iNuziWA7R0P, with debug_info, not stripped
Run Code Online (Sandbox Code Playgroud)

的输出cat audit.log | grep xteve

type=AVC msg=audit(1551898814.098:1342): avc:  denied  { execute } for pid=11002 comm="(xteve)" name="xteve" dev="dm-0" ino=30958 scontext=system_u:system_r:init_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0
type=SERVICE_STOP msg=audit(1551898814.100:1343): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=xteve comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'UID="root" AUID="unset"
type=SERVICE_START msg=audit(1551898814.420:1344): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=xteve comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset"
type=SERVICE_STOP msg=audit(1551898814.420:1345): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=xteve comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'UID="root" AUID="unset"
type=SERVICE_START msg=audit(1551898966.689:1385): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=xteve comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=?res=success'UID="root" AUID="unset"    
Run Code Online (Sandbox Code Playgroud)

我尝试过但没有奏效的事情:

systemd 在步骤 EXEC 生成脚本失败:权限被拒绝

systemd 自定义服务:在 EXEC 生成步骤失败……权限被拒绝

即使具有适当的组权限,“在生成 EXEC 步骤时失败”

Mic*_*ton 35

SELinux 会阻止您运行二进制文件位于用户主目录中的系统服务,或者在您的情况下是 root 用户的主目录。

要解决此问题,请将二进制文件复制到适当的目录,例如/usr/local/bin并从那里调用它。

  • 请注意,如果您将服务文件从主目录移动到“适当的目录”,则它们的 SELinux 上下文仍然是“主目录”。您可以通过运行“sudo restorecon -rv /path/to/moved/directory”来重置它 (17认同)