I'm trying to create an external acl helper for squid3 to (hopefully) cut down some config lines from my squid3 server and I wrote a simple python script for it:
#!/usr/bin/python
import sys
import logging
import time
logger = logging.getLogger( 'squid_auth' )
logger.setLevel( logging.DEBUG )
fh = logging.FileHandler( 'spam.log' )
fh.setLevel( logging.DEBUG )
formatter = logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - %(message)s' )
fh.setFormatter( formatter )
logger.addHandler( fh )
def grant ():
sys.stdout.write( 'OK\n' )
sys.stdout.flush()
def deny ():
sys.stdout.write( 'ERR\n' )
sys.stdout.flush()
while True:
line = sys.stdin.readline().strip()
if line:
logger.info( line )
grant()
else:
time.sleep( 1 )
and added it into my squid.conf:
external_acl_type custom_acl %SRC %LOGIN %DST /etc/changemyip/squid/config/acl.py
acl CustomAcl external custom_acl
http_access allow CustomAcl
The path to the script is right (I can execute it in shell), the program has execute rights and everything but, when I reload squid I get this error about 5-6 times then squid crashes:
Aug 17 14:08:52 server7 (squid): The custom_acl helpers are crashing too rapidly, need help!
Aug 17 14:08:52 server7 squid[28233]: Squid Parent: child process 28290 exited with status 1
Aug 17 14:08:52 server7 squid[28233]: Exiting due to repeated, frequent failures
As you can see the script is just printing OK\n
to the stdout to grant everyone. I haven't even started implementing any logic to it.
Tested with squid version: 3.1.19
I had a similar problem. I managed to fix it by changing the ownership of the script to the squid user and moving the file from my home directory to somewhere in the root filesystem.
I still had the same problem even after following @tyrells helpful directions.
The fix?
We need to make the python script executable by running the command below.
sudo chmod u+x /path/to/external-acl.py
So to summarize here's step by step instructions.
/usr/share/acl.py
sudo chown proxy:proxy /usr/share/acl.py
sudo chmod u+x /usr/share/acl.py
sudo service squid restart