Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3783030
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:10:00+00:00 2026-05-19T11:10:00+00:00

In my Django project I need to be able to check whether a host

  • 0

In my Django project I need to be able to check whether a host on the LAN is up using an ICMP ping. I found this SO question which answers how to ping something in Python and this SO question which links to resources explaining how to use the sodoers file.

The Setting

A Device model stores an IP address for a host on the LAN, and after adding a new Device instance to the DB (via a custom view, not the admin) I envisage checking to see if the device responds to a ping using an AJAX call to an API which exposes the capability.

The Problem

However (from the docstring of a library suggested in the the first SO question) “Note that ICMP messages can only be sent from processes running as root.”

I don’t want to run Django as the root user, since it is bad practice. However this part of the process (sending and ICMP ping) needs to run as root. If with a Django view I wish to send off a ping packet to test the liveness of a host then Django itself is required to be running as root since that is the process which would be invoking the ping.

Solutions

These are the solutions I can think of, and my question is are there any better ways to only execute select parts of a Django project as root, other than these:

  1. Run Django as root (please no!)
  2. Put a “ping request” in a queue that another processes — run as root — can periodically check and fulfil. Maybe something like celery.

Is there not a simpler way?

I want something like a “Django run as root” library, is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T11:10:00+00:00Added an answer on May 19, 2026 at 11:10 am

    Absolutely no way, do not run the Django code as root!

    I would run a daemon as root (written in Python, why not) and then IPC between the Django instance and your daemon. As long as you’re sure to validate the content and properly handle it (e.g. use subprocess.call with an array etc) and only pass in data (not commands to execute) it should be fine.

    Here is an example client and server, using web.py

    Server: http://gist.github.com/788639
    Client: http://gist.github.com/788658

    You’ll need to install webpy.org but it’s worth having around anyway. If you can hard-wire the IP (or hostname) into the server and remove the argument, all the better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a django project in which database values need to be updated fairly
For a Django project I'm working on, I need to be able to allow
In my Django project I am using Product.objects.all().order_by('order') in a view, but it doesn't
I'm considering using Django for a project I'm starting (fyi, a browser-based game) and
I need to build a django project on top of an existing database. I'll
I have a Django project that I need mounted at two different subdirectories of
I have a client's Django project that I'm developing locally, using Mercurial for version
I want to keep some global settings for my project in Django. I need
Summary: Say I have a project in Django called devsite which will be deployed
I'm working in a project with django and GAE, but I need internationalization for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.