how to give running process sudo permissions

2019-08-20 08:55发布

问题:

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.



标签: linux sudo