[squid-users] Trouble writing external acl helper

2010-04-14 Thread marriedto51

I am almost certainly missing something very basic, but I haven't found out
what after searching here and elsewhere, so any help will be greatly
appreciated.

I'm using squid 3.1 on Fedora 12 (64-bit).

I want to write an external acl helper (for fun!) and started with a toy
example written in C which is only going to allow the URL
http://www.google.com;. It works as I expect when I run it at the command
line (lines are read one-by-one from standard input and a reply of OK or
ERR appears on standard output), but the output I get from squid says:

2010/04/14 08:40:23.731| helperOpenServers: Starting 5/5 'toy_helper'
processes
...
2010/04/14 08:40:31.197| WARNING: toy_helper #1 (FD 7) exited
2010/04/14 08:40:31.197| WARNING: toy_helper #3 (FD 11) exited
2010/04/14 08:40:31.198| WARNING: toy_helper #2 (FD 9) exited
2010/04/14 08:40:31.198| WARNING: toy_helper #4 (FD 13) exited
2010/04/14 08:40:31.198| Too few toy_helper processes are running
...
FATAL: The toy_helper helpers are crashing too rapidly, need help!

In the squid.conf file I've put:

external_acl_type toy_helper %PATH /tmp/squid-tests/toy_helper
acl toy external toy_helper

This squid.conf and the toy_helper executable are both in /tmp/squid-tests,
and everything there is world-readable.

Lastly, here is the source for toy_helper:

   1 #include stdio.h
   2 #include string.h
   3 #define BUFSIZE 8192
   4 
   5 int
   6 main(int argc, char *argv[])
   7 {
   8 
   9   char buf[BUFSIZE];
  10
  11   /* make standard output and input unbuffered */
  12   setvbuf(stdout, NULL, _IONBF, 0);
  13   setvbuf(stdin, NULL, _IONBF, 0);
  14   
  15   /* main loop: read lines from stdin */
  16   while ( fgets(buf, sizeof(buf), stdin) )
  17   {
  18 if ( strcmp(http://www.google.com/\n;, buf) == 0 )
  19   printf(OK\n);
  20 else
  21   printf(ERR\n);
  22   }
  23 
  24   return 0;
  25 }

Thanks in advance for any clues,
John.
-- 
View this message in context: 
http://n4.nabble.com/Trouble-writing-external-acl-helper-tp1839464p1839464.html
Sent from the Squid - Users mailing list archive at Nabble.com.


Re: [squid-users] Trouble writing external acl helper

2010-04-14 Thread John Doe
From: marriedto51 johnmwil...@talktalk.net
 2010/04/14 08:40:31.197| WARNING: toy_helper #1 (FD 7) exited
 2010/04/14 08:40:31.197| WARNING: toy_helper #3 (FD 11) exited
 2010/04/14 08:40:31.198| WARNING: toy_helper #2 (FD 9) exited
 2010/04/14 08:40:31.198| WARNING: toy_helper #4 (FD 13) exited
 2010/04/14 08:40:31.198| Too few toy_helper processes are running

This works for me with squid 2.7 (I did not use setvbuf):

  fprintf(stderr, helper: starting...\n);
  fflush(stderr);
  while (fgets(input, sizeof(input), stdin)) {
if ((cp=strchr(input, '\n')) == NULL) {
  fprintf(stderr, filter: input too big: %s\n, input);
} else {
  *cp = '\0';
}
...
fflush(stderr);
fflush(stdout);
  }
  fprintf(stderr, helper: stopping...\n);


  


RE: [squid-users] Trouble writing external acl helper

2010-04-14 Thread Adnan Shahzad
Dear All,

I am adding my problem if you ppl can solve by external ACL Helper...

my clients mostly hitting local PC names as http request, which cause file 
descriptor in use and in that response Internet speed slow even dead slow..

Is it virus? What if I want to allow that them all, then how can I allow 
them Common thing them all is there is no .com or .org or .net. so is it 
possible that I make an acl that allow http request without having domain name 
(.com, .net or .org etc)

Looking forward to you response



1271255037.123  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.194  1 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.264  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.334  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.404  1 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.476  1 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.544  1 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.614  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.686  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.755  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.832  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.894  1 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255037.965  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.036  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.105  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.175  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.245  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.316  1 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.386  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.455  1 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.526  1 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.596  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.673  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.736  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.806  1 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.876  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255038.947  1 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255039.016  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html
1271255039.090  0 10.90.0.103 TCP_DENIED/407 7629 OPTIONS http://iqra-pc/ - 
NONE/- text/html

-Original Message-
From: marriedto51 [mailto:johnmwil...@talktalk.net] 
Sent: Wednesday, April 14, 2010 1:38 PM
To: squid-users@squid-cache.org
Subject: [squid-users] Trouble writing external acl helper


I am almost certainly missing something very basic, but I haven't found out
what after searching here and elsewhere, so any help will be greatly
appreciated.

I'm using squid 3.1 on Fedora 12 (64-bit).

I want to write an external acl helper (for fun!) and started with a toy
example written in C which is only going to allow the URL
http://www.google.com;. It works as I expect when I run it at the command
line (lines are read one-by-one from standard input and a reply of OK or
ERR appears on standard output), but the output I get from squid says:

2010/04/14 08:40:23.731| helperOpenServers: Starting 5/5 'toy_helper'
processes
...
2010/04/14 08:40:31.197| WARNING: toy_helper #1 (FD 7) exited
2010/04/14 08:40:31.197| WARNING: toy_helper #3 (FD 11) exited
2010/04/14 08:40:31.198| WARNING: toy_helper #2 (FD 9) exited
2010/04/14 08:40:31.198| WARNING: toy_helper #4 (FD 13) exited
2010/04/14 08:40:31.198| Too few toy_helper processes are running
...
FATAL: The toy_helper helpers are crashing too rapidly, need help!

In the squid.conf file I've put:

external_acl_type toy_helper %PATH /tmp/squid-tests/toy_helper
acl toy external toy_helper

This squid.conf and the toy_helper executable are both in /tmp/squid-tests,
and everything there is world-readable.

Lastly, here is the source for toy_helper:

   1 #include stdio.h
   2 #include string.h