| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Apache::ASP; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
141
|
use Apache::ASP::State; |
|
|
6
|
|
|
|
|
82
|
|
|
|
6
|
|
|
|
|
157
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
119
|
use strict; |
|
|
6
|
|
|
|
|
57
|
|
|
|
6
|
|
|
|
|
148
|
|
|
10
|
6
|
|
|
|
|
104
|
use vars qw( |
|
11
|
|
|
|
|
|
|
$CleanupGroups |
|
12
|
|
|
|
|
|
|
$SessionIDLength $SessionTimeout $StateManager |
|
13
|
|
|
|
|
|
|
$DefaultStateDB $DefaultStateSerializer |
|
14
|
6
|
|
|
6
|
|
93
|
); |
|
|
6
|
|
|
|
|
55
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$SessionTimeout = 20; |
|
17
|
|
|
|
|
|
|
$StateManager = 10; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$SessionIDLength = 32; |
|
23
|
|
|
|
|
|
|
$DefaultStateDB = 'SDBM_File'; |
|
24
|
|
|
|
|
|
|
$DefaultStateSerializer = 'Data::Dumper'; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub InitState { |
|
27
|
7
|
|
|
7
|
0
|
78
|
my $self = shift; |
|
28
|
7
|
|
|
|
|
84
|
my $r = $self->{r}; |
|
29
|
7
|
|
|
|
|
78
|
my $global_asa = $self->{GlobalASA}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
7
|
|
|
|
|
99
|
$self->{state_manager} = &config($self, 'StateManager', undef, $Apache::ASP::StateManager); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
7
|
|
|
|
|
106
|
$self->{state_dir} = &config($self, 'StateDir', undef, $self->{global}.'/.state'); |
|
38
|
7
|
|
|
|
|
81
|
$self->{state_dir} =~ tr///; |
|
39
|
7
|
|
|
|
|
92
|
$self->{session_state} = &config($self, 'AllowSessionState', undef, 1); |
|
40
|
7
|
|
|
|
|
91
|
$self->{state_serialize} = &config($self, 'ApplicationSerialize'); |
|
41
|
|
|
|
|
|
|
|
|
42
|
7
|
50
|
|
|
|
90
|
if($self->{state_db} = &config($self, 'StateDB')) { |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
0
|
$Apache::ASP::State::DB{$self->{state_db}} || |
|
45
|
|
|
|
|
|
|
$self->Error("$self->{state_db} is not supported for StateDB, try: " . |
|
46
|
|
|
|
|
|
|
join(", ", keys %Apache::ASP::State::DB)); |
|
47
|
0
|
|
|
|
|
0
|
$self->{state_db} =~ /^(.*)$/; |
|
48
|
0
|
|
|
|
|
0
|
$self->{state_db} = $1; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
$self->LoadModule('StateDB', $self->{state_db}); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
7
|
50
|
|
|
|
89
|
if($self->{state_serializer} = &config($self, 'StateSerializer')) { |
|
53
|
0
|
|
|
|
|
0
|
$self->{state_serializer} =~ tr///; |
|
54
|
0
|
|
|
|
|
0
|
$self->LoadModule('StateSerializer', $self->{state_serializer}); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
7
|
|
|
|
|
367
|
my %Internal; |
|
59
|
7
|
50
|
|
|
|
97
|
tie(%Internal, 'Apache::ASP::State', $self, 'internal', 'server') |
|
60
|
|
|
|
|
|
|
|| $self->Error("can't tie to internal state"); |
|
61
|
7
|
|
|
|
|
171
|
my $internal = $self->{Internal} = bless \%Internal, 'Apache::ASP::State'; |
|
62
|
7
|
50
|
|
|
|
153
|
$self->{state_serialize} && $internal->LOCK; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
7
|
|
|
|
|
96
|
$self->{app_state} = &config($self, 'AllowApplicationState', undef, 1); |
|
66
|
7
|
50
|
|
|
|
88
|
if($self->{app_state}) { |
|
67
|
|
|
|
|
|
|
|
|
68
|
7
|
|
|
|
|
210
|
require Apache::ASP::Application; |
|
69
|
|
|
|
|
|
|
|
|
70
|
7
|
50
|
|
|
|
99
|
($self->{Application} = &Apache::ASP::Application::new($self)) |
|
71
|
|
|
|
|
|
|
|| $self->Error("can't get application state"); |
|
72
|
7
|
50
|
|
|
|
147
|
$self->{state_serialize} && $self->{Application}->Lock; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} else { |
|
75
|
0
|
0
|
|
|
|
0
|
$self->{dbg} && $self->Debug("no application allowed config"); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
|
79
|
7
|
|
|
|
|
64
|
my $session; |
|
80
|
7
|
50
|
|
|
|
89
|
if($self->{session_state}) { |
|
81
|
|
|
|
|
|
|
|
|
82
|
7
|
|
|
|
|
111
|
$self->{cookie_path} = &config($self, 'CookiePath', undef, '/'); |
|
83
|
7
|
|
|
|
|
137
|
$self->{cookie_domain} = &config($self, 'CookieDomain'); |
|
84
|
7
|
|
|
|
|
90
|
$self->{paranoid_session} = &config($self, 'ParanoidSession'); |
|
85
|
7
|
|
|
|
|
161
|
$self->{remote_ip} = $r->connection()->remote_ip(); |
|
86
|
7
|
|
|
|
|
122
|
$self->{session_count} = &config($self, 'SessionCount'); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
7
|
|
|
|
|
119
|
$self->{session_url_parse_match} = &config($self, 'SessionQueryParseMatch'); |
|
90
|
7
|
|
33
|
|
|
147
|
$self->{session_url_parse} = $self->{session_url_parse_match} || &config($self, 'SessionQueryParse'); |
|
91
|
7
|
|
33
|
|
|
110
|
$self->{session_url_match} = $self->{session_url_parse_match} || &config($self, 'SessionQueryMatch'); |
|
92
|
7
|
|
33
|
|
|
147
|
$self->{session_url} = $self->{session_url_parse} || $self->{session_url_match} || &config($self, 'SessionQuery'); |
|
|
|
|
33
|
|
|
|
|
|
93
|
7
|
|
|
|
|
85
|
$self->{session_url_force} = &config($self, 'SessionQueryForce'); |
|
94
|
|
|
|
|
|
|
|
|
95
|
7
|
|
|
|
|
86
|
$self->{session_serialize} = &config($self, 'SessionSerialize'); |
|
96
|
7
|
|
|
|
|
87
|
$self->{secure_session} = &config($self, 'SecureSession'); |
|
97
|
|
|
|
|
|
|
|
|
98
|
7
|
|
|
|
|
91
|
$self->{session_timeout} = &config($self, 'SessionTimeout', undef, $SessionTimeout) * 60; |
|
99
|
7
|
|
50
|
|
|
108
|
$self->{'ua'} = $self->{headers_in}->get('User-Agent') || 'UNKNOWN UA'; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
|
103
|
7
|
|
|
|
|
139
|
$self->{group_refresh} = int($self->{session_timeout} / $self->{state_manager}); |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
|
108
|
7
|
|
|
|
|
289
|
require Apache::ASP::Session; |
|
109
|
|
|
|
|
|
|
|
|
110
|
7
|
|
33
|
|
|
108
|
$session = $self->{Session} = &Apache::ASP::Session::new($self) |
|
111
|
|
|
|
|
|
|
|| $self->Die("can't create session"); |
|
112
|
7
|
50
|
|
|
|
94
|
$self->{state_serialize} && $session->Lock(); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} else { |
|
115
|
0
|
0
|
|
|
|
0
|
$self->{dbg} && $self->Debug("no sessions allowed config"); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
7
|
|
|
|
|
124
|
$self->{Response}->IsClientConnected(); |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
7
|
50
|
|
|
|
77
|
if($session) { |
|
124
|
7
|
|
|
|
|
68
|
my $last_session_timeout; |
|
125
|
7
|
50
|
|
|
|
331
|
if($session->Started()) { |
|
126
|
|
|
|
|
|
|
|
|
127
|
7
|
50
|
|
|
|
86
|
if($self->{app_state}) { |
|
128
|
7
|
|
|
|
|
96
|
$internal->LOCK(); |
|
129
|
7
|
100
|
100
|
|
|
378
|
if(($last_session_timeout = $internal->{LastSessionTimeout} || 0) < time()) { |
|
130
|
1
|
|
|
|
|
15
|
$internal->{'LastSessionTimeout'} = $self->{session_timeout} + time; |
|
131
|
1
|
|
|
|
|
48
|
$internal->UNLOCK(); |
|
132
|
1
|
|
|
|
|
14
|
$self->{Application}->Lock; |
|
133
|
1
|
|
|
|
|
10
|
my $obj = tied(%{$self->{Application}}); |
|
|
1
|
|
|
|
|
12
|
|
|
134
|
1
|
50
|
|
|
|
15
|
if($self->CleanupGroups('PURGE')) { |
|
135
|
1
|
50
|
|
|
|
13
|
$last_session_timeout && $global_asa->ApplicationOnEnd(); |
|
136
|
1
|
|
|
|
|
17
|
$global_asa->ApplicationOnStart(); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
1
|
|
|
|
|
16
|
$self->{Application}->UnLock; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
7
|
|
|
|
|
458
|
$internal->UNLOCK(); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
7
|
|
|
|
|
107
|
$global_asa->SessionOnStart(); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
7
|
50
|
|
|
|
102
|
if($self->{app_state}) { |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
|
148
|
7
|
|
|
|
|
99
|
$internal->LOCK(); |
|
149
|
7
|
|
100
|
|
|
90
|
$last_session_timeout ||= $internal->{'LastSessionTimeout'}; |
|
150
|
7
|
100
|
|
|
|
327
|
if($last_session_timeout < $self->{session_timeout} + time + |
|
151
|
|
|
|
|
|
|
(rand() * $self->{group_refresh} / 2)) |
|
152
|
|
|
|
|
|
|
{ |
|
153
|
2
|
50
|
|
|
|
26
|
$self->{dbg} && $self->Debug("updating LastSessionTimeout from $last_session_timeout"); |
|
154
|
2
|
|
|
|
|
27
|
$internal->{'LastSessionTimeout'} = |
|
155
|
|
|
|
|
|
|
$self->{session_timeout} + time() + $self->{group_refresh}; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
7
|
|
|
|
|
108
|
$internal->UNLOCK(); |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
7
|
|
|
|
|
98
|
$self; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub CleanupGroup { |
|
172
|
6
|
|
|
6
|
0
|
62
|
my($self, $group_id, $force) = @_; |
|
173
|
6
|
50
|
|
|
|
67
|
return unless $self->{Session}; |
|
174
|
|
|
|
|
|
|
|
|
175
|
6
|
|
|
|
|
52
|
my $asp = $self; |
|
176
|
6
|
|
100
|
|
|
61
|
$force ||= 0; |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
|
|
179
|
6
|
|
|
|
|
50
|
my $state; |
|
180
|
6
|
50
|
|
|
|
59
|
unless($group_id) { |
|
181
|
0
|
|
|
|
|
0
|
$state = $self->{Session}{_STATE}; |
|
182
|
0
|
|
|
|
|
0
|
$group_id = $state->GroupId(); |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
|
186
|
6
|
50
|
|
|
|
59
|
$asp->Error("no group id") unless $group_id; |
|
187
|
6
|
|
|
|
|
57
|
my $group_key = "GroupId" . $group_id; |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
|
190
|
6
|
|
|
|
|
55
|
my $internal = $asp->{Internal}; |
|
191
|
6
|
|
|
|
|
68
|
$internal->LOCK(); |
|
192
|
6
|
|
100
|
|
|
76
|
my $group_check = $internal->{$group_key} || 0; |
|
193
|
6
|
50
|
66
|
|
|
237
|
unless($force || ($group_check < time())) { |
|
194
|
0
|
|
|
|
|
0
|
$internal->UNLOCK(); |
|
195
|
0
|
|
|
|
|
0
|
return; |
|
196
|
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
|
202
|
6
|
|
|
|
|
82
|
my $next_check = int($asp->{group_refresh} * rand()) + 1; |
|
203
|
6
|
|
|
|
|
73
|
$internal->{$group_key} = time() + $next_check; |
|
204
|
6
|
|
|
|
|
99
|
$internal->UNLOCK(); |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
|
207
|
6
|
|
33
|
|
|
84
|
$state ||= &Apache::ASP::State::new($asp, $group_id); |
|
208
|
6
|
|
50
|
|
|
74
|
my $ids = $state->GroupMembers() || []; |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
|
|
213
|
6
|
50
|
|
|
|
3889
|
$asp->{dbg} && $asp->Debug("group check $group_id, next in $next_check sec"); |
|
214
|
6
|
|
|
|
|
88
|
my $id = $self->{Session}->SessionID(); |
|
215
|
6
|
|
|
|
|
119
|
my $deleted = 0; |
|
216
|
6
|
|
|
|
|
73
|
$internal->LOCK(); |
|
217
|
6
|
50
|
|
|
|
65
|
$asp->{dbg} && $asp->Debug("checking group ids", $ids); |
|
218
|
6
|
|
|
|
|
59
|
for my $id (@$ids) { |
|
219
|
7
|
|
|
|
|
97
|
eval { |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
|
230
|
7
|
|
|
|
|
100
|
my $idata = $internal->{$id}; |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
|
233
|
7
|
50
|
33
|
|
|
140
|
unless(ref($idata) && (ref($idata) eq 'HASH')) { |
|
234
|
0
|
|
|
|
|
0
|
$idata = {}; |
|
235
|
|
|
|
|
|
|
} |
|
236
|
|
|
|
|
|
|
|
|
237
|
7
|
|
50
|
|
|
76
|
my $timeout = $idata->{timeout} || 0; |
|
238
|
|
|
|
|
|
|
|
|
239
|
7
|
50
|
|
|
|
70
|
unless($timeout) { |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
|
|
245
|
0
|
|
|
|
|
0
|
$idata->{timeout} = time() + $asp->{session_timeout}; |
|
246
|
0
|
|
|
|
|
0
|
$internal->{$id} = $idata; |
|
247
|
0
|
|
|
|
|
0
|
$asp->Debug("resetting timeout for $id to $idata->{timeout}"); |
|
248
|
0
|
|
|
|
|
0
|
return; |
|
249
|
|
|
|
|
|
|
} |
|
250
|
|
|
|
|
|
|
|
|
251
|
7
|
50
|
|
|
|
129
|
unless($timeout < time()) { |
|
252
|
7
|
50
|
|
|
|
73
|
$asp->{dbg} && $asp->Debug("$id not timed out with $timeout"); |
|
253
|
7
|
|
|
|
|
77
|
return; |
|
254
|
|
|
|
|
|
|
} |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
|
|
262
|
0
|
0
|
|
|
|
0
|
$asp->{dbg} && $asp->Debug("resetting timeout for deletion lock on $id"); |
|
263
|
0
|
|
|
|
|
0
|
$internal->{$id} = { |
|
264
|
0
|
|
|
|
|
0
|
%{$internal->{$id}}, |
|
265
|
|
|
|
|
|
|
'timeout' => time() + $asp->{session_timeout}, |
|
266
|
|
|
|
|
|
|
'end' => 1, |
|
267
|
|
|
|
|
|
|
}; |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
0
|
for (1..3) { $internal->UNLOCK() } |
|
|
0
|
|
|
|
|
0
|
|
|
272
|
0
|
|
|
|
|
0
|
$asp->{GlobalASA}->SessionOnEnd($id); |
|
273
|
0
|
|
|
|
|
0
|
$internal->LOCK; |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
0
|
my($member_state) = Apache::ASP::State::new($asp, $id); |
|
277
|
0
|
0
|
|
|
|
0
|
if(my $count = $member_state->Delete()) { |
|
278
|
0
|
0
|
|
|
|
0
|
$asp->{dbg} && |
|
279
|
|
|
|
|
|
|
$asp->Debug("deleting session", { |
|
280
|
|
|
|
|
|
|
session_id => $id, |
|
281
|
|
|
|
|
|
|
files_deleted => $count, |
|
282
|
|
|
|
|
|
|
}); |
|
283
|
0
|
|
|
|
|
0
|
$deleted++; |
|
284
|
0
|
|
|
|
|
0
|
delete $internal->{$id}; |
|
285
|
|
|
|
|
|
|
} else { |
|
286
|
0
|
|
|
|
|
0
|
$asp->Error("can't delete session id: $id"); |
|
287
|
0
|
|
|
|
|
0
|
return; |
|
288
|
|
|
|
|
|
|
} |
|
289
|
|
|
|
|
|
|
}; |
|
290
|
7
|
50
|
|
|
|
78
|
if($@) { |
|
291
|
0
|
|
|
|
|
0
|
$asp->Error("error for cleanup of session id $id: $@"); |
|
292
|
|
|
|
|
|
|
} |
|
293
|
|
|
|
|
|
|
} |
|
294
|
6
|
|
|
|
|
76
|
$internal->UNLOCK(); |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
|
|
303
|
6
|
50
|
|
|
|
65
|
if($deleted == @$ids) { |
|
304
|
0
|
0
|
|
|
|
0
|
if ($state->GroupId !~ /^[0]/) { |
|
305
|
0
|
|
|
|
|
0
|
$asp->{Internal}->LOCK(); |
|
306
|
0
|
|
|
|
|
0
|
my $ids = $state->GroupMembers(); |
|
307
|
0
|
0
|
|
|
|
0
|
if(@{$ids} == 0) { |
|
|
0
|
|
|
|
|
0
|
|
|
308
|
0
|
|
|
|
|
0
|
$self-> |