View | Details | Raw Unified | Return to bug 22190 | Differences between
and this patch

Collapse All | Expand All

(-)univention-thin-client-basesystem.info (+4 lines)
 Lines 6-11    Link Here 
6
6
7
Type: file
7
Type: file
8
File: etc/libnss-ldap.conf
8
File: etc/libnss-ldap.conf
9
Variables: ldap/server/addition
10
Variables: ldap/server/name
9
11
10
Type: file
12
Type: file
11
File: etc/nsswitch.conf
13
File: etc/nsswitch.conf
 Lines 24-29    Link Here 
24
26
25
Type: file
27
Type: file
26
File: etc/ldap/ldap.conf
28
File: etc/ldap/ldap.conf
29
Variables: ldap/server/name
30
Variables: ldap/server/addition
27
31
28
Type: file
32
Type: file
29
File: etc/resolv.conf
33
File: etc/resolv.conf
(-)debian/changelog (+34 lines)
 Lines 1-3    Link Here 
1
univention-thin-client-basesystem (9.1.3-1) unstable; urgency=low
2
3
  * merged changed from customer scope Ticket: #2011041210005499
4
5
 -- Felix Botner <botner@univention.de>  Mon, 15 Aug 2011 16:32:20 +0200
6
7
univention-thin-client-basesystem (9.1.2-2) unstable; urgency=low
8
9
  * run univention-find-ldapserver at the end of thin-client-network
10
    Ticket #2011030710000906 
11
12
 -- Felix Botner <botner@univention.de>  Wed, 13 Apr 2011 16:08:00 +0200
13
14
univention-thin-client-basesystem (9.1.2-1) unstable; urgency=low
15
16
  * ignore ldap server policy univentionLDAPServer Ticket #2011030710000906 
17
18
 -- Felix Botner <botner@univention.de>  Mon, 11 Apr 2011 14:51:39 +0200
19
20
univention-thin-client-basesystem (9.1.1-1) unstable; urgency=low
21
22
  * added univention-find-ldapserver into tc' chroot 
23
    Ticket #2011030710000906
24
25
 -- Felix Botner <botner@univention.de>  Mon, 11 Apr 2011 11:25:48 +0200
26
27
univention-thin-client-basesystem (9.1.0-1) unstable; urgency=low
28
29
  * support multiple ldap server in /proc/cmdline
30
  * support ldap/server/addition in thin client config
31
    and init scripts Ticket #2011030710000906
32
33
 -- Felix Botner <botner@univention.de>  Thu, 07 Apr 2011 11:28:38 +0200
34
1
univention-thin-client-basesystem (9.0.19-1) unstable; urgency=low
35
univention-thin-client-basesystem (9.0.19-1) unstable; urgency=low
2
36
3
  * Only run join script in postinst on dc master and dc backup (Bug
37
  * Only run join script in postinst on dc master and dc backup (Bug
(-)conffiles/etc/ldap/ldap.conf (-4 / +10 lines)
 Lines 1-5    Link Here 
1
HOST @%@ldap/server/name@%@
1
# See ldap.conf(5) for details
2
BASE @%@ldap/base@%@
2
# This file should be world readable but not world writable.
3
#SASL_MECH GSSAPI
3
4
#SASL_REALM @%@kerberos/realm@%@
5
TLS_CACERT /etc/univention/ssl/ucsCA/CAcert.pem
4
TLS_CACERT /etc/univention/ssl/ucsCA/CAcert.pem
5
6
@!@
7
print "HOST %s" % baseConfig.get('ldap/server/name', "") + " " + baseConfig.get('ldap/server/addition', "")
8
print "BASE %s" % baseConfig.get('ldap/base', "")
9
print "#SASL_MECH GSSAPI"
10
print "#SASL_REALM @%@kerberos/realm@%@"
11
@!@
(-)conffiles/etc/libnss-ldap.conf (-4 / +6 lines)
 Lines 1-4    Link Here 
1
host @%@ldap/server/name@%@
1
@!@
2
base @%@ldap/base@%@
2
print "host %s" % baseConfig.get('ldap/server/name', "") + " " + baseConfig.get('ldap/server/addition', "")
3
ldap_version 3
3
print "base %s" % baseConfig.get('ldap/base', "")
4
#ssl start_tls
4
print "ldap_version 3"
5
print "#ssl start_tls"
6
@!@
(-)usr/sbin/univention-find-ldapserver (+120 lines)
Line 0    Link Here 
1
#!/usr/bin/python2.4
2
#
3
# Univention Client Basesystem
4
#  helper script finding the ldap server for a thin client
5
#
6
# Copyright 2011 Univention GmbH
7
#
8
# http://www.univention.de/
9
#
10
# All rights reserved.
11
#
12
# The source code of this program is made available
13
# under the terms of the GNU Affero General Public License version 3
14
# (GNU AGPL V3) as published by the Free Software Foundation.
15
#
16
# Binary versions of this program provided by Univention to you as
17
# well as other copyrighted, protected or trademarked materials like
18
# Logos, graphics, fonts, specific documentations and configurations,
19
# cryptographic keys etc. are subject to a license agreement between
20
# you and Univention and not subject to the GNU AGPL V3.
21
#
22
# In the case you use this program under the terms of the GNU AGPL V3,
23
# the program is provided in the hope that it will be useful,
24
# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
# GNU Affero General Public License for more details.
27
#
28
# You should have received a copy of the GNU Affero General Public
29
# License with the Debian GNU/Linux or Univention distribution in file
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
32
33
import ldap
34
import socket
35
import os
36
import re
37
import sys
38
import univention.config_registry
39
40
LDAP_OLD_CMDLINE = re.compile('.*ldapServer=([^ "]+).*')
41
LDAP_NEW_CMDLINE = re.compile('.*ldapServer="([^"]+)".*')
42
LDAP_PORT = re.compile('.*ldapPort=([^ ]+).*')
43
SOURCE = "/proc/cmdline"
44
45
def setTemporaryVarsAndExit (server, port, addition):
46
47
	if server: univention.config_registry.handler_set(['temporary/ldap/server=%s' % server])
48
	if addition: univention.config_registry.handler_set(['temporary/ldap/addition=%s' % " ".join(addition)])
49
	if port: univention.config_registry.handler_set(['temporary/ldap/port=%s' % port])
50
51
	sys.exit(0)
52
53
def ldapAvailable (ip, port):
54
55
	# test ldap port
56
	try:
57
		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
58
		s.settimeout(1)
59
		s.connect((ip, int(port)))
60
	except Exception, e:
61
		return False
62
63
	# try simple bind
64
	try:
65
		lo = ldap.open(ip, port=int(port))
66
		lo.simple_bind_s()
67
	except Exception, e:
68
		return False
69
70
	return True
71
72
server = ""
73
servers = []
74
port = "389"
75
76
fh = open(SOURCE, "r")
77
for line in fh.readlines():
78
79
	line = line.rstrip('\n')
80
81
	# old cmdline style
82
	match = LDAP_OLD_CMDLINE.match(line)
83
	if match:
84
		server = match.group(1)
85
86
	# new style
87
	match = LDAP_NEW_CMDLINE.match(line)
88
	if match:
89
		servers = match.group(1).split(" ")
90
91
	# port
92
	match = LDAP_PORT.match(line)
93
	if match:
94
		port = match.group(1)
95
fh.close()
96
97
if server:
98
	setTemporaryVarsAndExit(server, port, [])
99
100
if servers:
101
	
102
	servers.reverse()
103
	addServer = []
104
105
	# test ldap servers
106
	while servers:
107
		server = servers.pop()
108
		if ldapAvailable(server, port):
109
			untested = servers
110
			untested.reverse()
111
			addServer = untested + addServer
112
			setTemporaryVarsAndExit(server, port, addServer)
113
		else:
114
			addServer.append(server)
115
116
	# multiple servers found but none available,
117
	# use first one
118
	server = addServer[0]
119
	del addServer[0]
120
	setTemporaryVarsAndExit(server, port, addServer)
0
  + *
121
  + *
(-)etc/init.d/thin-client-policies (+5 lines)
 Lines 51-56    Link Here 
51
	var="${line%%=*}"
51
	var="${line%%=*}"
52
	val="${line#*=}"
52
	val="${line#*=}"
53
53
54
	# ignore ldap server policy
55
	if [ "$var" == "univentionLDAPServer" ]; then
56
		continue
57
	fi
58
54
	if [ -n "$var" ] && [ -n "$val" ]; then
59
	if [ -n "$var" ] && [ -n "$val" ]; then
55
		new_value=$(grep "$var=" /etc/univention/templates/mapping/* | head -n 1 | sed -e 's|.*=||;s|"||g')
60
		new_value=$(grep "$var=" /etc/univention/templates/mapping/* | head -n 1 | sed -e 's|.*=||;s|"||g')
56
	fi
61
	fi
(-)etc/init.d/thin-client-network (-21 / +38 lines)
 Lines 86-92    Link Here 
86
		read
86
		read
87
		halt
87
		halt
88
	fi
88
	fi
89
90
else
89
else
91
	# NFS BOOT
90
	# NFS BOOT
92
	echo "(NFS) ... " >>/dev/tty3 2>&1
91
	echo "(NFS) ... " >>/dev/tty3 2>&1
 Lines 105-135    Link Here 
105
	mymac=$(cat /sys/class/net/eth0/address)
104
	mymac=$(cat /sys/class/net/eth0/address)
106
	eval $(univention-config-registry shell thinclient/rollout/domainname \
105
	eval $(univention-config-registry shell thinclient/rollout/domainname \
107
		thinclient/rollout/nameserver thinclient/rollout/ldap/base)
106
		thinclient/rollout/nameserver thinclient/rollout/ldap/base)
108
	ldapServer=$(cat /proc/cmdline | grep ldapServer | sed -e 's|.*ldapServer=||;s| .*||')
109
	if [ -n "$thinclient_rollout_nameserver" ]; then
107
	if [ -n "$thinclient_rollout_nameserver" ]; then
110
		nameserver="$thinclient_rollout_nameserver"
108
		nameserver="$thinclient_rollout_nameserver"
111
	fi
109
	fi
110
112
	# dns-lookup failed
111
	# dns-lookup failed
113
	if [ -z "$fqn" -a -n "$ldapServer" ]; then
112
	if [ -z "$fqn" ]; then
114
		# get ldap basedn (1) from $thinclient_rollout_ldap_base
113
115
		# (2) from ldapsearch namingContexts
114
		# save available ldap server from /proc/cmdline in temporary ucr var for later use
116
		if [ -n "$thinclient_rollout_ldap_base" ]; then
115
		/usr/sbin/univention-find-ldapserver
117
			basedn="$thinclient_rollout_ldap_base"
116
		searchedForLdap="true"
118
		else
117
		
119
			basedn=$(ldapsearch -xLLL -h "$ldapServer" -s base -b '' + | ldapsearch-wrapper | \
118
		eval "$(univention-config-registry shell temporary/ldap/server temporary/ldap/port)"
120
				grep ^namingContexts: | awk -F ": " {'print $2'})
119
120
		if [ -n "$temporary_ldap_server" ]; then
121
			# get ldap basedn (1) from $thinclient_rollout_ldap_base
122
			# (2) from ldapsearch namingContexts
123
			if [ -n "$thinclient_rollout_ldap_base" ]; then
124
				basedn="$thinclient_rollout_ldap_base"
125
			else
126
				basedn=$(ldapsearch -xLLL -h "$temporary_ldap_server" -p $temporary_ldap_port \
127
					-s base -b '' + | ldapsearch-wrapper | \
128
					grep ^namingContexts: | awk -F ": " {'print $2'})
129
			fi
130
			if [ -n "$basedn" ]; then
131
				hostname=$(ldapsearch -xLLL -h "$temporary_ldap_server" -p $temporary_ldap_port \
132
					-b "$basedn" macAddress="$mymac" cn | \
133
					ldapsearch-wrapper | grep ^cn:  | awk -F ": " {'print $2'})
134
				domainname=$(ldapsearch -xLLL -h "$temporary_ldap_server" -p $temporary_ldap_port \
135
					-b "$basedn" aRecord="$nameserver" \
136
					associatedDomain | ldapsearch-wrapper | grep ^associatedDomain: | \
137
					awk -F ": " {'print $2'})
138
			fi
139
			if [ -n "$thinclient_rollout_domainname" ]; then
140
				domainname="$thinclient_rollout_domainname"
141
			fi
142
			fqn="$hostname.$domainname"
121
		fi
143
		fi
122
		if [ -n "$basedn" ]; then
123
			hostname=$(ldapsearch -xLLL -h "$ldapServer" -b "$basedn" macAddress="$mymac" cn | \
124
				ldapsearch-wrapper | grep ^cn:  | awk -F ": " {'print $2'})
125
			domainname=$(ldapsearch -xLLL -h "$ldapServer" -b "$basedn" aRecord="$nameserver" \
126
				associatedDomain | ldapsearch-wrapper | grep ^associatedDomain: | \
127
				awk -F ": " {'print $2'})
128
		fi
129
		if [ -n "$thinclient_rollout_domainname" ]; then
130
			domainname="$thinclient_rollout_domainname"
131
		fi
132
		fqn="$hostname.$domainname"
133
	fi
144
	fi
134
fi
145
fi
135
146
 Lines 163-167    Link Here 
163
# bring up the loopback device
174
# bring up the loopback device
164
ifup lo
175
ifup lo
165
176
177
if [ -z "$searchedForLdap" ]; then
178
	# save available ldap server from /proc/cmdline in temporary ucr var for later use
179
	/usr/sbin/univention-find-ldapserver
180
fi
181
182
166
log_action_end_msg 0
183
log_action_end_msg 0
167
184
(-)etc/init.d/thin-client-ldap (-8 / +18 lines)
 Lines 31-43    Link Here 
31
31
32
log_action_msg "Setting up Thin Client LDAP configuration"
32
log_action_msg "Setting up Thin Client LDAP configuration"
33
33
34
eval $(univention-baseconfig shell hostname domainname nameserver1 interfaces/eth0/address interfaces/eth0/netmask interfaces/eth0/network)
34
35
ldapServer=$(cat /proc/cmdline | grep ldapServer | sed -e 's|.*ldapServer=||;s| .*||')
35
eval $(univention-baseconfig shell hostname domainname nameserver1 interfaces/eth0/address interfaces/eth0/netmask interfaces/eth0/network temporary/ldap/server temporary/ldap/port temporary/ldap/addition)
36
if [ -n "$ldapServer" ]; then
36
37
	ldapPort=$(cat /proc/cmdline | grep ldapPort | sed -e 's|.*ldapPort=||;s| .*||')
37
# available ldap server in /proc/cmdline was already searched in thin-client-network
38
	if [ -z "$ldapPort" ]; then
38
# and saved in temporary ucr var temporary/ldap/server and temporary/ldap/port
39
		ldapPort=389
39
if [ -n "$temporary_ldap_server" ]; then
40
	fi
40
	ldapServer="$temporary_ldap_server"
41
	ldapPort="$temporary_ldap_port"
42
	ldapServerAddition="$temporary_ldap_addition"
41
else
43
else
42
	# searching ldap server for this subnet
44
	# searching ldap server for this subnet
43
	res=$(/usr/bin/dns-lookup _ldap._tcp.$domainname srv | \
45
	res=$(/usr/bin/dns-lookup _ldap._tcp.$domainname srv | \
 Lines 114-119    Link Here 
114
mac_address=$(ip link show eth0 | grep link/ether | sed 's/.*link\/ether \([0-9a-f:]*\) .*/\1/')
116
mac_address=$(ip link show eth0 | grep link/ether | sed 's/.*link\/ether \([0-9a-f:]*\) .*/\1/')
115
hostdn=$(ldapsearch -x -h $ldapServer -p $ldapPort -b $ldapBase "(&(macAddress=${mac_address})(objectClass=univentionThinClient))" -LLL dn | ldapsearch-wrapper | sed -ne 's/dn: //p')
117
hostdn=$(ldapsearch -x -h $ldapServer -p $ldapPort -b $ldapBase "(&(macAddress=${mac_address})(objectClass=univentionThinClient))" -LLL dn | ldapsearch-wrapper | sed -ne 's/dn: //p')
116
118
117
univention-config-registry set ldap/server/name=$ldapServer ldap/port=$ldapPort ldap/base=$ldapBase ldap/hostdn="$hostdn" ldap/mydn="$hostdn" nsswitch/ldap=yes >>/dev/tty3 2>&1
119
univention-config-registry set \
120
	ldap/server/name=$ldapServer \
121
	ldap/port=$ldapPort \
122
	ldap/base=$ldapBase \
123
	ldap/hostdn="$hostdn" \
124
	ldap/mydn="$hostdn" \
125
	ldap/server/addition="$ldapServerAddition" \
126
	nsswitch/ldap=yes \
127
	>>/dev/tty3 2>&1
118
128
119
log_action_end_msg 0
129
log_action_end_msg 0

Return to bug 22190