Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

能否通过setcap添加capabilities在普通用户下执行 #48

Closed
kdurov opened this issue Dec 11, 2022 · 6 comments
Closed

能否通过setcap添加capabilities在普通用户下执行 #48

kdurov opened this issue Dec 11, 2022 · 6 comments
Labels
bug Something isn't working solved

Comments

@kdurov
Copy link

kdurov commented Dec 11, 2022

sudo setcap cap_net_raw,cap_net_admin+eip ~/.bin/nexttrace
添加后还是会提示需要 root 权限。
能否让普通用户也能执行呢?

谢谢

@sjlleo sjlleo added bug Something isn't working solved labels Dec 12, 2022
@sjlleo
Copy link
Contributor

sjlleo commented Dec 12, 2022

Hi kdurov,

感谢您的反馈,这确实是一个权限验证逻辑上的 Bug
现在应该没问题了,请下载最新版本 v0.2.4-1 试试

不过我手里的测试样本可能不足以证明能在所有的环境中都能正常工作,也请您帮忙验证一下。

Thanks!

Best Regards,
Leo

@sjlleo
Copy link
Contributor

sjlleo commented Dec 13, 2022

如无其他问题,此 issue 将被关闭,如果仍有疑问请另提新 issue

@sjlleo sjlleo closed this as completed Dec 13, 2022
@kdurov
Copy link
Author

kdurov commented Dec 13, 2022

谢谢。
刚测试本地环境无问题。

@kdurov
Copy link
Author

kdurov commented Jan 7, 2023

macOS 下没有 setcap。
想请教下有什么别的办法能在 macOS 普通用户下执行么?

@sjlleo
Copy link
Contributor

sjlleo commented Jan 8, 2023

对于 macOS (Darwin) 来说,权限设计是更为严格的。可惜目前 macOS 并没有能够达到 setcap 相似功能的指令集,NextTrace 的 net_raw (原始包监听)是必要的一个权限,对于 Go 开发的路由跟踪,可能目前没有很好的办法去避免(除非使用 syscall,但是 syscall 也会涉及到 root 权限的需要)。

网上也有很多关于这方面的讨论,目前对于 macOS 来说,只能通过 sudo 或者以 root 用户运行。
这些内容可能对你有所帮助:

  1. https://news.ycombinator.com/item?id=14168124
  2. https://unix.stackexchange.com/questions/271819/enable-linux-capabilities-on-macos

Thanks.

@kdurov
Copy link
Author

kdurov commented Jan 8, 2023

感谢指教。

看来只能通过 alias 配合 visudo 简化命令了。

tsosunchia added a commit that referenced this issue Apr 17, 2024
…rodaine/table-1.2.0

chore(deps): bump github.com/rodaine/table from 1.1.1 to 1.2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working solved
Projects
None yet
Development

No branches or pull requests

2 participants