是否可以通过编程方式更改 unix 进程的可执行文件名称 (ucmd)?
是否可以通过编程方式更改 ps 报告的 unix 进程的可执行文件名称 (ucmd)?
unix/POSIX 方式会很好,但 Linux 特定的解决方案就足够了。
我想更改此处报告的内容,
> ps -o ucmd
CMD
zsh
ps
;)
> ps -o command
COMMAND
zsh
ps -o command
谢谢
而不是这个,我知道这个 不尝试创建 rootkit,只是 net-snmp 在检查进程时查看此名称,并且我的程序在从 init 调用时和直接从 /etc/init.d 调用时具有不同的名称(etc/rcX.d/SNNname 而不是只是名字)。
Is it possible to programatically change an executable name (ucmd) of a unix process as reported by ps?
unix/POSIX way would be nice but Linux specific solution would suffice.
I want to change what is reported here
> ps -o ucmd
CMD
zsh
ps
not this, this I know ;)
> ps -o command
COMMAND
zsh
ps -o command
thanks
P.S. Not trying to create a rootkit, its just that net-snmp looks at this name when checking processes and my program has a different name when called from init and directly from /etc/init.d (etc/rcX.d/SNNname instead of just name).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
prctl()
的PR_SET_NAME
函数来完成此操作:但是,
/etc/rcX.d/SNNname
应该是 (符号链接到a) 启动进程的脚本,而不是指向进程可执行文件本身的链接。这样也能解决问题。You can do this with the
PR_SET_NAME
function ofprctl()
:However,
/etc/rcX.d/SNNname
should be a (symlink to a) script that starts your process, not a link to the process executable itself. This would also solve the problem.