This file is indexed.

/usr/share/perl5/Plack/Session/Store/File.pm is in libplack-middleware-session-perl 0.25-1.

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
package Plack::Session::Store::File;
use strict;
use warnings;

our $VERSION   = '0.23';
our $AUTHORITY = 'cpan:STEVAN';

use Storable ();

use parent 'Plack::Session::Store';

use Plack::Util::Accessor qw[
    dir
    serializer
    deserializer
];

sub new {
    my ($class, %params) = @_;

    $params{'dir'} ||= $ENV{TMPDIR} || '/tmp';

    die "Storage directory (" . $params{'dir'} . ") is not writeable"
        unless -w $params{'dir'};

    $params{'serializer'}   ||= sub { Storable::lock_nstore( @_ ) };
    $params{'deserializer'} ||= sub { Storable::lock_retrieve( @_ ) };

    bless { %params } => $class;
}

sub fetch {
    my ($self, $session_id) = @_;

    my $file_path = $self->_get_session_file_path( $session_id );
    return unless -f $file_path;

    $self->deserializer->( $file_path );
}

sub store {
    my ($self, $session_id, $session) = @_;
    my $file_path = $self->_get_session_file_path( $session_id );
    $self->serializer->( $session, $file_path );
}

sub remove {
    my ($self, $session_id) = @_;
    unlink $self->_get_session_file_path( $session_id );
}

sub _get_session_file_path {
    my ($self, $session_id) = @_;
    $self->dir . '/' . $session_id;
}

1;

__END__

=pod

=head1 NAME

Plack::Session::Store::File - Basic file-based session store

=head1 SYNOPSIS

  use Plack::Builder;
  use Plack::Middleware::Session;
  use Plack::Session::Store::File;

  my $app = sub {
      return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Foo' ] ];
  };

  builder {
      enable 'Session',
          store => Plack::Session::Store::File->new(
              dir => '/path/to/sessions'
          );
      $app;
  };

  # with custom serializer/deserializer

  builder {
      enable 'Session',
          store => Plack::Session::Store::File->new(
              dir          => '/path/to/sessions',
              # YAML takes it's args the opposite order
              serializer   => sub { YAML::DumpFile( reverse @_ ) },
              deserializer => sub { YAML::LoadFile( @_ ) },
          );
      $app;
  };

=head1 DESCRIPTION

This implements a basic file based storage for session data. By
default it will use L<Storable> to serialize and deserialize the
data, but this can be configured easily. 

This is a subclass of L<Plack::Session::Store> and implements
its full interface.

=head1 METHODS

=over 4

=item B<new ( %params )>

The C<%params> can include I<dir>, I<serializer> and I<deserializer>
options. It will check to be sure that the I<dir> is writeable for
you.

=item B<dir>

This is the directory to store the session data files in, if nothing
is provided then "/tmp" is used.

=item B<serializer>

This is a CODE reference that implements the serialization logic.
The CODE ref gets two arguments, the C<$value>, which is a HASH
reference to be serialized, and the C<$file_path> to save it to.
It is not expected to return anything.

=item B<deserializer>

This is a CODE reference that implements the deserialization logic.
The CODE ref gets one argument, the C<$file_path> to load the data
from. It is expected to return a HASH reference.

=back

=head1 BUGS

All complex software has bugs lurking in it, and this module is no
exception. If you find a bug please either email me, or add the bug
to cpan-RT.

=head1 AUTHOR

Stevan Little E<lt>stevan.little@iinteractive.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright 2009, 2010 Infinity Interactive, Inc.

L<http://www.iinteractive.com>

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut