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

Enabling opcache.restrict_api for security reasons

· 52CE 我爱测

This article says that having opcache_get_status() enabled is a security risk. To turn it off, one has to configure opcache.restrict_api , but I couldn't find an example of how. This person had the restriction in effect when conf…

问题原文

原帖链接 · ᴍᴇʜᴏᴠ · CC BY-SA 4.0

This article says that having opcache_get_status() enabled is a security risk. To turn it off, one has to configure opcache.restrict_api, but I couldn't find an example of how.

This person had the restriction in effect when configured as opcache.restrict_api=/restricted, which gives me a clue that it needs to be a path.

I started by creating a test script with an opcache_get_status() call, and I got an output of lots of PHP scripts on that system, confirming there was no restriction. Then I edited my /etc/php/7.3/fpm/php.ini to have opcache.restrict_api=/dev/null, and that same call now returns bool(false) - I take that the restriction is enabled.

My goal is to forbid opcache_get_status() and the like completely, and by 'allowing' scripts under /dev/null, I'm essentially making it impossible to use, since you can't a file there.

  • Is this logic correct?
  • Should I maybe use some other path?
  • Is there a way to enable the restriction directly, without messing around with fake paths?

Thank you

已采纳解答

原帖链接 · ᴍᴇʜᴏᴠ · CC BY-SA 4.0

Looking at the source code of ext/opcache/zend_accelerator_module.c

Also here's someone else using opcache.restrict_api=1 too.

Please correct me if I'm wrong somewhere! Until then, I feel like this pretty much answers my question.

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

资料来源与适用范围

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

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

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