大网数据广告活动
服务器运维问答

Disable mount namespaces in Apache/PHP-FPM

· 52CE 我爱测

For a web GUI to manage NFS mount points, we've run into a problem after migrating to Centos 8 . JS Billings noted that: CentOS8 runs httpd in a private namespace (with its own private /tmp). Since it's such a terrible idea to gi…

问题原文

原帖链接 · Danny · CC BY-SA 4.0

For a web GUI to manage NFS mount points, we've run into a problem after migrating to Centos 8.

JS Billings noted that:

CentOS8 runs httpd in a private namespace (with its own private /tmp). Since it's such a terrible idea to give httpd the ability to run sudo, I've never tried this, but I suspect what you are seeing is the fact that the mounts are happening in the private namespace

The effect is that running mount(8) via system() or even a setuid program which calls mount(2) to mount NFS partitions, the partitions are only visible to subsequent HTTP calls and not to any processes running on the server itself.

Is there a way to configure apache and/or php-fpm to not use mount namespaces?

  • Centos 8 Kernel 4.18.0-147.el8.x86_64
  • SELinux is disabled
  • Apache/2.4.37 (centos)
  • PHP 7.2.11

EDIT I

From Michael Hampton's advice, changing /etc/systemd/system/php-fpm.service to disable the PrivateTmp solved the problem:

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=notify
ExecStart=/usr/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID

# Disable private mount namespace
PrivateTmp=false
RuntimeDirectory=php-fpm
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

You can turn off PrivateTmp= in your php-fpm.service to prevent it from getting its own mount namespace. This has security implications, of course, so you may wish to review your code's use of temporary files.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-07-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。