This file is indexed.

/usr/share/perl5/Net/HTTPServer/Session.pm is in libnet-httpserver-perl 1.1.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
##############################################################################
#
#  This library is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Library General Public
#  License as published by the Free Software Foundation; either
#  version 2 of the License, or (at your option) any later version.
#
#  This library is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Library General Public License for more details.
#
#  You should have received a copy of the GNU Library General Public
#  License along with this library; if not, write to the
#  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
#  Boston, MA  02111-1307, USA.
#
#  Copyright (C) 2003-2005 Ryan Eatmon
#
##############################################################################
package Net::HTTPServer::Session;

=head1 NAME

Net::HTTPServer::Session - HTTP server side client session

=head1 SYNOPSIS

Net::HTTPServer::Session handles server side client sessions
  
=head1 DESCRIPTION

Net::HTTPServer::Session provides a server side data store for client
specific sessions.  It uses a cookie stored on the browser to tell
the server which session to restore to the user.  This is modelled
after the PHP session concept.  The session is valid for 4 hours from
the last time the cookie was sent.

=head1 EXAMPLES

sub pageHandler
{
    my $request = shift;
    
    my $session = $request->Session();

    my $response = $request->Response();

    # Logout
    $session->Destroy() if $request->Env("logout");

    $response->Print("<html><head><title>Hi there</title></head><body>");
    
    # If the user specified a username on the URL, then save it.
    if ($request->Env("username"))
    {
        $session->Set("username",$request->Env("username"));
    }
    
    # If there is a saved username, then use it.
    if ($session->Get("username"))
    {
        $response->Print("Hello, ",$session->Get("username"),"!");
    }
    else
    {
        $response->Print("Hello, stranger!");
    }

    $response->Print("</body></html>");

    return $response;
}

The above would behave as follows:

  http://server/page                - Hello, stranger!
  http://server/page?username=Bob   - Hello, Bob!
  http://server/page                - Hello, Bob!
  http://server/page?username=Fred  - Hello, Fred!
  http://server/page                - Hello, Fred!
  http://server/page?logout=1       - Hello, stranger!
  http://server/page                - Hello, stranger!

=head1 METHODS

=head2 Delete(var)

Delete the specified variable from the session.

=head2 Destroy()

Destroy the session.  The server side data is deleted and the cookie
will be expired.

=head2 Exists(var)

Returns if the specified variable exists in the sesion.

=head2 Get(var)

Return the value of the specified variable from the session if it
exists, undef otherwise.

=head2 Set(var,value)

Store the specified value (scalar or reference to any Perl data
structure) in the session.

=head1 AUTHOR

Ryan Eatmon

=head1 COPYRIGHT

Copyright (c) 2003-2005 Ryan Eatmon <reatmon@mail.com>. All rights
reserved.  This program is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.

=cut
  
use strict;
use Carp;
use Data::Dumper;

use vars qw ( $VERSION $SESSION_COUNT %data );

$VERSION = "1.0.3";

$SESSION_COUNT = 0;

sub new
{
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my $self = { };
    
    bless($self, $proto);

    my (%args) = @_;
    
    $self->{ARGS} = \%args;

    $self->{KEY} = $self->_arg("key",undef);
    $self->{SERVER} = $self->_arg("server",undef);

    return unless $self->{SERVER}->{CFG}->{SESSIONS};

    $self->{KEY} = $self->_genkey()
        if (!defined($self->{KEY}) ||
            ($self->{KEY} eq "") ||
            ($self->{KEY} =~ /\//)
           );

    $self->{FILE} = $self->{SERVER}->{CFG}->{DATADIR}."/".$self->{KEY};
    
    #XXX Check that server (Net::HTTPServer object) is defined
    
    $self->{VALID} = 1;
    $self->{DATA} = {};
    $self->_load();

    return $self;
}


sub Delete
{
    my $self = shift;
    my $var = shift;

    return unless $self->Exists($var);
    delete($self->{DATA}->{$var});
}


sub Destroy
{
    my $self = shift;

    $self->{VALID} = 0;
}


sub Exists
{
    my $self = shift;
    my $var = shift;

    return unless $self->_valid();
    return exists($self->{DATA}->{$var});
}


sub Get
{
    my $self = shift;
    my $var = shift;

    return unless $self->Exists($var);
    return $self->{DATA}->{$var};
}


sub Set
{
    my $self = shift;
    my $var = shift;
    my $value = shift;

    return unless $self->_valid();
    $self->{DATA}->{$var} = $value if defined($value);
}


###############################################################################
#
# _arg - if the arg exists then use it, else use the default.
#
###############################################################################
sub _arg
{
    my $self = shift;
    my $arg = shift;
    my $default = shift;

    return (exists($self->{ARGS}->{$arg}) ? $self->{ARGS}->{$arg} : $default);
}


sub _genkey
{
    my $self = shift;

    $SESSION_COUNT++;
    my $key = "NetHTTPServerSession".$SESSION_COUNT.$$.time;

    if ($Net::HTTPServer::DigestMD5 == 1)
    {
        $key = Digest::MD5::md5_hex($key);
    }

    return $key;
}


sub _key
{
    my $self = shift;

    return $self->{KEY};
}


sub _load
{
    my $self = shift;

    return unless $self->_valid();

    return unless (-f $self->{FILE});

    undef(%data);
    
    my $data;
    open(DATA,$self->{FILE}) || return;
    read(DATA, $data, (-s DATA));
    close(DATA);

    eval $data;
    
    if (!$@)
    {
        $self->{DATA} = \%data;
    }
}


sub _save
{
    my $self = shift;

    if (!$self->_valid())
    {
        unlink($self->{FILE}) if (-f $self->{FILE});
        return;
    }

    my $dumper = new Data::Dumper([$self->{DATA}],["*data"]);
    $dumper->Purity(1);

    open(DATA,">".$self->{FILE});
    print DATA $dumper->Dump();
    close(DATA);
}


sub _valid
{
    my $self = shift;

    return (exists($self->{VALID}) && ($self->{VALID} == 1));
}


1;