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

apache2: Saves files on /tmp in a 'system-private-[hash]' instead of just saving folders as defined in the code

· 52CE 我爱测

For some reason, when I try to save a file (generated by PHP under /www/appname/module ) - it is saved under /tmp/systemd-private-015eb2e9f67b4eef862c68e99fe0ba30-apache2.service-9h6i08 and when aiming files to get saved under /t…

问题原文

原帖链接 · Rick Sanchez · CC BY-SA 4.0

For some reason, when I try to save a file (generated by PHP under /www/appname/module) - it is saved under

/tmp/systemd-private-015eb2e9f67b4eef862c68e99fe0ba30-apache2.service-9h6i08

and when aiming files to get saved under

/tmp/somename

files get saved under

/tmp/systemd-private-015eb2e9f67b4eef862c68e99fe0ba30-apache2.service-9h6i08/tmp/somename.

How do i disable this feature and just save files "regularly" to the /tmp directory?

What is the purpose of this default feature anyway?

已采纳解答

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

That is a systemd security setting that creates a service specific private temp directory.

Your apache systemd unit will file have a setting:

...
[Service]
ExecStart=...
PrivateTmp=yes
...

This option will ensure that the /tmp directory the service will see is private and isolated from the host system's /tmp. /tmp traditionally has been a shared space for all local services and users. Over the years it has been a major source of security problems for a multitude of services. Symlink attacks and DoS vulnerabilities due to guessable /tmp temporary files are common. By isolating the service's /tmpfrom the rest of the host, such vulnerabilities become moot.
Source: http://0pointer.de/blog/projects/security.html

You can configure multiple services to share a PrivateTmp with JoinsNamespaceOf= which may be desirable to setting PrivateTmp=no

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

资料来源与适用范围

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

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

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