如何检查用户 php 正在以什么身份运行? [英] How to check what user php is running as?

查看:23
本文介绍了如何检查用户 php 正在以什么身份运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检测php是否以nobody运行.我该怎么做呢?

I need to detect if php is running as nobody. How do I do this?

nobody"还有其他名字吗?阿帕奇"?还有其他的吗?

Are there any other names for "nobody"? "apache"? Any others?

推荐答案

如果可用,您可以使用 posix_geteuid 然后使用 posix_getpwuid 获取用户名.

If available you can probe the current user account with posix_geteuid and then get the user name with posix_getpwuid.

$username = posix_getpwuid(posix_geteuid())['name'];

但是,如果您在安全模式下运行(禁用 exec 时经常出现这种情况),那么您的 PHP 进程不太可能在默认的 www-data 下运行>apache 帐户.

If you are running in safe mode however (which is often the case when exec is disabled), then it's unlikely that your PHP process is running under anything but the default www-data or apache account.

这篇关于如何检查用户 php 正在以什么身份运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆