how to give running process sudo permissions

2019-08-20 08:28发布

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.

标签: linux sudo
2条回答
时光不老,我们不散
2楼-- · 2019-08-20 08:59

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.

查看更多
smile是对你的礼貌
3楼-- · 2019-08-20 09:14

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.

查看更多
登录 后发表回答