Ok, now I have a new error!!! I have tried to create my own auth script however I just get crap in the log files and I cant find anything useful on google:
/var/log/squid/cache.log:
Code:
1031 2010/11/29 18:18:18| helperHandleRead: unexpected read from basicauthenticator #4, 3 bytes 'ERR'
1032 2010/11/29 18:18:18| helperHandleRead: unexpected read from basicauthenticator #5, 3 bytes 'ERR'
1033 2010/11/29 18:19:18| helperHandleRead: unexpected read from basicauthenticator #3, 3 bytes 'ERR'
1034 2010/11/29 18:19:18| helperHandleRead: unexpected read from basicauthenticator #2, 3 bytes 'ERR'
1035 2010/11/29 18:19:18| helperHandleRead: unexpected read from basicauthenticator #4, 3 bytes 'ERR'
1036 2010/11/29 18:19:18| helperHandleRead: unexpected read from basicauthenticator #5, 3 bytes 'ERR'
squid.conf:
Code:
10 auth_param basic program /usr/bin/php /usr/lib64/squid/sql_auth.php
11 auth_param basic children 5
12 auth_param basic realm Linux Class
13 auth_param basic credentialsttl 2 hours
14 auth_param basic casesensitive off
15
16 acl class proxy_auth REQUIRED
17 http_access allow class
18
My auth script - /usr/lib64/squid/sql_auth.php:
Code:
<?php
DEFINE('DB_USER', 'squid');
DEFINE('DB_PASSWORD', 'password');
DEFINE('DB_HOST', 'localhost');
DEFINE('DB_NAME', 'squid');
while(!feof(STDIN))
{
$line = trim(fgets(STDIN));
$fields = explode(' ', $line);
if(isset($fields[0]))
{
$username = rawurldecode($fields[0]);
}
if(isset($fields[1]))
{
$password = rawurldecode($fields[1]);
}
if($username == 'quit')
{
exit();
}
if(strlen($username)>0 && strlen($password)>0)
{
$dbc = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$q = "SELECT id FROM users WHERE user = '$username' AND password = SHA1('$password') AND enabled = 'Y' AND paid_dstamp > DATE_SUB(NOW(), I
NTERVAL 1 YEAR);";
$r = @mysqli_query($dbc, $q);
if(mysqli_num_rows($r)== 1)
{
fwrite(STDOUT, "OK\n");
}
else
{
fwrite(STDOUT, "ERR\n");
}
mysqli_close($dbc);
}
else
{
// failed miserably
fwrite(STDOUT, "ERR\n");
}
}
I believe that this error is causing my authentication to fail, however the script returns OK or ERR in the command line when passing the values in, such as:
Code:
root@server squid]# php /usr/lib64/squid/sql_auth.php
trscookie mypass
OK
trscookie crappass
ERR
quit
[root@server squid]#
Any ideas would be more than appreciated.
Many thanks,
trscookie