This file is indexed.

/usr/bin/debian-edu-ldapserver is in debian-edu-config 1.702.

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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/perl

use strict;
use warnings;

use Getopt::Std;
use Debian::Edu;

sub usage {
    my $retval = shift;
    print <<EOF;
debian-edu-ldapserver [-dfrk] [-b [-s <servername>]]

Find LDAP server and base.  By default the LDAP server is located
using SRV records, and if -b is used, the LDAP base is printed.  If -b
is not used, the LDAP server is used instead.

 -b             Print LDAP base.
 -d             Enable debug output.
 -f             Provide fallback values if dynamic detection fail.
 -k             Print Kerberos server name.
 -r             Print Kerberos realm name.
 -s <server>    Use this server when finding LDAP base.

EOF
    exit $retval;
}

my %opts;
getopts("bdfkrs:", \%opts) || usage(1);

usage(1) if ($opts{s} && !$opts{b});

my $defaultdnsdomain = 'intern';
my $defaultldapserver = 'ldap.intern';
my $defaultldapbase = 'dc=skole,dc=skolelinux,dc=no';
my $defaultkrbserver = 'kerberos.intern';
my $defaultkrbrealm = 'INTERN';

my $dnsdomain;
my $ldapserver;
my $ldapbase;
my $krbserver;
my $krbrealm;

# During installation on the Main Server, dynamic lookup is not
# possible because DNS and LDAP is not yet operational.
if (on_main_server() && during_installation()) {
    my $dnsdomain = $defaultdnsdomain;
    $ldapserver = $defaultldapserver;
    $ldapbase = $defaultldapbase;
    $krbserver = $defaultkrbserver;
    $krbrealm = $defaultkrbrealm;
} else {
    my $hostname = `hostname`;
    chomp $hostname;
    if ("localhost" ne $hostname) {
        $dnsdomain = `dnsdomainname`;
        chomp $dnsdomain;
        $ldapserver = $opts{s} || find_ldap_server($dnsdomain);
        $krbserver = find_kerberos_server($dnsdomain);
    }
}

if ($opts{k}) {
    if ($krbserver) {
        print "$krbserver\n";
    } elsif ($opts{f}) {
        print "$defaultkrbserver\n";
    } else {
        exit 1;
    }
} elsif ($opts{r}) {
    $krbrealm = find_kerberos_realm($dnsdomain);
    if ($krbrealm) {
        print "$krbrealm\n";
    } elsif ($opts{f}) {
        print "$defaultkrbrealm\n"
    } else {
        exit 1;
    }
} else {
    if (!$ldapserver) {
        if (0 == system("ping -c2 ldap > /dev/null 2>&1") && !$?) {
            system('logger -t debian-edu-ldapserver "The function \'find_ldap_server\' did not provide a ldap host: Use fallback \'ldap\'."');
            $ldapserver = "ldap";
        } elsif (! $opts{f}) {
            system('logger -t debian-edu-ldapserver "The function \'find_ldap_server\' did not provide a ldap host and fallback \'ldap\' does not work."');
            exit 0;
        }
    }
    if ($opts{b}) {
        $ldapbase = find_ldap_base($ldapserver) if $ldapserver && !$ldapbase;
        if ($ldapbase) {
            print "$ldapbase\n";
        } elsif ($opts{f}) {
            print "$defaultldapbase\n";
        } else {
            exit 1;
        }
    } else {
        if ($ldapserver) {
            print "$ldapserver\n";
        } elsif ($opts{f}) {
            print "$defaultldapserver\n";
        } else {
            exit 1;
        }
    }
}

exit 0;

sub on_main_server {
    my $retval = 0;
    if (open(my $fh, "<", "/etc/debian-edu/config")) {
        while (<$fh>) {
            $retval = 1 if (m/^PROFILE="Main-Server\W/);
        }
        close $fh;
    }
    return $retval;
}

sub during_installation {
    return 1 if ( -e "/sbin/start-stop-daemon.REAL" );
    return 0;
}