如何授予正在运行的进程 sudo 权限
我想给正在运行的进程 sudo 权限。 就像我正常打开eclipse一样。现在,当我在 Eclipse 上启动服务器时,它需要 sudo 权限,但为此我必须关闭 Eclipse,然后使用 sudo eclipse 打开它以获得 sudo 权限。 我尝试设置 /usr/bin/eclipse 的 setuid 和 setgid 但没有成功。我不知道为什么它不起作用。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Setuid/setgid 不起作用,因为这些文件掩码位在创建进程时由内核使用,以赋予其提升的权限。
我认为如果不向内核添加主要功能,这是不可能的。
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.
我认为你的意思是“root权限”。在称为“Eclipse”的大量代码上设置 SUID root 并不是一个好主意。
您需要的是一个 SUID 包装器,它必须是二进制文件。嗯,这就是 sudo 的意思。但 sudo 会要求你输入密码。您需要使用 -A 开关运行它,并将 SUDO_ASKPASS 环境变量设置为 /usr/bin/x11-ssh-askpass 之类的内容。然后,您将看到 GUI 弹出窗口,询问您的密码,然后生成的程序将以提升的权限运行。
这与更改已运行进程的权限不同,正如您的问题标题所暗示的那样。这是你做不到的,据我所知。
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.