This file is indexed.

/usr/share/perl5/Lemonldap/NG/Common/PSGI/Cli/Lib.pm is in liblemonldap-ng-common-perl 1.9.16-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
package Lemonldap::NG::Common::PSGI::Cli::Lib;

use JSON;
use Mouse;
use Lemonldap::NG::Common::PSGI;

our $VERSION = '1.9.13';

has iniFile => ( is => 'ro', isa => 'Str' );

has app => ( is => 'ro', isa => 'CodeRef' );

sub _get {
    my ( $self, $path, $query ) = @_;
    $query //= '';
    return $self->app->(
        {
            'HTTP_ACCEPT'          => 'application/json, text/plain, */*',
            'SCRIPT_NAME'          => '',
            'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
            'SERVER_NAME'          => '127.0.0.1',
            'QUERY_STRING'         => $query,
            'HTTP_CACHE_CONTROL'   => 'max-age=0',
            'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
            'PATH_INFO'            => $path,
            'REQUEST_METHOD'       => 'GET',
            'REQUEST_URI'          => $path . ( $query ? "?$query" : '' ),
            'SERVER_PORT'          => '8002',
            'SERVER_PROTOCOL'      => 'HTTP/1.1',
            'HTTP_USER_AGENT' =>
              'Mozilla/5.0 (VAX-4000; rv:36.0) Gecko/20350101 Firefox',
            'REMOTE_ADDR' => '127.0.0.1',
            'HTTP_HOST'   => '127.0.0.1:8002'
        }
    );
}

sub _post {
    my ( $self, $path, $query, $body, $type, $len ) = @_;
    die "$body must be a IO::Handle"
      unless ( ref($body) and $body->can('read') );
    return $self->app->(
        {
            'HTTP_ACCEPT'          => 'application/json, text/plain, */*',
            'SCRIPT_NAME'          => '',
            'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
            'SERVER_NAME'          => '127.0.0.1',
            'QUERY_STRING'         => $query,
            'HTTP_CACHE_CONTROL'   => 'max-age=0',
            'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
            'PATH_INFO'            => $path,
            'REQUEST_METHOD'       => 'POST',
            'REQUEST_URI'          => $path . ( $query ? "?$query" : '' ),
            'SERVER_PORT'          => '8002',
            'SERVER_PROTOCOL'      => 'HTTP/1.1',
            'HTTP_USER_AGENT' =>
              'Mozilla/5.0 (VAX-4000; rv:36.0) Gecko/20350101 Firefox',
            'REMOTE_ADDR'          => '127.0.0.1',
            'HTTP_HOST'            => '127.0.0.1:8002',
            'psgix.input.buffered' => 1,
            'psgi.input'           => $body,
            'CONTENT_LENGTH'       => $len // scalar( ( stat $body )[7] ),
            'CONTENT_TYPE'         => $type,
        }
    );
}

sub _put {
    my ( $self, $path, $query, $body, $type, $len ) = @_;
    die "$body must be a IO::Handle"
      unless ( ref($body) and $body->can('read') );
    return $self->app->(
        {
            'HTTP_ACCEPT'          => 'application/json, text/plain, */*',
            'SCRIPT_NAME'          => '',
            'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
            'SERVER_NAME'          => '127.0.0.1',
            'QUERY_STRING'         => $query,
            'HTTP_CACHE_CONTROL'   => 'max-age=0',
            'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
            'PATH_INFO'            => $path,
            'REQUEST_METHOD'       => 'PUT',
            'REQUEST_URI'          => $path . ( $query ? "?$query" : '' ),
            'SERVER_PORT'          => '8002',
            'SERVER_PROTOCOL'      => 'HTTP/1.1',
            'HTTP_USER_AGENT' =>
              'Mozilla/5.0 (VAX-4000; rv:36.0) Gecko/20350101 Firefox',
            'REMOTE_ADDR'          => '127.0.0.1',
            'HTTP_HOST'            => '127.0.0.1:8002',
            'psgix.input.buffered' => 1,
            'psgi.input'           => $body,
            'CONTENT_LENGTH'       => $len // scalar( ( stat $body )[7] ),
            'CONTENT_TYPE'         => $type,
        }
    );
}

sub _del {
    my ( $self, $path, $query ) = @_;
    return $self->app->(
        {
            'HTTP_ACCEPT'          => 'application/json, text/plain, */*',
            'SCRIPT_NAME'          => '',
            'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
            'SERVER_NAME'          => '127.0.0.1',
            'QUERY_STRING'         => $query,
            'HTTP_CACHE_CONTROL'   => 'max-age=0',
            'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3',
            'PATH_INFO'            => $path,
            'REQUEST_METHOD'       => 'DELETE',
            'REQUEST_URI'          => $path . ( $query ? "?$query" : '' ),
            'SERVER_PORT'          => '8002',
            'SERVER_PROTOCOL'      => 'HTTP/1.1',
            'HTTP_USER_AGENT' =>
              'Mozilla/5.0 (VAX-4000; rv:36.0) Gecko/20350101 Firefox',
            'REMOTE_ADDR' => '127.0.0.1',
            'HTTP_HOST'   => '127.0.0.1:8002',
        }
    );
}

sub jsonResponse {
    my ( $self, $path, $query ) = @_;
    my $res = $self->_get( $path, $query )
      or die "Manager lib has refused my get, aborting";
    unless ( $res->[0] == 200 ) {
        require Data::Dumper;
        print STDERR "Result dump :\n" . Data::Dumper::Dumper($res);
        die "Manager lib does not return a 200 code, aborting";
    }
    my $href = from_json( $res->[2]->[0], { allow_nonref => 1 } )
      or die 'Response is not JSON';
    return $href;
}

sub jsonPostResponse {
    my ( $self, $path, $query, $body, $type, $len ) = @_;
    my $res = $self->_post( $path, $query, $body, $type, $len )
      or die "Manager lib has refused my post, aborting";
    unless ( $res->[0] == 200 ) {
        require Data::Dumper;
        print STDERR "Result dump :\n" . Data::Dumper::Dumper($res);
        die "Manager lib does not return a 200 code, aborting";
    }
    my $href = from_json( $res->[2]->[0], { allow_nonref => 1 } )
      or die 'Response is not JSON';
    return $href;
}

sub jsonPutResponse {
    my ( $self, $path, $query, $body, $type, $len ) = @_;
    my $res = $self->_put( $path, $query, $body, $type, $len )
      or die "Manager lib has refused my put, aborting";
    unless ( $res->[0] == 200 ) {
        require Data::Dumper;
        print STDERR "Result dump :\n" . Data::Dumper::Dumper($res);
        die "Manager lib does not return a 200 code, aborting";
    }
    my $href = from_json( $res->[2]->[0], { allow_nonref => 1 } )
      or die 'Response is not JSON';
    return $href;
}

1;