Privilege Error

Hello guys , anybody can help me with this error?? I have a view that use multiping but when I call the view I receive this error , anybody knows how to solve it?

Thanks and sorry for my English :smiley:

MultiPingError at /Ar

Root privileges required for sending ICMP

Request Method: GET
Request URL: http://127.0.0.1:8000/Ar
Django Version: 3.0.5
Exception Type: MultiPingError
Exception Value:

Root privileges required for sending ICMP

Exception Location: /home/ramiro/.local/lib/python3.8/site-packages/multiping/init.py in _open_icmp_socket, line 175
Python Executable: /usr/bin/python3
Python Version: 3.8.2
Python Path:

[’/home/ramiro/Django/dashboard’,
‘/usr/lib/python38.zip’,
‘/usr/lib/python3.8’,
‘/usr/lib/python3.8/lib-dynload’,
‘/home/ramiro/.local/lib/python3.8/site-packages’,
‘/usr/local/lib/python3.8/dist-packages’,
‘/usr/lib/python3/dist-packages’]

Server time: Sun, 3 May 2020 11:34:45 -0300

Your application is using a module called multiping. In its documentation it says that you need to run the application as root/admin in order to use some functionality. In other words, run your application with more rights, such as “run as admin” on windows.

Yep I know it but I am running Django with a user with root privileges , I am using Ubuntu . So I dont know what more I have to add to permit multiping work from a user that is not root . (My user is in sudoers file)

How are you running multiping in your view? If you’re running it directly, you could run the sudo program itself, passing multiping in as a parameter. (You’ll need to set your sudoers file to allow the account running Django to run multiping without a password.)

Hello Ken, I am runining multiping directly in a function , I already have my sudoers file like this
root ALL=(ALL:ALL) ALL
ramiro ALL=(ALL:ALL) ALL
ramiro ALL = NOPASSWD:ALL

But the problem is the same , I think the problem is that cannot open ICMP socket , but I dont know how to fix it :expressionless: :

I would need to see the view code that is running the multiping command.

For example, If you’re running multiping directly, you could change it to run ‘sudo multiping’

This is the code
from multiping import MultiPing

def manila():
ahora=datetime.datetime.now()
cores = [“10.10.0.1”, “10.10.0.2”, “10.10.0.3”, “10.10.0.13”, “10.10.0.24”]
mp = MultiPing(cores)
mp.send()
responses, no_responses = mp.receive(1)
hostUP= (list(responses))

Ah, ok, you’re running the python multiping library. I was working under the assumption that you were calling an external program by that name.
The misunderstanding was mine. In this case, I’m going to agree with JonasKs’ answer. You either need to run your entire application as root. (Note, this means actually running it as root, not just as an account with root access.) Or, you need to externalize this code into a separate script, and then run that script from your view using the sudo command.

Thanks Ken and JonasKs, as you said , I had to run the app as root.

Thanks for your time , I really appreciated it.