This file is indexed.

/usr/share/perl5/Perlbal/Plugin/NotModified.pm is in libperlbal-perl 1.80-3.

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
package Perlbal::Plugin::NotModified;

use Perlbal;
use strict;
use warnings;

# Takes settings in perlbal like:
# SET ss.notmodified.host_pattern = ^example\.com
#
# The value is a regular expression to match against the Host: header on the incoming request.

sub load {
    my $class = shift;
    return 1;
}

sub unload {
    my $class = shift;
    return 1;
}

# called when we're being added to a service
sub register {
    my ($class, $svc) = @_;

    my $host_check_regex = undef;

    my $start_http_request_hook =  sub {
        my Perlbal::ClientHTTPBase $client = shift;
        my Perlbal::HTTPHeaders $hds = $client->{req_headers};
        return 0 unless $hds;

        my $uri = $hds->request_uri;

        return 0 unless $uri;

        my $host = $hds->header("Host");

        return 0 unless $host;
        return 0 unless $host =~ $host_check_regex;

        my $ims = $hds->header("If-Modified-Since");

        return 0 unless $ims;

        $client->send_response(304, "Not Modified");

        return 1;
    };

    # register things to take in configuration regular expressions
    $svc->register_setter('NotModified', 'host_pattern', sub {
        my ($out, $what, $val) = @_;
        return 0 unless $what && $val;

        my $err = sub {
            $out->("ERROR: $_[0]") if $out;
            return 0;
        };

        unless (length $val) {
            $host_check_regex = undef;
            $svc->unregister_hooks('NotModified');
            return 1;
        }

        $host_check_regex = qr/$val/;
        $svc->register_hook('NotModified', 'start_http_request', $start_http_request_hook);

        return 1;
    });

    return 1;
}

# called when we're no longer active on a service
sub unregister {
    my ($class, $svc) = @_;
    $svc->unregister_hooks('NotModified');
    $svc->unregister_setters('NotModified');
    return 1;
}

1;