Re: Idea for storing LTSP configuration in LDAP
Petter Reinholdtsen <[email protected]> Sat, 17 Jul 2010 13:18:24 +0200
| Newsgroups | gmane.linux.terminal-server.devel |
|---|---|
| Organization | University of Oslo, Norway |
| Message-ID | <[email protected]> |
[Vagrant Cascadian]
> though i mentioned in our earlier chat, the LDAP schema needs to
> account for arbitrary lts.conf variables, since we're always adding
> new ones, and people should be able to easily use custom variables
> with custom hooks.
This is a good point. One way to do this is to not use specific LDAP
attributes for each variable, but instead one generic multi-value
variable and store all settings there. Something like this would then
be stored in LDAP:
dn: cn=ltspConfigDefault,ou=somewhere
objectclass: device
objectclass: ltspClientAux
cn=ltspConfigDefault
ltspConfig: SERVER=ltspserver.somewhere
ltspConfig: SOUND=N
dn: cn=hostname,ou=somewhere
objectclass: ieee802Device
objectclass: domainRelatedObject
objectclass: ltspClientAux
cn=hostname
macAddress: 00:01:02:03:04:05
associatedDomain: hostname.somewhere
ltspConfig: SOUND=N
This way, any setting can be stored in LDAP without extending the
schema. The LDAP schema would be a lot simpler too:
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 'ltspClientAux'
DESC 'LTSP client configuration attributes'
SUP top
AUXILIARY
MAY ( ltspConfig ))
> also, because we're dealing with shell variables, making sure that
> things are properly quoted and/or escaped needs to be considered
> (wheee).
I am sure this detail can be fixed. There might also be a problem to
locate the LDAP server before resolv.conf is set up, but it would be
solvable using IP addresses instead, or making sure resolv.conf is set
up before the ltsp_config.d fragments is executed.
I rewrote my draft implementation for a ltsp_config.d script, and now
it look like this:
# Store in /opt/ltsp/$arch/usr/share/ltsp/ltsp_config.d/ldap-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 prefix and uppercasing the rest of the attribute name.
# To set the SERVER variable, set the ltspConfigServer attribute.
#
# Some LDAP schema should be created with all the relevant
# configuration settings. Something like this should work:
#
# attributetype ( 1.1.1.1 NAME 'ltspConfig'
# DESC 'LTSP config setting'
# SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
#
# objectclass ( 1.1.2.1 NAME 'ltspClientAux'
# DESC 'LTSP client configuration attributes'
# SUP top
# AUXILIARY
# MAY ( ltspConfig ))
#
# Example LDAP object:
#
# dn: cn=ltspConfigDefault,ou=somewhere
# objectclass: device
# objectclass: ltspClientAux
# cn=ltspConfigDefault
# ltspConfig: SERVER=ltspserver.somewhere
# ltspConfig: SOUND=N
#
# dn: cn=hostname,ou=somewhere
# objectclass: ieee802Device
# objectclass: domainRelatedObject
# objectclass: ltspClientAux
# 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.
setup_from_ldap() {
filter="(&(ltspConfig=*)$1)"
# Use temporary file to ensure the while loop is running in this
# process, and not a subprocess.
tempfile=$(tempfile)
ldapsearch -h "$LDAP_HOST" -b "$BASE_DN" -v -x "$filter" ltspConfig | \
awk '/^ltspConfig: [^=]*=[^;]*$/ { print $2}' > $tempfile
if [ -s "$tempfile" ] ; then
. $tempfile
foundinldap=true
fi
rm $tempfile
}
lookup_mac_addrs() {
PATH=/sbin:$PATH LANG=C ifconfig | grep -i hwaddr | awk '{print $5}' | sort -u
}
if [ -z "$LDAP_HOST" ] ; then
LDAP_HOST=$(debian-edu-ldapserver)
fi
if [ "$LDAP_HOST" ] ; then
if [ -z "$BASE_DN" ] ; then
BASE_DN=$(debian-edu-ldapserver -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
for MAC in $(lookup_mac_addrs) ; do
filter="(|(dhcpHWAddress=ethernet $MAC)(macAddress=$MAC))"
setup_from_ldap "$filter"
done
# If the HW MAC address was not found, look for the host name
# instead.
if [ false = "$foundinldap" ] ; then
hostname=$(uname -n)
setup_from_ldap "(associatedDomain=$hostname)"
fi
fi
fi
Happy hacking,
--
Petter Reinholdtsen
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_____________________________________________________________________
Ltsp-developer mailing list. To un-subscribe, or change prefs, goto:
https://lists.sourceforge.net/lists/listinfo/ltsp-developer
For additional LTSP help, try #ltsp channel on irc.freenode.net