title: How to run python script which require root privilage for execution in apache with mod_python at openbsd
body: <p>I am trying to run python script in Apache 2.x with mod_python. I edited httpd.conf with publisher</p>
  
  <pre><code>    LoadModule python_module /usr/local/apache2/modules/mod_python.so
   &lt;Directory /usr/local/apache2/htdocs/mod_python&gt;
  
  SetHandler mod_python
  PythonHandler mod_python.publisher
  PythonDebug On
  </code></pre>
  
  <p></p>
  
  <p>I am trying to add a rule in firewall using python script which require root privilege. it's asking for root privilege ? Please somebody help.</p>
  
  <pre><code>    #!/usr/local/bin/python
      #from mod_python import apache
      import sys
      import errno
      import pf
  
      def index(req):
           filter = pf.PacketFilter()
  
           try:
                # Enable packet filtering
                filter.enable()
                print  "pf is enabled"
                return "pf is enabled"
           except IOError, (err, msg):
                  if err == errno.EACCES:
                        #sys.exit("Permission denied: are you root?")
                         return ("Permission denied: are you root?")
                  elif err == errno.ENOTTY:
                          #sys.exit("ioctl not supported by the device: is the pf device correct?")
                          return ("ioctl not supported by the device: is the pf device correct?")
  </code></pre>
  
  <p>this is python script which i want to execute though apache at openBSD. it uses mod_python.</p>