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

Drop sudo need #5

Closed
laixintao opened this issue Apr 7, 2019 · 9 comments
Closed

Drop sudo need #5

laixintao opened this issue Apr 7, 2019 · 9 comments
Labels
help wanted Extra attention is needed

Comments

@laixintao
Copy link
Owner

laixintao commented Apr 7, 2019

Replacement for RAW_SOCKET?

This tool need sudo because this:

pingtop/ping.py

Line 202 in c8c522c

my_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)

@ryankrage77
Copy link

If I run it with sudo, I get command not found, otherwise it fails.

@laixintao
Copy link
Owner Author

@ryankrage77 Did you install for current user only instead of installing globally?

Try type which pingtop and use absolute path to run:

sudo /usr/local/bin/pingtop xxx

(replace /usr/local/bin/pingtop with your absolute path.)

Or you can install for sudo user:

sudo pip install pingtop

@gzxultra
Copy link
Contributor

gzxultra commented Apr 9, 2019

no way to work around this, kernel will not allow sending of packets that cannot be trusted.

@sgowie
Copy link

sgowie commented Apr 10, 2019

If the python interpreter being invoked has been provided the appropriate capabilities, sudo is not required.

e.g.

$ pip install pingtop --user
$ NEWPATH=$(pwd)/.local/bin/python
$ cp $(which python) $NEWPATH
$ sudo setcap cap_net_raw=ep $NEWPATH
$ sed -i "1s;/usr/bin/python;$NEWPATH;" .local/bin/pingtop

This lets you run the installed pingtop without invoking sudo, and only the specific privileges required for pingtop to do its thing are granted.

$ .local/bin/pingtop google.ca cnn.com

@gzxultra
Copy link
Contributor

gzxultra commented Apr 10, 2019

@sgowie there is no setcap on OS X

@laixintao
Copy link
Owner Author

@gzxultra I am thinking support tcpping, if use tcpping do we still need sudo ?

@laixintao
Copy link
Owner Author

I will check BSD ping's source code, see how does it run without sudo.

@laixintao laixintao added the help wanted Extra attention is needed label Apr 10, 2019
@gzxultra
Copy link
Contributor

@laixintao
Copy link
Owner Author

Solved by @gzxultra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants