linux Apache2:无法设置装载命名空间:权限被拒绝

aurhwmvo  于 2022-12-18  发布在  Linux
关注(0)|答案(2)|浏览(168)

我的VPS服务器安装了Debian 10。我想使用选项PrivateTmp=true启动Apache 2。但是启动失败,错误如下:apache 2.服务:在生成/usr/sbin/apachectl的命名空间步骤失败:权限被拒绝

● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2020-11-27 17:17:43 CET; 5s ago
     Docs: https://httpd.apache.org/docs/2.4/
  Process: 523 ExecStart=/usr/sbin/apachectl start (code=exited, status=226/NAMESPACE)

Nov 27 17:17:43 5091-server systemd[1]: Starting The Apache HTTP Server...
Nov 27 17:17:43 5091-server systemd[523]: apache2.service: Failed to set up mount namespacing: Permission denied
Nov 27 17:17:43 5091-server systemd[523]: apache2.service: Failed at step NAMESPACE spawning /usr/sbin/apachectl: Permission denied
Nov 27 17:17:43 5091-server systemd[1]: apache2.service: Control process exited, code=exited, status=226/NAMESPACE
Nov 27 17:17:43 5091-server systemd[1]: apache2.service: Failed with result 'exit-code'.
Nov 27 17:17:43 5091-server systemd[1]: Failed to start The Apache HTTP Server.

我检查了tmp的权限:

root@5091-server:~# ls -ld /tmp
drwxrwxrwt 8 root root 4096 Nov 27 17:17 /tmp
root@5091-server:~# ls -ld /var/tmp
drwxrwxrwt 2 root root 4096 Nov 27 17:17 /var/tmp

知道哪些权限是错误的吗?

lnxxn5zx

lnxxn5zx1#

这个可以...

sudo sed -i -e 's,PrivateTmp=true,PrivateTmp=false\nNoNewPrivileges=yes,g' /lib/systemd/system/apache2.service
sudo systemctl daemon-reload
sudo systemctl start apache2.service
sudo systemctl status apache2.service
tyg4sfes

tyg4sfes2#

这与新的systemd安全特性(v220+?)与非特权LXC容器(如Proxmox内部的容器)冲突有关。
1.编辑apache配置(干净的方式):

sudo systemctl edit apache2.service

1.添加此选项以禁用新的systemd安全特性(影响LXC容器,如Proxmox内的容器)

[Service]
PrivateDevices=false
PrivateTmp=false
ProtectControlGroups=false
ProtectKernelModules=false
ProtectSystem=false

仅需要Maybe

ProtectHome=false
ProtectSystem=false

1.然后

sudo systemctl start apache2.service
sudo systemctl status apache2.service  # Just to check the output

我在apache 2和memcached上看到了这个。还有systemd-logind。在最后一个案例中,ssh连接速度受到了影响。ssh -vvvdebug1: pledge: filesystem(没有VPN)和debug1: pledge: network(有VPN)上卡住了。正如前面提到的herehere,在Proxmox容器上启用nesting(也在这里)问题得到了解决。
可能只需为容器启用“嵌套”特性(如果它没有特权)就可以允许systemd使用其名称空间特性。

相关

  • Nested containers in LXD | Ubuntu
  • 路线图- Proxmox VE 7.1真实的的解决方案是升级主机?
  • 无法重置devices. list...不允许操作·问题#2004 · lxc/lxd

相关问题