更改当前正在运行的进程的所有者 [英] Change owner of a currently running process

查看:133
本文介绍了更改当前正在运行的进程的所有者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个进程,当前正在使用 pid $PID运行,并且由非root用户用户 foo拥有>.我想将此过程的所有权转让给另一个不是root 用户 bar.

I have a process that is currently running with pid, $PID, and owned by the user foo which is not root. I want to transfer the ownership of this process to another user bar which is also not root.

是否有一个Shell命令可以更改进程的所有者?我正在考虑chown,但对于看起来像这样的过程.

Is there a shell command that changes the owner of a process? I'm thinking of a chown but for processes that looks something like.

chownproc [option] PID

此问题

This question and this question are similar, but not quite what I'm looking for and chown man pages doesn't say anything about processes, only files.

如果没有,为什么没有这样做或不可能呢?

If there isn't, is there a reason why this hasn't been done or isn't possible?

推荐答案

您不能这样做,没有这样的系统调用.但是,根据您希望如何影响该过程,如果该过程对您的系统不是至关重要的,则可以尝试一些破解.

You cannot do that, there's no such syscall. However, depending on how you want to affect the process, you could try some hack if the process is not critical to your system.

(gdb) attach process_id
(gdb) call putenv ("UID=1234")
(gdb) call putenv ("EUID=1234")
(gdb) call putenv ("GID=1234")
(gdb) detach

请注意,这将无效:

(gdb) call setuid(1234)

这并不能真正回答您的问题(更改正在运行的进程的所有者),但考虑到您可能希望更改所有者以影响有关该进程的某些东西,也许是此黑客帮助.

This does not really answer to your question (change the owner of a running process), but considering that you may want to change the owner to affect something about the process, maybe this hack help.

请记住,这很可能破坏您的流程.

Remember that it's very likely that this breaks your process.

(基于此: 是否可以更改其他进程的环境变量?)

这篇关于更改当前正在运行的进程的所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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