This file is indexed.

/usr/share/perl5/Nagios/Config/File.pm is in libnagios-object-perl 0.21.20-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
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
package Nagios::Config::File;

use strict;
use warnings;
use Carp;
use Symbol;

# NOTE: due to CPAN version checks this cannot currently be changed to a
# standard version string, i.e. '0.21'
our $VERSION = '35';

my %DUPLICATES_ALLOWED = (
    cfg_file => 1,
    cfg_dir  => 1,
);

=head1 NAME

Nagios::Config::File - Base class for Nagios configuration files

=head1 SYNOPSIS

  use Nagios::Config ;
  my $nc = new Nagios::Config("/usr/local/nagios/etc/nagios.cfg") ;
  my $resource = $nc->get_resource_cfg() ; 
  print $resource->get_attr('$USER1$') . "\n" ;

=head1 DESCRIPTION

C<Nagios::Config::File> is the base class for all Nagios configuration
files. You should not need to create these yourself.

=cut

=head1 CONSTRUCTOR

=over 4

=item new ([FILE])

Creates a C<Nagios::Config::File>.

=back

=cut

sub new {
    my $class = shift;
    my $file  = shift;

    croak "Missing argument: must specify a configuration file to parse."
        if ( !$file );

    my $this = {};
    bless( $this, $class );

    my $fh = undef;
    if ( ref($file) ) {
        $fh = $file;
    }
    else {
        $fh = gensym;
        open( $fh, "<$file" )
            || croak("Can't open $file for reading: $!");
        $this->{filename} = $file;
    }

    $this->{file_attributes} = {};
    $this->{fh}              = $fh;

    $this->parse();
    close($fh);

    return $this;
}

sub parse {
    my $this = shift;

    my $fh = $this->{fh};

    while (<$fh>) {
        my $line = $this->strip($_);

        if ( $this->is_comment($line) ) {
            next;
        }
        elsif ( my ( $name, $value ) = $this->is_attribute($line) ) {
            if ( $DUPLICATES_ALLOWED{$name} ) {
                push @{ $this->{file_attributes}->{$name} }, $value;
            }
            else {
                $this->{file_attributes}->{$name} = $value;
            }
        }
    }
}

sub strip {
    my $this = shift;
    my $line = shift;

    $line =~ s/^\s+//;
    $line =~ s/\s+$//;

    return $line;
}

sub is_comment {
    my $this = shift;
    my $line = shift;

    if ( ( $line eq '' ) || ( $line =~ /^#/ ) ) {
        return 1;
    }

    return 0;
}

sub is_attribute {
    my $this = shift;
    my $line = shift;

    if ( $line =~ /^([\w\$]+)\s*=\s*(.+)$/ ) {
        return ( $1, $2 );
    }

    return ();
}

=head1 METHODS

=over 4

=item get ([NAME], [SPLIT])

Returns the value of the attribute C<NAME> for the current file.
If C<SPLIT> is true, returns a list of all the values split on
/\s*,\s*/. This is useful for attributes that can have more that one value.

=cut

sub get {
    my ( $this, $name, $split ) = @_;
    my $val = $this->{file_attributes}->{$name};
    return $split ? split( /\s*,\s*/, $val ) : $val;
}
sub get_attr { &get; }

=item filename()

Returns the filename for the current object.

=cut

sub filename { $_[0]->{filename} }

=item dump ()

Returns a scalar with the full configuration text ready to parse again.

=cut

sub dump {
    my $this   = shift;
    my $outtxt = "# filename: $this->{filename}\n";
    foreach my $attr ( keys( %{ $this->{file_attributes} } ) ) {
        if ( $DUPLICATES_ALLOWED{$attr} ) {
            foreach my $element ( @{ $this->{file_attributes}{$attr} } ) {
                $outtxt .= $attr . '=' . $element . "\n";
            }
        }
        else {
            $outtxt .= $attr . '=' . $this->{file_attributes}{$attr} . "\n";
        }
    }
    return $outtxt;
}

1;

=back 

=head1 AUTHOR

Patrick LeBoutillier, patl@cpan.org

Al Tobey, tobeya@cpan.org

=head1 SEE ALSO

Nagios::Config, Nagios::Config::Object

=cut