Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 542472 | Differences between
and this patch

Collapse All | Expand All

(-)squidGuard-1.5-beta.orig/src/main.c (-16 / +50 lines)
Lines 64-69 Link Here
64
int passthrough = 0;
64
int passthrough = 0;
65
int showBar = 0;   /* Do not display the progress bar. */
65
int showBar = 0;   /* Do not display the progress bar. */
66
char *globalCreateDb = NULL;
66
char *globalCreateDb = NULL;
67
int globalSquid34 = 0;
67
int failsafe_mode = 0;
68
int failsafe_mode = 0;
68
int sig_hup = 0;
69
int sig_hup = 0;
69
int sig_alrm = 0;
70
int sig_alrm = 0;
Lines 91-96 Link Here
91
  char buf[MAX_BUF];
92
  char buf[MAX_BUF];
92
  char *redirect,tmp[MAX_BUF];
93
  char *redirect,tmp[MAX_BUF];
93
  char *configFile = NULL;
94
  char *configFile = NULL;
95
  char *status = NULL, *endptr;
96
  long statusl = 0;
94
  time_t t;
97
  time_t t;
95
#if HAVE_SIGACTION
98
#if HAVE_SIGACTION
96
  struct sigaction act;
99
  struct sigaction act;
Lines 101-107 Link Here
101
#ifdef USE_SYSLOG
104
#ifdef USE_SYSLOG
102
openlog("squidGuard", LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL2);
105
openlog("squidGuard", LOG_PID | LOG_NDELAY | LOG_CONS, LOG_LOCAL2);
103
#endif
106
#endif
104
  while ((ch = getopt(argc, argv, "hbduPC:t:c:v")) != EOF)
107
  while ((ch = getopt(argc, argv, "hbdunPC:t:c:v")) != EOF)
105
    switch (ch) {
108
    switch (ch) {
106
    case 'd':
109
    case 'd':
107
       globalDebug = 1;
110
       globalDebug = 1;
Lines 124-129 Link Here
124
      fprintf(stderr, "SquidGuard: %s %s\n", VERSION,db_version(NULL,NULL,NULL));
127
      fprintf(stderr, "SquidGuard: %s %s\n", VERSION,db_version(NULL,NULL,NULL));
125
      exit(0);
128
      exit(0);
126
      break;
129
      break;
130
    case 'n':
131
      globalSquid34 = 1;
132
      break;
127
    case 't':
133
    case 't':
128
      if((t = iso2sec(optarg)) == -1){
134
      if((t = iso2sec(optarg)) == -1){
129
	fprintf(stderr,"-t dateformat error, should be yyyy-mm-ddTHH:MM:SS\n");
135
	fprintf(stderr,"-t dateformat error, should be yyyy-mm-ddTHH:MM:SS\n");
Lines 185-191 Link Here
185
	sgReloadConfig();
191
	sgReloadConfig();
186
      }
192
      }
187
      if(failsafe_mode) {
193
      if(failsafe_mode) {
188
	puts("");
194
	if (globalSquid34) puts("ERR message=\"squidGuard failsafe mode\"");
195
	else puts("");
189
	fflush(stdout);
196
	fflush(stdout);
190
	if(sig_hup){
197
	if(sig_hup){
191
          sgReloadConfig();
198
          sgReloadConfig();
Lines 194-200 Link Here
194
      }
201
      }
195
      if(parseLine(buf,&squidInfo) != 1){
202
      if(parseLine(buf,&squidInfo) != 1){
196
	sgLogError("ERROR: Error parsing squid line: %s",buf);
203
	sgLogError("ERROR: Error parsing squid line: %s",buf);
197
	puts("");
204
	if (globalSquid34) puts("BH message=\"squidGuard error parsing squid line\"");
205
	else puts("");
198
      }
206
      }
199
        else {
207
        else {
200
	src = Source;
208
	src = Source;
Lines 206-234 Link Here
206
	  acl = sgAclCheckSource(src);
214
	  acl = sgAclCheckSource(src);
207
	  if((redirect = sgAclAccess(src,acl,&squidInfo)) == NULL){
215
	  if((redirect = sgAclAccess(src,acl,&squidInfo)) == NULL){
208
	    if(src == NULL || src->cont_search == 0){
216
	    if(src == NULL || src->cont_search == 0){
209
	      puts(""); 
217
	      if (globalSquid34) puts("ERR");
218
	      else puts("");
210
	      break;
219
	      break;
211
	    } else
220
	    } else
212
	      if(src->next != NULL){
221
	      if(src->next != NULL){
213
		src = src->next;
222
		src = src->next;
214
		continue;
223
		continue;
215
	      } else {
224
	      } else {
216
		puts("");
225
		if (globalSquid34) puts("ERR");
226
		else puts("");
217
		break;
227
		break;
218
	      }
228
	      }
219
	  } else {
229
	  } else {
220
	    if(squidInfo.srcDomain[0] == '\0'){
230
	    if (globalSquid34) {
221
	      squidInfo.srcDomain[0] = '-';
231
	      status = strsep(&redirect, ":");
222
	      squidInfo.srcDomain[1] = '\0';
232
	      if (status != NULL) {
223
	    }
233
	        // trying to check the 1st colon-separeted field to be a HTTP status
224
	    if(squidInfo.ident[0] == '\0'){
234
	        statusl = strtol(status, &endptr, 10);
225
	      squidInfo.ident[0] = '-';
235
	        // if the 1st field is not an acceptable HTTP status then restore the string
226
	      squidInfo.ident[1] = '\0';
236
	        switch (statusl) {
237
	        case 301:
238
	        case 302:
239
	        case 303:
240
	        case 307:
241
	        case 308:
242
	          break;
243
	        default:
244
	          statusl = 0;
245
	          redirect = status;
246
	          redirect[strlen(redirect)] = ':';
247
	        }
248
	      }
249
	      if (statusl) fprintf(stdout, "OK status=%s url=\"%s\"\n", status, redirect);
250
	      else fprintf(stdout, "OK rewrite-url=\"%s\"\n", redirect);
251
	    } else {
252
	      if(squidInfo.srcDomain[0] == '\0'){
253
	        squidInfo.srcDomain[0] = '-';
254
	        squidInfo.srcDomain[1] = '\0';
255
	      }
256
	      if(squidInfo.ident[0] == '\0'){
257
	        squidInfo.ident[0] = '-';
258
	        squidInfo.ident[1] = '\0';
259
	      }
260
	      fprintf(stdout,"%s %s/%s %s %s\n",redirect,squidInfo.src,
261
		      squidInfo.srcDomain,squidInfo.ident,
262
		      squidInfo.method);
263
	      /* sgLogDebug("DEBUG: %s %s/%s %s %s\n",redirect,squidInfo.src,squidInfo.srcDomain,squidInfo.ident,squidInfo.method);  */
227
	    }
264
	    }
228
	    fprintf(stdout,"%s %s/%s %s %s\n",redirect,squidInfo.src,
229
		    squidInfo.srcDomain,squidInfo.ident,
230
		    squidInfo.method);
231
            /* sgLogDebug("DEBUG: %s %s/%s %s %s\n",redirect,squidInfo.src,squidInfo.srcDomain,squidInfo.ident,squidInfo.method);  */
232
	    break;
265
	    break;
233
	  }
266
	  }
234
	} /*for(;;)*/
267
	} /*for(;;)*/
Lines 271-276 Link Here
271
  fprintf(stderr, 
304
  fprintf(stderr, 
272
	  "Usage: squidGuard [-u] [-C block] [-t time] [-c file] [-v] [-d] [-P]\n");
305
	  "Usage: squidGuard [-u] [-C block] [-t time] [-c file] [-v] [-d] [-P]\n");
273
  fprintf(stderr, "Options:\n");
306
  fprintf(stderr, "Options:\n");
307
  fprintf(stderr, "  -n          : Use Squid 3.4+ reply format");
274
  fprintf(stderr, "  -v          : show version number\n");
308
  fprintf(stderr, "  -v          : show version number\n");
275
  fprintf(stderr, "  -d          : all errors to stderr\n");
309
  fprintf(stderr, "  -d          : all errors to stderr\n");
276
  fprintf(stderr, "  -b          : switch on the progress bar when updating the blacklists\n");
310
  fprintf(stderr, "  -b          : switch on the progress bar when updating the blacklists\n");
(-)squidGuard-1.5-beta.orig/src/sgDiv.c (-1 / +4 lines)
Lines 21-26 Link Here
21
21
22
/* #define METEST 8; */
22
/* #define METEST 8; */
23
23
24
extern int globalSquid34;
25
24
#if __STDC__
26
#if __STDC__
25
void sgHandlerSigHUP(int signal)
27
void sgHandlerSigHUP(int signal)
26
#else
28
#else
Lines 782-788 Link Here
782
  }
784
  }
783
  sgLogError("ERROR: Going into emergency mode");
785
  sgLogError("ERROR: Going into emergency mode");
784
  while(fgets(buf, MAX_BUF, stdin) != NULL){
786
  while(fgets(buf, MAX_BUF, stdin) != NULL){
785
    puts("");
787
    if (globalSquid34) puts("ERR message=\"squidGuard emergency mode\"");
788
    else puts("");
786
    fflush(stdout);
789
    fflush(stdout);
787
  }
790
  }
788
  sgLogError("ERROR: Ending emergency mode, stdin empty");
791
  sgLogError("ERROR: Ending emergency mode, stdin empty");

Return to bug 542472