This file is indexed.

/usr/share/ltsp/get-ldap-ltsp-config is in debian-edu-config 1.818+deb8u2.

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
#!/bin/sh
# Store as /opt/ltsp/$arch/usr/share/ltsp/get-ldap-ltsp-config
#
# Fetch LTSP client settings from LDAP based on MAC address
#
# Uses ethernet address as stored in the dhcpHost objectclass using
# the dhcpHWAddress attribute or as stored in the ieee802Device
# objectclass with the macAddress attribute.
#
# This module is written to be schema agnostic, and only depend on the
# existence of attribute names.
#
# The LTSP configuration variables are saved directly using a
# ltspConfig attribute.  To set the SERVER variable, set a ltspConfig
# attribute to 'SERVER=value'.
#
# Some LDAP schema should be created with all the relevant
# configuration settings.  Something like this should work:
#
# attributetype ( some-OID NAME 'ltspConfig'
#    DESC 'LTSP config setting'
#    SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
#
# objectclass ( some-OID NAME 'ltspClientConfigAux'
#    DESC 'LTSP client configuration attributes'
#    SUP top
#    AUXILIARY
#    MAY ( ltspConfig ))
#
# objectclass ( some-OID NAME 'ltspClientConfig'
#    DESC 'LTSP client configuration attributes'
#    SUP top
#    STRUCTURAL
#    MUST ( cn )
#    MAY ( ltspConfig ))
#
# Example LDAP object:
#
# dn: cn=ltspConfigDefault,ou=somewhere
# objectclass: device
# objectclass: ltspClientConfigAux
# cn=ltspConfigDefault
# ltspConfig: SERVER=ltspserver.somewhere
# ltspConfig: SOUND=N
#
# dn: cn=hostname,ou=somewhere
# objectclass: ieee802Device
# objectclass: domainRelatedObject
# objectclass: ltspClientConfigAux
# cn=hostname
# macAddress: 00:01:02:03:04:05
# associatedDomain: hostname.somewhere
# ltspConfig: SOUND=N

#
# GOSA also have a LDAP approach for the tftp content (PXE arguments),
# searching for
#
# filter => "(&(macAddress=$mac)(objectClass=gotoTerminal))",
# attrs => [ 'gotoTerminalPath', 'gotoBootKernel',
#            'gotoKernelParameters', 'gotoLdapServer', 'cn' ] );
#
# See the fts-ltsp-ldap package for this.  The gotoTerminal object
# class is auxiliary, allowing it to be combined with other
# objectclasses.

echo "Fetching ltsp config from ldap"

#LDAP_HOST=tjener.intern
#BASE_DN=dc=skole,dc=skolelinux,dc=no
cachefile=/var/cache/ltsp/ltsp_config_edu
envfile=/var/cache/ltsp/ltsp_config_env
PATH=/bin:/usr/bin:/usr/sbin

setup_from_ldap() {
    filter="(&(ltspConfig=*)$1)"
    config="$(ldapsearch -h "$LDAP_HOST" -b "$BASE_DN" -x "$filter" ltspConfig | \
	    awk '/^ltspConfig: [^=]*=[^;]*$/ { print $2 }')"
    if [ "$config" ] ; then
	if eval "$config" ; then
            echo "$config" >> $cachefile
	else
	    logger -t ltsp-ldap "got invalid LTSP config from LDAP: '$config'"
	fi
	foundinldap=true
    fi
}

lookup_mac_addrs() {
    PATH=/sbin:$PATH LANG=C ifconfig 2>/dev/null | grep -i hwaddr | awk '{print $5}' | sort -u
}

# Only check LDAP when the result can be cached
if touch $cachefile && touch $envfile; then
    if [ -z "$LDAP_HOST" ] ; then
	LDAP_HOST=$(debian-edu-ldapserver || :)
    fi
    if [ "$LDAP_HOST" ] && ping -W2 -c2 "$LDAP_HOST" > /dev/null 2>&1 ; then
        if [ -z "$BASE_DN" ] ; then
            BASE_DN=$(debian-edu-ldapserver -s "$LDAP_HOST" -b || :)
        fi

        if [ "$BASE_DN" ] ; then
            # First set default values if found
            setup_from_ldap '(cn=ltspConfigDefault)'

            # Next, look up the host MAC address(es).
            foundinldap=false
            if [ -e /proc/net/dev ] ; then
                for MAC in $(lookup_mac_addrs) ; do
                    filter="(|(dhcpHWAddress=ethernet $MAC)(macAddress=$MAC))"
                    setup_from_ldap "$filter"
                done
            fi
            # If the HW MAC address was not found, look for the host name
            # instead.
            if [ false = "$foundinldap" ] ; then
                fqdn=$(hostname -f)
                # No use checking if it isn't set up yet
                if [ "(none)" != "$fqdn" ] ; then
                    setup_from_ldap "(associatedDomain=$fqdn)"
                fi
            fi
        fi
    fi
fi
echo "Fetching ltsp config from ldap done"