I'm working on an acl helper in c, that needs to access a pid file.

The name of the file is the ip address of a client in dot notation. Inside
the file is a username, and I want to pass to squid. I wrote an acl
helper, and setup external_acl_type to pass %SRC.

SQUID never grants access to the client.

I'm not that familar with c, but combed through the source of every other
acl helper I could find. The program I wrote works wonderfully from the
command line, but does not work from squid.

I wrote an acl helper that works well when I test it from the command
line, but has never worked when squid passes %SRC.

using stderr, I think the program fails to open the pid file (named ex:
192.168.100.109) when passed %SRC by squid from machine 192.168.100.109,
even when the %Src is printed to stderr as 192.168.100.109.


I have used strchr to change \n to \0 and also just chopping it off with a
strncat(var, var, strlen(squidsrc) -1). Neither worked. Checked and
rechecked file perms. I've even played around with ttls.



Here's the code:

int main(  )
{
        char squidsrc[256];
        while ( fgets(squidsrc, sizeof(squidsrc), stdin ) != NULL ) {

                FILE *FH;
                char line[1024];
                char filename[MAXPATHLEN] = "/var/userlock/";
                char username[MAXLOGNAME + 10];
                char squidreturnok[1024] = "OK user="
                char *p;
                if ((p = strchr(squidsrc, '\n')) != NULL) {
                p = '\0';}


                 if ((FH = fopen( filename , "r" )) != NULL ) {


                        while ( fgets ( line , sizeof(line), FH )  != NULL ) {
                                strcpy( username ,  line );
                        }

                        fclose ( FH );

                        strcat( squidreturnok, username);
                        printf (squidreturnok "\n");

                }       else {
                        printf ( "ERR\n" ); }

}

}





My acl's are simple
external_acl_type pid_file %SRC /var/squid/helpers/pid_squid
acl lab external pid_file
http_access allow lab


Any input would be much appreciated! I need to wrap this project up, and
the helper is the last step. Thanks.


(ALL PRAISE THE MIGHTY SQUID)







Reply via email to