summaryrefslogtreecommitdiff
path: root/www/squidguard/files/extra-patch-strip.diff
blob: ed93611810d46a53b5c35faf847a7e061dfcdaf7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
diff -ruN ../squidGuard-1.4.orig/doc/authentication.html ./doc/authentication.html
--- ../squidGuard-1.4.orig/doc/authentication.html	2015-04-22 12:42:14.937955000 -0500
+++ ./doc/authentication.html	2015-04-22 12:42:54.745042000 -0500
@@ -345,10 +345,43 @@
 </div>
 <br>
 
-
-
-
-
+<li> <b>Stripping NT domain name or Kerberos Realm from user name </b><br><br>
+ 
+(You need squidGuard version 1.5 or higher to use user name stripping.)<br>
+If the authentication is made with NTLM or Kerberos, it contains NT domain
+or Kerberos realm. The following tags exist :
+<br><br>
+<table border=0 cellpadding=2 cellspacing=2>
+	<tr>
+		<td valign=top>stripntdomain</td><td> Strip NT domain name component from
+			      user names (/ or \ separated).
+			</tr><tr>
+			<td valign=top>striprealm</td><td> Strip Kerberos Realm component from
+				      user names (@ separated).
+				</tr><tr>
+				</tr><tr>
+				</tr>
+			</table>
+		
+		<br><br>
+		Example configuration:<br>
+		<br>
+		<div style=width:700px;overflow:auto>
+			<table width="75%" cellpadding="0" cellspacing="0" style="background-color:
+				#f2fff0; border: solid 1px #4455bb;">
+				<tr>
+					<td style="background-color: #223499; border-bottom: 1px solid #888;">
+						<font size="-1" color=white>Stripping NT domain name or Kerberos Realm from user name </font>
+						</td></tr>
+				<tr>
+					<td>
+						<pre> stripntdomain true
+ striprealm true
+</pre>
+					</td></tr>
+			</table>
+		</div>
+	<br> 
 
 </td></tr></table>
 
diff -ruN ../squidGuard-1.4.orig/src/sg.h.in ./src/sg.h.in
--- ../squidGuard-1.4.orig/src/sg.h.in	2015-04-22 12:42:14.931469000 -0500
+++ ./src/sg.h.in	2015-04-22 12:42:54.738534000 -0500
@@ -82,6 +82,8 @@
 #define DEFAULT_CONFIGFILE "@prefix@/squidGuard/squidGuard.conf"
 #define DEFAULT_LOGDIR "@prefix@/squidGuard/log"
 #define DEFAULT_DBHOME "@prefix@/squidGuard/db"
+#define DEFAULT_STRIPNTDOMAIN "false"
+#define DEFAULT_STRIPREALM "false"
 #define EXEC_PROGRAM "@prefix@/bin/squidGuard"
 
 #ifdef ACCONFIG
diff -ruN ../squidGuard-1.4.orig/src/sg.l ./src/sg.l
--- ../squidGuard-1.4.orig/src/sg.l	2015-04-22 12:42:14.932909000 -0500
+++ ./src/sg.l	2015-04-22 12:42:54.740080000 -0500
@@ -105,6 +105,8 @@
 ^acl         return ACL;
 ^dbhome                return DBHOME;
 ^logdir                return LOGDIR;
+^stripntdomain return STRIPNTDOMAIN;
+^striprealm    return STRIPREALM;
 ^ldapcachetime return LDAPCACHETIME;
 ^ldapprotover  return LDAPPROTOVER;
 ^ldapbinddn    { BEGIN LDAPDN_STATE; return LDAPBINDDN; }
diff -ruN ../squidGuard-1.4.orig/src/sg.y.in ./src/sg.y.in
--- ../squidGuard-1.4.orig/src/sg.y.in	2015-04-22 12:42:14.932264000 -0500
+++ ./src/sg.y.in	2015-04-22 12:44:41.473988000 -0500
@@ -116,6 +117,7 @@
 %type <string> tval
 %type <string> date
 %type <string> ttime
+%type <string> STRIPNTDOMAIN STRIPREALM
 %%
 
 start: statements
@@ -127,6 +129,12 @@
 logdir:    LOGDIR WORD { sgSetting("logdir",$2); }
          ;
 
+stripntdomain: STRIPNTDOMAIN WORD { sgSetting("stripntdomain",$2); }
+         ;
+
+striprealm: STRIPREALM WORD { sgSetting("striprealm",$2); }
+         ;
+ 
 ldapcachetime: LDAPCACHETIME NUMBER { sgSetting("ldapcachetime",$2); }
          ;
 
@@ -352,6 +360,8 @@
 	     | destination_block
              | dbhome
 	     | logdir
+             | stripntdomain
+             | striprealm 
             | ldapprotover
             | ldapbinddn
             | ldapbindpass
diff -ruN ../squidGuard-1.4.orig/src/sgDiv.c ./src/sgDiv.c
--- ../squidGuard-1.4.orig/src/sgDiv.c	2015-04-22 12:42:14.931973000 -0500
+++ ./src/sgDiv.c	2015-04-22 12:49:24.400088000 -0500
@@ -223,11 +223,34 @@
       break;
     case 1: /* ident */
       if(strcmp(p,"-")){
-	strcpy(s->ident,p);
-	for(p=s->ident; *p != '\0'; p++) /* convert ident to lowercase chars */
-	  *p = tolower(*p);
+        char *stripntdomain = NULL, *striprealm = NULL;
+        HTUnEscape(p);
+        stripntdomain = sgSettingGetValue("stripntdomain");
+        if(stripntdomain == NULL)
+          stripntdomain = DEFAULT_STRIPNTDOMAIN;
+        striprealm = sgSettingGetValue("striprealm");
+        if(striprealm == NULL)
+	  striprealm = DEFAULT_STRIPREALM;
+        if (strcmp(stripntdomain,"false")) {
+           char *u = strrchr(p, '\\');
+           if (!u)
+              u = strrchr(p, '/');
+           if (!u)
+              u = strrchr(p, '+');
+           if (u && u[1])
+              p = u + 1;
+        }
+        if (strcmp(striprealm,"false")) {
+           char *u = strchr(p, '@');
+           if (u != NULL) {
+              *u = '\0';
+           }
+        }
+        strcpy(s->ident,p);
+        for(p=s->ident; *p != '\0'; p++) /* convert ident to lowercase chars */
+           *p = tolower(*p);
       } else
-	s->ident[0] = '\0';
+        s->ident[0] = '\0';
       break;
     case 2: /* method */
       strcpy(s->method,p);
@@ -734,7 +757,7 @@
       p++;
       break;
     case 'u': /* Requested URL */
-      strcat(buf, req->orig);
+      strncat(buf, req->orig, 2048);
       p++;
       break;
     default:
diff -ruN ../squidGuard-1.4.orig/src/sgDiv.c.in ./src/sgDiv.c.in
--- ../squidGuard-1.4.orig/src/sgDiv.c.in	2015-04-22 12:42:14.932693000 -0500
+++ ./src/sgDiv.c.in	2015-04-22 12:48:38.406521000 -0500
@@ -234,11 +234,34 @@
       break;
     case 1: /* ident */
       if(strcmp(p,"-")){
-	strcpy(s->ident,p);
-	for(p=s->ident; *p != '\0'; p++) /* convert ident to lowercase chars */
-	  *p = tolower(*p);
+        char *stripntdomain = NULL, *striprealm = NULL;
+        HTUnEscape(p);
+        stripntdomain = sgSettingGetValue("stripntdomain");
+        if (stripntdomain == NULL)
+           stripntdomain = DEFAULT_STRIPNTDOMAIN;
+        striprealm = sgSettingGetValue("striprealm");
+        if (striprealm == NULL)
+           striprealm = DEFAULT_STRIPREALM;
+        if (strcmp(stripntdomain,"false")) {
+           char *u = strrchr(p, '\\');
+           if (!u)
+              u = strrchr(p, '/');
+           if (!u)
+              u = strrchr(p, '+');
+           if (u && u[1])
+              p = u + 1;
+        }
+        if (strcmp(striprealm,"false")) {
+           char *u = strchr(p, '@');
+           if (u != NULL) {
+              *u = '\0';
+           }
+        }
+        strcpy(s->ident,p);
+        for(p=s->ident; *p != '\0'; p++) /* convert ident to lowercase chars */
+           *p = tolower(*p);
       } else
-	s->ident[0] = '\0';
+        s->ident[0] = '\0';
       break;
     case 2: /* method */
       strcpy(s->method,p);