dev-perl/MooseX-Types-DateTime: Remove old
[gentoo.git] / net-proxy / squidguard / files / squidguard-1.5_beta-protocol.patch
1 Patch for compatibility with new(>=3.4) Squid helper protocol
2
3 Bugreport: http://bugs.squid-cache.org/show_bug.cgi?id=3978
4
5 diff -ur squidGuard-1.5-beta.orig/src/main.c squidGuard-1.5-beta/src/main.c
6 --- squidGuard-1.5-beta.orig/src/main.c 2013-12-12 11:47:31.000000000 +1300
7 +++ squidGuard-1.5-beta/src/main.c      2013-12-12 11:50:38.000000000 +1300
8 @@ -185,7 +185,7 @@
9         sgReloadConfig();
10        }
11        if(failsafe_mode) {
12 -       puts("");
13 +       puts("ERR message=\"squidGuard failsafe mode\"");
14         fflush(stdout);
15         if(sig_hup){
16            sgReloadConfig();
17 @@ -194,7 +194,7 @@
18        }
19        if(parseLine(buf,&squidInfo) != 1){
20         sgLogError("ERROR: Error parsing squid line: %s",buf);
21 -       puts("");
22 +       puts("BH message=\"squidGuard error parsing squid line\"");
23        }
24          else {
25         src = Source;
26 @@ -206,14 +206,14 @@
27           acl = sgAclCheckSource(src);
28           if((redirect = sgAclAccess(src,acl,&squidInfo)) == NULL){
29             if(src == NULL || src->cont_search == 0){
30 -             puts(""); 
31 +             puts("ERR");
32               break;
33             } else
34               if(src->next != NULL){
35                 src = src->next;
36                 continue;
37               } else {
38 -               puts("");
39 +               puts("ERR");
40                 break;
41               }
42           } else {
43 @@ -228,6 +228,10 @@
44             fprintf(stdout,"%s %s/%s %s %s\n",redirect,squidInfo.src,
45                     squidInfo.srcDomain,squidInfo.ident,
46                     squidInfo.method);
47 +           if (isdigit(redirect[0]) && isdigit(redirect[1]) && isdigit(redirect[2]) && redirect[3]==':') {
48 +             fprintf(stdout,"OK status=%c%c%c url=\"%s\"\n", redirect[0], redirect[1], redirect[2], &redirect[4]);
49 +           } else
50 +             fprintf(stdout,"OK rewrite-url=\"%s\"\n",redirect);
51              /* sgLogDebug("DEBUG: %s %s/%s %s %s\n",redirect,squidInfo.src,squidInfo.srcDomain,squidInfo.ident,squidInfo.method);  */
52             break;
53           }
54 diff -ur squidGuard-1.5-beta.orig/src/main.c.in squidGuard-1.5-beta/src/main.c.in
55 --- squidGuard-1.5-beta.orig/src/main.c.in      2013-12-12 11:47:31.000000000 +1300
56 +++ squidGuard-1.5-beta/src/main.c.in   2013-12-12 11:53:18.000000000 +1300
57 @@ -185,7 +185,7 @@
58         sgReloadConfig();
59        }
60        if(failsafe_mode) {
61 -       puts("");
62 +       puts("ERR message=\"squidGuard failsafe mode\"");
63         fflush(stdout);
64         if(sig_hup){
65            sgReloadConfig();
66 @@ -194,7 +194,7 @@
67        }
68        if(parseLine(buf,&squidInfo) != 1){
69         sgLogError("ERROR: Error parsing squid line: %s",buf);
70 -       puts("");
71 +       puts("BH message=\"squidGuard error parsing squid line\"");
72        }
73          else {
74         src = Source;
75 @@ -206,14 +206,14 @@
76           acl = sgAclCheckSource(src);
77           if((redirect = sgAclAccess(src,acl,&squidInfo)) == NULL){
78             if(src == NULL || src->cont_search == 0){
79 -             puts(""); 
80 +             puts("ERR");
81               break;
82             } else
83               if(src->next != NULL){
84                 src = src->next;
85                 continue;
86               } else {
87 -               puts("");
88 +               puts("ERR");
89                 break;
90               }
91           } else {
92 @@ -225,9 +225,11 @@
93               squidInfo.ident[0] = '-';
94               squidInfo.ident[1] = '\0';
95             }
96 -           fprintf(stdout,"%s %s/%s %s %s\n",redirect,squidInfo.src,
97 -                   squidInfo.srcDomain,squidInfo.ident,
98 -                   squidInfo.method);
99 +           if (isdigit(redirect[0]) && isdigit(redirect[1]) && isdigit(redirect[2]) && redirect[3]==':') {
100 +             fprintf(stdout,"OK status=%c%c%c url=\"%s\"\n", redirect[0], redirect[1], redirect[2], &redirect[4]);
101 +           } else
102 +             fprintf(stdout,"OK rewrite-url=\"%s\"\n",redirect);
103 +
104              /* sgLogDebug("DEBUG: %s %s/%s %s %s\n",redirect,squidInfo.src,squidInfo.srcDomain,squidInfo.ident,squidInfo.method);  */
105             break;
106           }
107 diff -ur squidGuard-1.5-beta.orig/src/sgDiv.c squidGuard-1.5-beta/src/sgDiv.c
108 --- squidGuard-1.5-beta.orig/src/sgDiv.c        2013-12-12 11:47:31.000000000 +1300
109 +++ squidGuard-1.5-beta/src/sgDiv.c     2013-12-12 11:48:36.000000000 +1300
110 @@ -782,7 +782,7 @@
111    }
112    sgLogError("ERROR: Going into emergency mode");
113    while(fgets(buf, MAX_BUF, stdin) != NULL){
114 -    puts("");
115 +    puts("ERR");
116      fflush(stdout);
117    }
118    sgLogError("ERROR: Ending emergency mode, stdin empty");
119 diff -ur squidGuard-1.5-beta.orig/src/sgDiv.c.in squidGuard-1.5-beta/src/sgDiv.c.in
120 --- squidGuard-1.5-beta.orig/src/sgDiv.c.in     2013-12-12 11:47:31.000000000 +1300
121 +++ squidGuard-1.5-beta/src/sgDiv.c.in  2013-12-12 11:48:36.000000000 +1300
122 @@ -782,7 +782,7 @@
123    }
124    sgLogError("ERROR: Going into emergency mode");
125    while(fgets(buf, MAX_BUF, stdin) != NULL){
126 -    puts("");
127 +    puts("ERR");
128      fflush(stdout);
129    }
130    sgLogError("ERROR: Ending emergency mode, stdin empty");