This file is indexed.

/usr/share/doc/liblemonldap-ng-portal-perl/examples/PortalStatus.pl is in liblemonldap-ng-portal-perl 1.9.16-2.

This file is owned by root:root, with mode 0o755.

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
#!/usr/bin/perl

use CGI;
use strict;

# Status page for Lemonldap::NG::Portal
#
# This CGI displays some information about Lemonldap::NG sessions
#

BEGIN {

    sub Apache::Session::get_sessions_count {
        return 0;
    }

    sub Apache::Session::MySQL::get_sessions_count {
        my $class = shift;
        my $args  = shift;
        my $dbh =
          DBI->connect( $args->{DataSource}, $args->{UserName},
            $args->{Password} )
          or die("$!$@");
        my $table = $args->{TableName} || 'sessions';
        my $sth = $dbh->prepare("SELECT count(*) from $table");
        $sth->execute;
        return ( $sth->fetchrow_array )[0];
    }

    *Apache::Session::Postgres::get_sessions_count =
      \&Apache::Session::MySQL::get_sessions_count;
    *Apache::Session::Oracle::get_sessions_count =
      \&Apache::Session::MySQL::get_sessions_count;
    *Apache::Session::Sybase::get_sessions_count =
      \&Apache::Session::MySQL::get_sessions_count;
    *Apache::Session::Informix::get_sessions_count =
      \&Apache::Session::MySQL::get_sessions_count;

    sub Apache::Session::File::get_sessions_count {
        my $class = shift;
        my $args  = shift;
        $args->{Directory} ||= '/var/lib/lemonldap-ng/sessions/';
        unless ( opendir DIR, $args->{Directory} ) {
            die "Cannot open directory $args->{Directory}\n";
        }
        my @t =
          grep { -f "$args->{Directory}/$_" and /^[A-Za-z0-9@\-]+$/ }
          readdir(DIR);
        closedir DIR;
        return $#t + 1;
    }

    sub Apache::Session::DB_File::get_sessions_count {
        my $class = shift;
        my $args  = shift;

        if ( !tied %{ $class->{dbm} } ) {
            my $rv = tie %{ $class->{dbm} }, 'DB_File', $args->{FileName};

            if ( !$rv ) {
                die "Could not open dbm file $args->{FileName}: $!";
            }
        }
        my @t = keys( %{ $class->{dbm} } );
        return $#t + 1;
    }
}

use Lemonldap::NG::Common::Conf;
use Lemonldap::NG::Common::Conf::Constants;
use strict;
use DBI;

my $cgi = CGI->new();

print $cgi->header(
    -charset => 'ascii',
    -type    => 'text/plain',
);

print "LEMONLDAP::NG::PORTAL STATUS\n\nConfiguration          : ";

my $lmconf = Lemonldap::NG::Common::Conf->new();

unless ($lmconf) {
    print "unable to create conf object\n";
}
else {
    my $conf = $lmconf->getConf;
    unless ($conf) {
        write "unable to get configuration ($!)\n";
    }
    else {
        print "OK\nApache::Session module : ";
        my $tmp = $conf->{globalStorage};
        eval "use $tmp";
        if ($@) {
            print "unable to load $tmp ($@)\n";
        }
        else {
            my $t = $tmp->get_sessions_count( $conf->{globalStorageOptions} );
            print "OK\nActive sessions        : $t\n";
        }
    }
}

1;