how to give running process sudo permissions

僤鯓⒐⒋嵵緔 提交于 2019-12-25 00:42:44

问题


I want to give a running process sudo permissions. Like if I have opened eclipse normally. Now when I start my server on eclipse it needs sudo permission but for that I will have to close the eclipse and then open it with sudo eclipse to get sudo permission. I tried setting the setuid and setgid of /usr/bin/eclipse but that didn't worked. I don't know why it didn't worked.


回答1:


Setuid/setgid didn't work as those file mask bits are used by the kernel, when the process is created, to give it the elevated privileges.

I don't believe it's possible without adding major pieces of functionality to the kernel.




回答2:


I think you mean "root permissions". Setting SUID root on the giant mass of code called "Eclipse" is not a good idea.

What you need is an SUID wrapper, which has to be a binary. Hm, that's what sudo is. But sudo asks for your password. You need to run it with the -A switch , and have the SUDO_ASKPASS environment variable set to something like /usr/bin/x11-ssh-askpass. Then you will get GUI popup asking for your password, and then the spawned program will run with elevated privileges.

That is different than changing the permissions on an anlready running process, which your question title implies. That you cannot do, AFAIK.



来源:https://stackoverflow.com/questions/4623673/how-to-give-running-process-sudo-permissions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!