为什么我不能在 IIS 中的网络共享上使用 PHP 脚本中的 shell_exec?

发布于 2024-08-26 03:58:24 字数 749 浏览 4 评论 0原文

我有一些驻留在网络共享上的 PHP 脚本。为了便于讨论,我们将共享命名为 \\nas\dev。我在 IIS6 中设置了 \\w2k3dev\ 上的网站,通过设置“位于另一台计算机上的共享”,使用 \\nas\dev\ 作为其主目录。

我的一些脚本使用 shell_exec 在服务器上执行函数并将结果返回到我的脚本。再次出于争论的目的,假设我只是得到一个目录列表,如下所示:

echo shell_exec('dir');

  • 如果我在 IIS 中运行脚本,我不会得到任何结果输出 - 但也没有错误日志。
  • 如果我在 \\w2k3dev\ 上设置 Apache 并将其配置为使用相同的共享,则脚本运行正常
  • 如果我将脚本复制到本地计算机并通过IIS 工作正常。

因此,问题似乎仅出现在 IIS 设置为使用包含 shell_exec 的脚本的网络共享时。我的脚本的所有其他方面都工作得很好。

在 procmon 中进行分析,我可以看到 cmd.exe 的运行方式完全不同,具体取决于它是由 IIS 还是 Apache 运行。我有更多细节,但为了简洁起见,我现在将省略它们,除非有人要求更多细节。

非常感谢您看到这个,我已经无计可施了。

亲切的问候

伊恩

I have some PHP scripts that reside on a network share. For argument's sake, let's call the share \\nas\dev. I have a Web Site on \\w2k3dev\ set up in IIS6 that uses \\nas\dev\ as its home directory by setting "A share located on another computer".

Some of my scripts use shell_exec to execute functions on the server and return results to my script. Again for argument's sake let's say I'm just getting a directory listing like so:

echo shell_exec('dir');

  • If I run the script in IIS, I get no output - but no error logs either.
  • If I set up Apache on \\w2k3dev\ and configure it to use the same share, the script runs fine
  • If I copy the script to the local machine and run it through IIS it works fine.

So the problem only seems to be when IIS is set up to use a network share with a script containing shell_exec. Every other aspect of my scripts work fine.

Profiling in procmon, I can see that cmd.exe operates completely differently depending on whether it's being run by IIS or Apache. I have more details, but for the sake of being concise, I will omit them for now unless someone asks for more details.

Thank you so much for looking at this, I am at my wits end.

Kind regards

Iain

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文