mod_python を使用して Apache 2.x で python スクリプトを実行しようとしています。パブリッシャーで httpd.conf を編集しました
LoadModule python_module /usr/local/apache2/modules/mod_python.so
<Directory /usr/local/apache2/htdocs/mod_python>
SetHandler mod_python
PythonHandler mod_python.publisher
PythonDebug On
root 権限を必要とする Python スクリプトを使用してファイアウォールにルールを追加しようとしています。それはルート権限を求めていますか?誰か助けてください。
#!/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?")
これは、openBSD で apache を介して実行したい python スクリプトです。mod_python を使用します。