This file is indexed.

/usr/lib/x86_64-linux-gnu/dirsrv/perl/Resource.pm is in 389-ds-base 1.3.7.10-1ubuntu1.

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
# BEGIN COPYRIGHT BLOCK
# Copyright (C) 2007 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
# See LICENSE for details. 
# END COPYRIGHT BLOCK
#

# manages resource bundle files - gets values
# given keys

package Resource;

use strict;

#require    Exporter;
#@ISA       = qw(Exporter);
#@EXPORT    = qw();

sub new {
    my $type = shift;
    my $self = {};

    while (@_) {
        push @{$self->{filenames}}, shift;
    }

    $self = bless $self, $type;

    if (@{$self->{filenames}}) {
        $self->read();
    }

    return $self;
}

# the resource files are read in order given.  Definitions from
# later files override the same definitions in earlier files.
sub read {
    my $self = shift;

    while (@_) {
        push @{$self->{filenames}}, shift;
    }

    for my $filename (@{$self->{filenames}}) {
        my $incontinuation = 0;
        my $curkey;
        open RES, $filename or die "Error: could not open resource file $filename: $!";
        my $line;
        while ($line = <RES>) {
            my $iscontinuation;
            chop $line; # trim trailing newline
            if ($line =~ /^\s*$/) { # skip blank/empty lines
                $incontinuation = 0;
                next;
            }
            if ($line =~ /^\s*\#/) { # skip comment lines
                $incontinuation = 0;
                next;
            }
            # read name = value pairs like this
            # bol whitespace* name whitespace* '=' whitespace* value eol
            # the value will include any trailing whitespace
            if ($line =~ /\\$/) {
                chop $line;
                $iscontinuation = 1;
            }
            if ($incontinuation) {
                $self->{res}->{$curkey} .= "\n" . $line;
            } elsif ($line =~ /^\s*(.*?)\s*=\s*(.*?)$/) {
                # replace \n with real newline
                if ($curkey) {
                    $self->{res}->{$curkey} =~ s/\\n/\n/g;
                }
                $curkey = $1;
                $self->{res}->{$curkey} = $2;
            }
            if ($iscontinuation) { # if line ends with a backslash, continue the data on the next line
                $incontinuation = 1;
            } else {
                $incontinuation = 0;
            }
        }
        # replace \n with real newline
        if (defined($curkey)) {
            $self->{res}->{$curkey} =~ s/\\n/\n/g;
        }
        close RES;
    }
}

# given a resource key and optional args, return the value
# $text = $res->getText('key');
# or
# $text = $res->getText('key', @args);
# or
# $text = $res->getText($arrayref)
# where $arrayref is ['key', @args]
sub getText {
    my $self = shift;
    my $key = shift;
    my @args = @_;

    if (ref($key) eq 'ARRAY') {
        my $tmpkey = shift @{$key};
        @args = @{$key};
        $key = $tmpkey;
    }

    if (!exists($self->{res}->{$key})) {
        print "Error: unknown resource key $key\n";
        return undef;
    }

    if (!defined($self->{res}->{$key})) {
        print "Error: resource key $key has no value\n";
        return undef;
    }

    # see if the args themselves are resource keys
    for (my $ii = 0; $ii < @args; ++$ii) {
        if (exists($self->{res}->{$args[$ii]})) {
            $args[$ii] = $self->{res}->{$args[$ii]};
        }
    }

    my $text = sprintf $self->{res}->{$key}, @args;

    return $text;
}

#############################################################################
# Mandatory TRUE return value.
#
1;