This file is indexed.

/usr/share/perl5/OpenSRS/Util/Session.pm is in libopensrs-perl 3.0.0-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
157
158
#!/usr/bin/perl

#       .Copyright (C)  1999-2002 TUCOWS.com Inc.
#       .Created:       11/19/1999
#       .Contactid:     <admin@opensrs.org>
#       .Url:           http://www.opensrs.org
#       .Originally Developed by:
#                       Tucows/OpenSRS
#       .Authors:       Evgeniy Pirogov
#
#
#       This program is free software; you can redistribute it and/or
#       modify it under the terms of the GNU Lesser General Public 
#       License as published by the Free Software Foundation; either 
#       version 2.1 of the License, or (at your option) any later version.
#
#       This program 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
#       Lesser General Public License for more details.
#
#       You should have received a copy of the GNU Lesser General Public
#       License along with this program; if not, write to the Free Software
#       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

package OpenSRS::Util::Session;

use strict;
use Core::Checksum qw/calculate compare/;
use Data::Dumper;
use Core::Exception;


sub import {
    my $pkg = shift;
    my $var = shift;
    OpenSRS::Util::Session::Serializer::init($var);
}

sub new {
    my $class = shift;
    return bless {@_},$class;
}

sub add {
    my $self = shift;
    while (@_){
	my $name = shift;
	return unless $name;
	my $val = shift;
    	$self->{$name} = $val;
    }
}

sub dump {
    my $self = shift;
    my $salt = shift;
    throw 'dev','Salt not specified ' unless $salt;
    my $dump = OpenSRS::Util::Session::Serializer::store(%$self);
    return (session => $dump, sign => calculate($dump,$salt));    
}

sub restore {
    my $class = shift;
    my $dump = shift;
    return $class->new unless $dump; 

    my $sign = shift;
    my $salt = shift;
    throw 'dev','Salt not specified ' unless $salt;
    unless (compare($sign, $dump,$salt)){
	return $class->new;
    }
    my $VAR1 =  OpenSRS::Util::Session::Serializer::restore($dump);
    return $class->new(%$VAR1);
}


package OpenSRS::Util::Session::Serializer;

use strict;
use Core::Exception;
use warnings;

my $defaultSerializer = 'Data::Dumper';

my %methods = (
    'Data::Dumper' => q/
use Data::Dumper;
sub store { 
    local $Data::Dumper::Indent = 0;
    local $Data::Dumper::Useqq = 1;
    local $Data::Dumper::Purity = 1; 
    local $Data::Dumper::Deepcopy = 1; 
    my %hash = @_;
    my $result = Dumper(\%hash);
    $result =~ s#(.)#sprintf("%x", ord($1))#eg;
    return $result;
}

sub restore {
    my $VAR1;
    my $dump = shift;
    $dump =~ s#(..)#sprintf("%c", hex($1))#eg;
    eval($dump);
    if ($@){
        throw 'dev',"Can't restore session %s [%s]",$dump,$@;
    }
    unless (ref $VAR1 eq 'HASH'){
        throw 'dev',"Session is not hash %s",$dump;
    }
    return $VAR1;
}
/,
    'OPS' => q/
use OPS;
our $OPS = new OPS(option => 'compress');
sub store { 
    my %hash = @_;
    my $result = $OPS->encode(\%hash);
    $result =~ s#(.)#sprintf("%x", ord($1))#eg;
    return $result;
}

sub restore {
    my $dump = shift;
    $dump =~ s#(..)#sprintf("%c", hex($1))#eg;
    my $VAR1 = $OPS->decode($dump);
    if ($VAR1->{'response_code'} eq 'OPS_ERR'){
        throw 'dev',"Can't restore session %s",$dump;
    }
    unless (ref $VAR1 eq 'HASH'){
        throw 'dev',"Session  is not hash %s",$dump,$@;
    }
    return $VAR1;
}
/,
);

sub init {
    my $type = shift;
    $type ||= $defaultSerializer;
    throw 'dev','Wrong serializer type [%s]',$type unless exists $methods{$type};
    {
	$^W = 0;
	eval ($methods{$type});
	throw 'dev','Cant init serializer %s [%s]',$type,$@ if $@;
    }
}

sub store {
    die 'Serialier not inited'
}

sub restore {
    die 'Serialier not inited'
}
1;