question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PermissionError when Pingtop is executed without sudo

See original GitHub issue

Hi, Beautiful and useful tool! However I am having a similar problem to #5, but it is already fixed and seems a bit different to this one I am reporting.

I installed it with pip install pingtop. Then I ping baidu.com with pingtop baidu.com but it doesn’t work, I get this error:

ERROR:root:[Errno13]: Permiso denegado
[...]
PermissionError: [Errno13]  Permiso denegado

I can’t copy the error, so I am going to attach a screenshot.

pingtop_error

I achieve to run it thanks to the comment of @laixintao in the mentioned issue, I mean making a which pingtop to get the path in which it is installed and then using sudo PATH baidu.com.

Is there some reason to run it as super user? Or, could it be fixed?

Regards

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
laixintaocommented, Apr 28, 2019

Hi @ivanhercaz , we use ICMP socket to send ICMP packet without root.

However, there is a option control who can use this feature.

cat /proc/sys/net/ipv4/ping_group_range

1	0

This means group number from 1 to 0 can use this feature, which means nobody can use this, so you get a Permission denied .

[vagrant@centos7 pingtop]$ python ping.py
Traceback (most recent call last):
  File "ping.py", line 281, in <module>
    print(do_one("google.com", 1, 64))
  File "ping.py", line 204, in do_one
    my_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, icmp)
  File "/usr/lib64/python2.7/socket.py", line 187, in __init__
    _sock = _realsocket(family, type, proto)
socket.error: [Errno 13] Permission denied

Solution

Change this variable to a proper range include your group id, like this:

[vagrant@centos7 pingtop]$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

[vagrant@centos7 pingtop]$ sudo sysctl -w net.ipv4.ping_group_range='0 1001'
net.ipv4.ping_group_range = 0 1001

Then you can use this without sudo.

1reaction
gzxultracommented, Apr 26, 2019

Apologize for the delay, I just realize my PR only granted non-root support for OS X, Linux is a bit tricky. One way to work around here is, like @laixintao indicated, set the ping_group_range. Also, there’s a bug in receive_one_ping func, will submit a PR to fix this.

root@host:~# sysctl -w net.ipv4.ping_group_range="<min-uid> <max-uid>"

For example, if your uid is 1234,

root@host:~# sysctl -w net.ipv4.ping_group_range="0 1234"

Not sure if it is the best practice here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why i can't do some things without sudo using Python and pip?
The reason is that your regular user doesn't have the permissions needed to modify the system directories. Just like in this message:
Read more >
Permissions error when installing without sudo #11 - GitHub
An alternative solution is to make a system package installable via the systems own package manager (would be apt-get in this case).
Read more >
Why is sudo required for every sudo executed executable?
Explanation. When you execute a command with sudo it just means that the user that is executing that command is root .
Read more >
How can I run this command without the use of sudo?
I'm trying to do the same, accessing this file from a shell script. Nothing works, even setting u+s permissions to the shell script....
Read more >
Bug #1300948 “aa-genprof crashed with PermissionError in ...
running aa-genprof without sudo made the crash. ProblemType: Crash DistroRelease: Ubuntu 14.04 Package: apparmor-utils 2.8.95~2430-0ubuntu3 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found