Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 160979 | Differences between
and this patch

Collapse All | Expand All

(-)dhcp-3.0.5/Changelog-LDAP (+251 lines)
Line 0 Link Here
1
2007-2-23 Brian Masney <masneyb@ntelos.net>
2
	* contrib/dhcpd-conf-to-ldap.pl - fixed a parsing bug in which
3
	didn't handle correctly quoted string containing spaces.
4
	(Rapha?l Luta <raphael.luta@aptiwan.com>)
5
6
	* dst/Makefile.dist server/Makefile.dist site.conf - updated build
7
	method when using -lssl.
8
	(from Marius Tomaschewski <mt@suse.de>)
9
10
	* server/ldap.c - fix for ldap_read_function to avoid returning
11
	empty strings (skipped host declaration from ldap) that are causing
12
	parsing errors in ldap-dynamic mode.
13
	(from Marius Tomaschewski <mt@suse.de>)
14
15
	* includes/dhcpd.h README.ldap server/dhcpd.c server/ldap.c
16
	server/stables.c - added ldap-ssl <off|start_tls|ldaps|on> option and
17
        several ldap-tls* options, that are described in the "man ldap.conf".
18
	(from Marius Tomaschewski <mt@suse.de>)
19
20
	* includes/dhcpd.h server/ldap.c server/stables.c - added ldap-referrals
21
	<on|off> option. Also implemented a LDAP rebuind function
22
	(from Kalyan <skalyanasundaram@novell.com>)
23
24
	* includes/dhcpd.h server/ldap.c server/stables.c - renamed dhcpd.conf
25
	option ldap-server-cn to ldap-dhcp-server-cn
26
	(from Marius Tomaschewski <mt@suse.de>)
27
28
	* contrib/dhcp.schema - schema updates 
29
	(from Kalyan <skalyanasundaram@novell.com>)
30
31
	* server/ldap.c server/ldap_casa.c - CASA support fixes
32
	(from Marius Tomaschewski <mt@suse.de>)
33
34
	* server/ldap.c - added strncat() fix
35
	(from Marius Tomaschewski <mt@suse.de>)
36
37
2006-12-15 Brian Masney <masneyb@ntelos.net>
38
	* server/ldap.c (ldap_read_config) - unbind from the LDAP server after
39
	the config file has been ran if the server is being ran in static mode
40
	(from Tomas Hoger <thoger@pobox.sk>)
41
42
	* server/ldap.c (ldap_read_function) - fixed bug where the entire
43
	configuration was not being processed in the LDAP directory.
44
45
	* server/ldap.c - added the following functions for reading values
46
	from the config file: _do_lookup_dhcp_string_option(),
47
	_do_lookup_dhcp_int_option() and _do_lookup_dhcp_enum_option(). This
48
	helped to clean up ldap_start() start a bit. Also, various small
49
	formatting changes to the code.
50
51
2006-12-15 Marius Tomaschewski <mt@suse.de>
52
	* Changelog-LDAP - Added / changed some of entries in
53
	Changelog-LDAP, e.g.  changes to the dhcpServer and
54
	dhcpService objectclasses in schema file was not mentioned.
55
56
        * server/ldap.c Some a little bit paranoid checks to strchr results
57
	in the group patch, avoided allocation of groupname using snprintf
58
	with a "%.*s" format.
59
60
        * server/ldap.c - Readded FIXME comment about one space in
61
	dhcpHWAddress.
62
63
        * server/ldap.c Changed "dhcpdnsZone" and "dhcpdnszoneServer" into
64
	"dhcpDnsZone" and "dhcpDnsZoneServer".
65
66
        * Fixed memory leak in ldap_parse_zone (dfree of keyCn), added checks
67
	for dmalloc and strchr results.
68
69
	* ldap_casa.c, ldap_casa.h - surrounded content of ldap_casa.h and
70
	ldap_casa.c with if defined(LDAP_CASA_AUTH).
71
72
	* contrib/dhcp.schema  - Reverted the equality change for dhcpOption.
73
	The dhcp options are case-insensitive in dhcpd.conf.
74
75
	* Changed "dhcpdnsZone" and "dhcpdnszoneServer" into "dhcpDnsZone"
76
	and "dhcpDnsZoneServer".
77
78
	* Changed "FQDNs" into "DNs" in dhcpLocatorDN description (DN is already
79
	absolute, RDN is relative DN, FQDN means a full qualified domain name).
80
81
2006-12-15 Kalyan <skalyanasundaram@novell.com>
82
	* includes/ldap_casa.h server/ldap_casa.c - updated to support CASA
83
	1.7
84
85
2006-8-15 Kalyan <skalyanasundaram@novell.com>
86
	* server/ldap.c (ldap_parse_options) - fetch option from the group
87
	if the host belongs to that group in the dynamic method.
88
89
	* contrib/dhcp.schema - modified dhcpServiceDN attribute in dhcpServer
90
	objectclasses to be optional instead of mandatory
91
92
	* contrib/dhcp.schema - modified dhcpPrimaryDN attribute in dhcpService
93
	objectclasses to be optional instead of mandatory
94
95
	* contrib/dhcp.schema - schema has been updated with
96
	new objectclasses dhcpLocator,dhcpTsigKey,dhcpdnsZone,dhcpFailOver and
97
	many attributes.
98
99
	* contrib/dhcp.schema - dhcpHWAddress's equality has been modified to
100
	caseIgnoreIA5Match.
101
102
	* server/ldap.c - added support for reading the dhcpTsigKey and
103
	dhcpdnsZone objects. 
104
105
	* server/ldap.c (ldap_parse_options) Fetch option from the group if
106
	the host belongs to that group in the dynamic method.
107
108
	* server/ldap.c - CASA authentication is enabled.
109
110
	* server/ldap.c - introduced new attribute ldap-server-cn to mention
111
	the dhcpServer object name in configuration.
112
113
2006-7-17 Brian Masney <masneyb@ntelos.net>
114
	* server/ldap.c (ldap_read_function) - fixes for reading the data
115
	from the LDAP tree in some cases (patch from
116
	Darrin Smith <beldin@beldin.org>)
117
118
2006-3-17 Brian Masney <masneyb@ntelos.net>
119
	* server/ldap.c (ldap_read_function) - added patch from 
120
	Dmitriy Bogun <kabanyura@gmail.com>. This patch fixes a bug when
121
	EOF wasn't returned in some cases.
122
123
2005-9-26 Brian Masney <masneyb@ntelos.net>
124
	* server/ldap.c (ldap_start) - added support for reading the
125
	ldap-port option. This option was not being used.
126
127
2005-5-24 Brian Masney <masneyb@ntelos.net>
128
	* server/ldap.c (ldap_parse_host) - allow dhcpHost entries that do
129
	not have a hardware address associated with them
130
131
2005-4-11 Brian Masney <masneyb@ntelos.net>
132
	* README.ldap - updated directions on how to use LDAP over SSL on
133
	non-Linux machines
134
135
2005-2-23 Brian Masney <masneyb@ntelos.net>
136
	* server/ldap.c (ldap_generate_config_string) - do a case insensitive
137
	string comparsion when comparing the object classes
138
139
2004-11-8 Brian Masney <masneyb@ntelos.net>
140
	* debian/control - updated the depends and build-depends line
141
	(from Andrew Pollock <me@andrew.net.au>)
142
143
2004-10-13 Brian Masney <masneyb@ntelos.net>
144
	* server/ldap.c (ldap_start) - allow doing an anonymous bind to the
145
	LDAP server
146
147
2004-9-27 Brian Masney <masneyb@ntelos.net>
148
	* contrib/dhcpd-conf-to-ldap.pl - make sure the DHCP hardware address
149
	is always lowercased
150
151
2004-7-30 Brian Masney <masneyb@ntelos.net>
152
	* server/ldap.c - added more debbuging statements. Fixed possible crash
153
	that could occur whenever more than 1 external DN is added to an LDAP
154
	entry. Fixed possible infinite loop when reading the external DNs.
155
	(from Sebastian Hetze <s.hetze@linux-ag.de>)
156
157
2004-7-1 Brian Masney <masneyb@ntelos.net>
158
	* README.ldap - updated build instructions paragraph
159
	(from Mason Schmitt <sysadmin@sunwave.net>)
160
161
2004-6-29 Brian Masney <masneyb@ntelos.net>
162
	* debian/control - set the minimum required version of the DHCP server
163
	to be 3.0.1rc9
164
165
	* configure - fix for sed when configure was run from an older shell
166
167
2004-6-22 Brian Masney <masneyb@ntelos.net>
168
	* Updated patch to use ISC DHCP 3.0.1rc14
169
170
2004-5-24 Brian Masney <masneyb@ntelos.net>
171
	* server/ldap.c - don't append a ; to the end of a dhcpStatement if it
172
	ends in }
173
174
	* server/ldap.c contrib/dhcpd-conf-to-ldap.pl - support having multiple
175
	dhcpRange statements (from Marco D'Ettorre <marco.dettorre@sys-net.it>)
176
177
2004-5-5 Brian Masney <masneyb@ntelos.net>
178
	* server/ldap.c - added more debugging statements when
179
	it is compiled in to help troubleshoot parsing errors. Don't free
180
	a LDAP connection prematurely when there is a reference to another
181
	LDAP tree. If the config entry ends in }, make sure a ; gets tacked
182
	on
183
184
	* debian/* - Updated version number. Renamed package from
185
	dhcp3-ldap-ntelos to dhcp3-server-ldap.
186
187
	* server/ldap.c - enclose the shared-network name in quotes so
188
	that there can be shared network statements in LDAP that have spaces
189
	in them
190
191
	* configure - after the work directory is setup, add -lldap -llber
192
	to the server Makefile
193
194
Wed Apr 21 15:09:08 CEST 2004 - mt@suse.de
195
	* contrib/dhcpd-conf-to-ldap.pl:
196
	  - added "--conf=file" option usable instead of stdin
197
	  - added "--ldif=file" option usable instead of stdout
198
	  - added "--second=host|dn" option usefull for failover
199
	  - added "--use=feature" option to enable extended features;
200
	    currently used to enable failover (default is disabled).
201
	  - extended remaining_line() to support block statements
202
	  - fixed / improved failover support, added notes about
203
204
	* server/ldap.c:
205
	  - moved code checking statement ends to check_statement_end()
206
	  - moved parsing of entry options/statements to
207
	    ldap_parse_entry_options()
208
	  - moved code closing debug fd into ldap_close_debug_fd()
209
	  - moved code writing to debug fd into ldap_write_debug()
210
	  - added support for full hostname in dhcpServer search filter
211
	  - added support for multiple dhcpService entries in dhcpServer object
212
	  - added parsing of options and statements for dhcpServer object
213
	  - added verify if dhcpService contains server dn as primary or
214
	    secondary
215
	  - changed to search for dhcpHost,dhcpSubClass bellow of all
216
	    dhcpService trees instead of base-dn (avoids finding of hosts in
217
	    foreign configs)
218
	  - fixes to free all dn's fetched by ldap_get_dn (e.g. debug output)
219
	  - fixes to free ldap results, mainly in cases where no LDAP_SUCCESS
220
	    returned or other error conditions happened
221
	  - fixed/improved some log messages
222
223
2004-3-30 Brian Masney <masneyb@ntelos.net>
224
	* contrib/dhcpd-conf-to-ldap.pl - added option to control the
225
	DHCP Config DN. Wrap the DHCP Statements in { }
226
	This patch was contributed by Marius Tomaschewski <mt@suse.de>
227
228
	* server/ldap.c - changed ldap_username and ldap_password to
229
	be optional (anonymous bind is used then). Added {} block support
230
	to dhcpStatements. (no ";" at end if statement ends with a "}").
231
	Fixed writing to ldap-debug-file. Changed find_haddr_in_ldap() to
232
	use dhcpHost objectClass in its filter
233
	This patch was contributed by Marius Tomaschewski <mt@suse.de>
234
235
2004-3-23 Brian Masney <masneyb@ntelos.net>
236
	* contrib/dhcpd-conf-to-ldap.pl - added options for server, basedn
237
	options and usage message (Net::Domain instead of SYS::Hostname).
238
	Added handling of zone, authoritative and failover (config and
239
	pool-refs) statements. Added numbering of groups and pools per
240
	subnet. This patch was contributed by Marius Tomaschewski <mt@suse.de>
241
242
2004-2-26 Brian Masney <masneyb@ntelos.net>
243
	* fixed an instance where the LDAP server would restart, but the DHCP
244
	server would not reconnect
245
246
2004-2-18 Brian Masney <masneyb@ntelos.net>
247
	* allow multiple dhcp*DN entries in the LDAP entry.
248
249
2003-9-11 Brian Masney <masneyb@ntelos.net>
250
	* updated patch to work with 3.0.1rc12
251
(-)dhcp-3.0.5/README.ldap (+190 lines)
Line 0 Link Here
1
LDAP Support in DHCP
2
Brian Masney <masneyb@ntelos.net>
3
Last updated 3/23/2003
4
5
This document describes setting up the DHCP server to read it's configuration 
6
from LDAP. This work is based on the IETF document 
7
draft-ietf-dhc-ldap-schema-01.txt included in the doc directory. For the latest
8
version of this document, please see http://home.ntelos.net/~masneyb.
9
10
First question on most people's mind is "Why do I want to store my 
11
configuration in LDAP?" If you run a small DHCP server, and the configuration
12
on it rarely changes, then you won't need to store your configuration in LDAP.
13
But, if you have several DHCP servers, and you want an easy way to manage your 
14
configuration, this can be a solution. 
15
16
The first step will be to setup your LDAP server. I am using OpenLDAP from
17
www.openldap.org. Building and installing OpenLDAP is beyond the scope of this 
18
document. There is plenty of documentation out there about this. Once you have 
19
OpenLDAP installed, you will have to edit your slapd.conf file. I added the 
20
following 2 lines to my configuration file:
21
22
include         /etc/ldap/schema/dhcp.schema
23
index           dhcpHWAddress 	eq
24
index           dhcpClassData	eq
25
26
The first line tells it to include the dhcp schema file. You will find this 
27
file under the contrib directory in this distribution. You will need to copy 
28
this file to where your other schema files are (maybe
29
/usr/local/openldap/etc/openldap/schema/). The second line sets up
30
an index for the dhcpHWAddress parameter. The third parameter is for reading 
31
subclasses from LDAP every time a DHCP request comes in. Make sure you run the 
32
slapindex command and restart slapd to have these changes to into effect.
33
34
Now that you have LDAP setup, you should be able to use gq (http://biot.com/gq/)
35
to verify that the dhcp schema file is loaded into LDAP. Pull up gq, and click
36
on the Schema tab. Go under objectClasses, and you should see at least the 
37
following object classes listed: dhcpClass, dhcpGroup, dhcpHost, dhcpOptions, 
38
dhcpPool, dhcpServer, dhcpService, dhcpSharedNetwork, dhcpSubClass, and 
39
dhcpSubnet. If you do not see these, you need to check over your LDAP 
40
configuration before you go any further.
41
42
You should now be ready to build DHCP. If you would like to enable LDAP over
43
SSL, you will need to perform the following steps:
44
45
  * Edit the includes/site.h file and uncomment the USE_SSL line
46
    or specify "-DUSE_SSL" via CFLAGS.
47
  * Edit the dst/Makefile.dist file and remove md5_dgst.c and md5_dgst.o
48
    from the SRC= and OBJ= lines (around line 24)
49
  * Now run configure in the base source directory. If you chose to enable
50
    LDAP over SSL, you must append -lcrypto -lssl to the LIBS= line in the file
51
    work.os/server/Makefile (replace os with your operating system, linux-2.2 on
52
    my machine).  You should now be able to type make to build your DHCP server.
53
54
If you choose to not enable LDAP over SSL, then you only need to run configure
55
and make in the toplevel source directory.
56
57
Once you have DHCP installed, you will need to setup your initial plaintext 
58
config file. In my /etc/dhcpd.conf file, I have:
59
60
ldap-server "localhost";
61
ldap-port 389;
62
ldap-username "cn=DHCP User, dc=ntelos, dc=net";
63
ldap-password "blah";
64
ldap-base-dn "dc=ntelos, dc=net";
65
ldap-method dynamic;
66
ldap-debug-file "/var/log/dhcp-ldap-startup.log";
67
68
If SSL has been enabled at compile time using the USE_SSL flag, the dhcp
69
server trys to use TLS if possible, but continues without TLS if not.
70
71
You can modify this behaviour using following option in /etc/dhcpd.conf:
72
73
ldap-ssl <off | ldaps | start_tls | on>
74
   off:       disables TLS/LDAPS.
75
   ldaps:     enables LDAPS -- don't forget to set ldap-port to 636.
76
   start_tls: enables TLS using START_TLS command
77
   on:        enables LDAPS if ldap-port is set to 636 or TLS in 
78
              other cases.
79
80
See also "man 5 ldap.conf" for description the following TLS related 
81
options:
82
   ldap-tls-reqcert, ldap-tls-ca-file, ldap-tls-ca-dir, ldap-tls-cert
83
   ldap-tls-key, ldap-tls-crlcheck, ldap-tls-ciphers, ldap-tls-randfile
84
85
All of these parameters should be self explanatory except for the ldap-method.
86
You can set this to static or dynamic. If you set it to static, the 
87
configuration is read once on startup, and LDAP isn't used anymore. But, if you
88
set this to dynamic, the configuration is read once on startup, and the 
89
hosts that are stored in LDAP are looked up every time a DHCP request comes in.
90
91
When the optional statement ldap-debug-file is specified, on startup the DHCP
92
server will write out the configuration that it generated from LDAP. If you are
93
getting errors about your LDAP configuration, this is a good place to start
94
looking.
95
96
The next step is to set up your LDAP tree. Here is an example config that will
97
give a 10.100.0.x address to machines that have a host entry in LDAP. 
98
Otherwise, it will give a 10.200.0.x address to them. (NOTE: replace 
99
dc=ntelos, dc=net with your base dn). If you would like to convert your 
100
existing dhcpd.conf file to LDIF format, there is a script 
101
contrib/dhcpd-conf-to-ldap.pl that will convert it for you. Type
102
dhcpd-conf-to-ldap.pl --help to see the usage information for this script.
103
104
# You must specify the server's host name in LDAP that you are going to run
105
# DHCP on and point it to which config tree you want to use. Whenever DHCP 
106
# first starts up, it will do a search for this entry to find out which 
107
# config to use
108
dn: cn=brian.ntelos.net, dc=ntelos, dc=net
109
objectClass: top
110
objectClass: dhcpServer
111
cn: brian.ntelos.net
112
dhcpServiceDN: cn=DHCP Service Config, dc=ntelos, dc=net
113
114
# Here is the config tree that brian.ntelos.net points to. 
115
dn: cn=DHCP Service Config, dc=ntelos, dc=net
116
cn: DHCP Service Config
117
objectClass: top
118
objectClass: dhcpService
119
dhcpPrimaryDN: dc=ntelos, dc=net
120
dhcpStatements: ddns-update-style none
121
dhcpStatements: default-lease-time 600
122
dhcpStatements: max-lease-time 7200
123
124
# Set up a shared network segment
125
dn: cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
126
cn: WV
127
objectClass: top
128
objectClass: dhcpSharedNetwork
129
130
# Set up a subnet declaration with a pool statement. Also note that we have
131
# a dhcpOptions object with this entry
132
dn: cn=10.100.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
133
cn: 10.100.0.0
134
objectClass: top
135
objectClass: dhcpSubnet
136
objectClass: dhcpOptions
137
dhcpOption: domain-name-servers 10.100.0.2
138
dhcpOption: routers 10.100.0.1
139
dhcpOption: subnet-mask 255.255.255.0
140
dhcpOption: broadcast-address 10.100.0.255
141
dhcpNetMask: 24
142
143
# Set up a pool for this subnet. Only known hosts will get these IPs
144
dn: cn=Known Pool, cn=10.100.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
145
cn: Known Pool
146
objectClass: top
147
objectClass: dhcpPool
148
dhcpRange: 10.100.0.3 10.100.0.254
149
dhcpPermitList: deny unknown-clients
150
151
# Set up another subnet declaration with a pool statement
152
dn: cn=10.200.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
153
cn: 10.200.0.0
154
objectClass: top
155
objectClass: dhcpSubnet
156
objectClass: dhcpOptions
157
dhcpOption: domain-name-servers 10.200.0.2
158
dhcpOption: routers 10.200.0.1
159
dhcpOption: subnet-mask 255.255.255.0
160
dhcpOption: broadcast-address 10.200.0.255
161
dhcpNetMask: 24
162
163
# Set up a pool for this subnet. Only unknown hosts will get these IPs
164
dn: cn=Known Pool, cn=10.200.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
165
cn: Known Pool
166
objectClass: top
167
objectClass: dhcpPool
168
dhcpRange: 10.200.0.3 10.200.0.254
169
dhcpPermitList: deny known clients
170
171
# Set aside a group for all of our known MAC addresses
172
dn: cn=Customers, cn=DHCP Service Config, dc=ntelos, dc=net
173
objectClass: top
174
objectClass: dhcpGroup
175
cn: Customers
176
177
# Host entry for my laptop
178
dn: cn=brianlaptop, cn=Customers, cn=DHCP Service Config, dc=ntelos, dc=net
179
objectClass: top
180
objectClass: dhcpHost
181
cn: brianlaptop
182
dhcpHWAddress: ethernet 00:00:00:00:00:00
183
184
You can use the command slapadd to load all of these entries into your LDAP 
185
server. After you load this, you should be able to start up DHCP. If you run
186
into problems reading the configuration, try running dhcpd with the -d flag. 
187
If you still have problems, edit the site.conf file in the DHCP source and
188
add the line: COPTS= -DDEBUG_LDAP and recompile DHCP. (make sure you run make 
189
clean and rerun configure before you rebuild).
190
(-)dhcp-3.0.5/common/conflex.c (-15 / +31 lines)
Lines 47-52 Link Here
47
static enum dhcp_token read_number PROTO ((int, struct parse *));
47
static enum dhcp_token read_number PROTO ((int, struct parse *));
48
static enum dhcp_token read_num_or_name PROTO ((int, struct parse *));
48
static enum dhcp_token read_num_or_name PROTO ((int, struct parse *));
49
static enum dhcp_token intern PROTO ((char *, enum dhcp_token));
49
static enum dhcp_token intern PROTO ((char *, enum dhcp_token));
50
static int read_function PROTO ((struct parse *));
50
51
51
isc_result_t new_parse (cfile, file, inbuf, buflen, name, eolp)
52
isc_result_t new_parse (cfile, file, inbuf, buflen, name, eolp)
52
	struct parse **cfile;
53
	struct parse **cfile;
Lines 74-79 Link Here
74
	tmp -> file = file;
75
	tmp -> file = file;
75
	tmp -> eol_token = eolp;
76
	tmp -> eol_token = eolp;
76
77
78
	if (file != -1) {
79
		tmp -> read_function = read_function;;
80
	}
81
77
	tmp -> bufix = 0;
82
	tmp -> bufix = 0;
78
	tmp -> buflen = buflen;
83
	tmp -> buflen = buflen;
79
	if (inbuf) {
84
	if (inbuf) {
Lines 113-134 Link Here
113
	int c;
118
	int c;
114
119
115
	if (cfile -> bufix == cfile -> buflen) {
120
	if (cfile -> bufix == cfile -> buflen) {
116
		if (cfile -> file != -1) {
121
		if (cfile -> read_function) {
117
			cfile -> buflen =
122
			c = cfile -> read_function (cfile);
118
				read (cfile -> file,
123
		} else {
119
				      cfile -> inbuf, cfile -> bufsiz);
120
			if (cfile -> buflen == 0) {
121
				c = EOF;
122
				cfile -> bufix = 0;
123
			} else if (cfile -> buflen < 0) {
124
				c = EOF;
125
				cfile -> bufix = cfile -> buflen = 0;
126
			} else {
127
				c = cfile -> inbuf [0];
128
				cfile -> bufix = 1;
129
			}
130
		} else
131
			c = EOF;
124
			c = EOF;
125
		}
132
	} else {
126
	} else {
133
		c = cfile -> inbuf [cfile -> bufix];
127
		c = cfile -> inbuf [cfile -> bufix];
134
		cfile -> bufix++;
128
		cfile -> bufix++;
Lines 1128-1130 Link Here
1128
	}
1122
	}
1129
	return dfv;
1123
	return dfv;
1130
}
1124
}
1125
1126
1127
static int
1128
read_function (struct parse * cfile)
1129
{
1130
  int c;
1131
1132
	cfile -> buflen = read (cfile -> file, cfile -> inbuf, cfile -> bufsiz);
1133
	if (cfile -> buflen == 0) {
1134
		c = EOF;
1135
		cfile -> bufix = 0;
1136
	} else if (cfile -> buflen < 0) {
1137
		c = EOF;
1138
		cfile -> bufix = cfile -> buflen = 0;
1139
	} else {
1140
		c = cfile -> inbuf [0];
1141
		cfile -> bufix = 1;
1142
	}
1143
1144
	return c;
1145
}
1146
(-)dhcp-3.0.5/common/print.c (-3 / +3 lines)
Lines 166-174 Link Here
166
}
166
}
167
167
168
char *print_hw_addr (htype, hlen, data)
168
char *print_hw_addr (htype, hlen, data)
169
	int htype;
169
	const int htype;
170
	int hlen;
170
	const int hlen;
171
	unsigned char *data;
171
	const unsigned char *data;
172
{
172
{
173
	static char habuf [49];
173
	static char habuf [49];
174
	char *s;
174
	char *s;
(-)dhcp-3.0.5/contrib/dhcp.schema (+462 lines)
Line 0 Link Here
1
attributetype ( 2.16.840.1.113719.1.203.4.1 
2
	NAME 'dhcpPrimaryDN' 
3
	EQUALITY distinguishedNameMatch
4
	DESC 'The DN of the dhcpServer which is the primary server for the configuration.' 
5
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
6
7
attributetype ( 2.16.840.1.113719.1.203.4.2 
8
	NAME 'dhcpSecondaryDN' 
9
	EQUALITY distinguishedNameMatch
10
	DESC 'The DN of dhcpServer(s) which provide backup service for the configuration.'
11
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
12
13
attributetype ( 2.16.840.1.113719.1.203.4.3 
14
	NAME 'dhcpStatements' 
15
	EQUALITY caseIgnoreIA5Match
16
	DESC 'Flexible storage for specific data depending on what object this exists in. Like conditional statements, server parameters, etc. This allows the standard to evolve without needing to adjust the schema.' 
17
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
18
19
attributetype ( 2.16.840.1.113719.1.203.4.4 
20
	NAME 'dhcpRange' 
21
	EQUALITY caseIgnoreIA5Match
22
	DESC 'The starting & ending IP Addresses in the range (inclusive), separated by a hyphen; if the range only contains one address, then just the address can be specified with no hyphen.  Each range is defined as a separate value.'
23
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
24
25
attributetype ( 2.16.840.1.113719.1.203.4.5 
26
	NAME 'dhcpPermitList' 
27
	EQUALITY caseIgnoreIA5Match
28
	DESC 'This attribute contains the permit lists associated with a pool. Each permit list is defined as a separate value.' 
29
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
30
31
attributetype ( 2.16.840.1.113719.1.203.4.6 
32
	NAME 'dhcpNetMask' 
33
	EQUALITY integerMatch
34
	DESC 'The subnet mask length for the subnet.  The mask can be easily computed from this length.' 
35
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
36
37
attributetype ( 2.16.840.1.113719.1.203.4.7 
38
	NAME 'dhcpOption' 
39
	EQUALITY caseIgnoreIA5Match
40
	DESC 'Encoded option values to be sent to clients.  Each value represents a single option and contains (OptionTag, Length, OptionValue) encoded in the format used by DHCP.' 
41
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
42
43
attributetype ( 2.16.840.1.113719.1.203.4.8 
44
	NAME 'dhcpClassData' 
45
	EQUALITY caseIgnoreIA5Match
46
	DESC 'Encoded text string or list of bytes expressed in hexadecimal, separated by colons.  Clients match subclasses based on matching the class data with the results of match or spawn with statements in the class name declarations.' 
47
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
48
49
attributetype ( 2.16.840.1.113719.1.203.4.9 
50
	NAME 'dhcpOptionsDN' 
51
	EQUALITY distinguishedNameMatch
52
	DESC 'The distinguished name(s) of the dhcpOption objects containing the configuration options provided by the server.' 
53
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
54
55
attributetype ( 2.16.840.1.113719.1.203.4.10 
56
	NAME 'dhcpHostDN' 
57
	EQUALITY distinguishedNameMatch
58
	DESC 'the distinguished name(s) of the dhcpHost objects.' 
59
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) 
60
61
attributetype ( 2.16.840.1.113719.1.203.4.11 
62
	NAME 'dhcpPoolDN' 
63
	EQUALITY distinguishedNameMatch
64
	DESC 'The distinguished name(s) of pools.' 
65
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
66
67
attributetype ( 2.16.840.1.113719.1.203.4.12 
68
	NAME 'dhcpGroupDN' 
69
	EQUALITY distinguishedNameMatch
70
	DESC 'The distinguished name(s)   of the groups.' 
71
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
72
73
attributetype ( 2.16.840.1.113719.1.203.4.13 
74
	NAME 'dhcpSubnetDN' 
75
	EQUALITY distinguishedNameMatch
76
	DESC 'The distinguished name(s) of the subnets.' 
77
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
78
79
attributetype ( 2.16.840.1.113719.1.203.4.14 
80
	NAME 'dhcpLeaseDN' 
81
	EQUALITY distinguishedNameMatch
82
	DESC 'The distinguished name of a client address.' 
83
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE)
84
85
attributetype ( 2.16.840.1.113719.1.203.4.15 
86
	NAME 'dhcpLeasesDN' 
87
	DESC 'The distinguished name(s) client addresses.' 
88
	EQUALITY distinguishedNameMatch
89
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
90
91
attributetype ( 2.16.840.1.113719.1.203.4.16 
92
	NAME 'dhcpClassesDN' 
93
	EQUALITY distinguishedNameMatch
94
	DESC 'The distinguished name(s) of a class(es) in a subclass.' 
95
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
96
97
attributetype ( 2.16.840.1.113719.1.203.4.17 
98
	NAME 'dhcpSubclassesDN' 
99
	EQUALITY distinguishedNameMatch
100
	DESC 'The distinguished name(s) of subclass(es).' 
101
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
102
103
attributetype ( 2.16.840.1.113719.1.203.4.18 
104
	NAME 'dhcpSharedNetworkDN' 
105
	EQUALITY distinguishedNameMatch
106
	DESC 'The distinguished name(s) of sharedNetworks.' 
107
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
108
109
attributetype ( 2.16.840.1.113719.1.203.4.19 
110
	NAME 'dhcpServiceDN' 
111
	EQUALITY distinguishedNameMatch
112
	DESC 'The DN of dhcpService object(s)which contain the configuration information. Each dhcpServer object has this attribute identifying the DHCP configuration(s) that the server is associated with.' 
113
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
114
115
attributetype ( 2.16.840.1.113719.1.203.4.20 
116
	NAME 'dhcpVersion'
117
	DESC 'The version attribute of this object.'
118
	EQUALITY caseIgnoreIA5Match
119
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
120
121
attributetype ( 2.16.840.1.113719.1.203.4.21 
122
	NAME 'dhcpImplementation' 
123
	EQUALITY caseIgnoreIA5Match
124
	DESC 'Description of the DHCP Server implementation e.g. DHCP Servers vendor.' 
125
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
126
127
attributetype ( 2.16.840.1.113719.1.203.4.22 
128
	NAME 'dhcpAddressState' 
129
	EQUALITY caseIgnoreIA5Match
130
	DESC 'This stores information about the current binding-status of an address.  For dynamic addresses managed by DHCP, the values should be restricted to the following: "FREE", "ACTIVE", "EXPIRED", "RELEASED", "RESET", "ABANDONED", "BACKUP".  For other addresses, it SHOULD be one of the following: "UNKNOWN", "RESERVED" (an address that is managed by DHCP that is reserved for a specific client), "RESERVED-ACTIVE" (same as reserved, but address is currently in use), "ASSIGNED" (assigned manually or by some other mechanism), "UNASSIGNED", "NOTASSIGNABLE".'
131
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
132
133
attributetype ( 2.16.840.1.113719.1.203.4.23 
134
	NAME 'dhcpExpirationTime' 
135
	EQUALITY generalizedTimeMatch 
136
	DESC 'This is the time the current lease for an address expires.' 
137
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
138
139
attributetype ( 2.16.840.1.113719.1.203.4.24 
140
	NAME 'dhcpStartTimeOfState' 
141
	EQUALITY generalizedTimeMatch 
142
	DESC 'This is the time of the last state change for a leased address.' 
143
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
144
145
attributetype ( 2.16.840.1.113719.1.203.4.25 
146
	NAME 'dhcpLastTransactionTime' 
147
	EQUALITY generalizedTimeMatch 
148
	DESC 'This is the last time a valid DHCP packet was received from the client.'
149
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
150
151
attributetype ( 2.16.840.1.113719.1.203.4.26 
152
	NAME 'dhcpBootpFlag' 
153
	EQUALITY booleanMatch 
154
	DESC 'This indicates whether the address was assigned via BOOTP.' 
155
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )
156
157
attributetype ( 2.16.840.1.113719.1.203.4.27 
158
	NAME 'dhcpDomainName' 
159
	EQUALITY caseIgnoreIA5Match
160
	DESC 'This is the name of the domain sent to the client by the server.  It is essentially the same as the value for DHCP option 15 sent to the client, and represents only the domain - not the full FQDN.  To obtain the full FQDN assigned to the client you must prepend the "dhcpAssignedHostName" to this value with a ".".' 
161
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
162
163
attributetype ( 2.16.840.1.113719.1.203.4.28 
164
	NAME 'dhcpDnsStatus' 
165
	EQUALITY integerMatch
166
	DESC 'This indicates the status of updating DNS resource records on behalf of the client by the DHCP server for this address.  The value is a 16-bit bitmask.'
167
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
168
169
attributetype ( 2.16.840.1.113719.1.203.4.29 
170
	NAME 'dhcpRequestedHostName' 
171
	EQUALITY caseIgnoreIA5Match
172
	DESC 'This is the hostname that was requested by the client.' 
173
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
174
175
attributetype ( 2.16.840.1.113719.1.203.4.30 
176
	NAME 'dhcpAssignedHostName' 
177
	EQUALITY caseIgnoreIA5Match
178
	DESC 'This is the actual hostname that was assigned to a client. It may not be the name that was requested by the client.  The fully qualified domain name can be determined by appending the value of "dhcpDomainName" (with a dot separator) to this name.' 
179
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
180
181
attributetype ( 2.16.840.1.113719.1.203.4.31 
182
	NAME 'dhcpReservedForClient' 
183
	EQUALITY distinguishedNameMatch
184
	DESC 'The distinguished name of a "dhcpClient" that an address is reserved for.  This may not be the same as the "dhcpAssignedToClient" attribute if the address is being reassigned but the current lease has not yet expired.'
185
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
186
187
attributetype ( 2.16.840.1.113719.1.203.4.32 
188
	NAME 'dhcpAssignedToClient' 
189
	EQUALITY distinguishedNameMatch
190
	DESC 'This is the distinguished name of a "dhcpClient" that an address is currently assigned to.  This attribute is only present in the class when the address is leased.' 
191
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
192
193
attributetype ( 2.16.840.1.113719.1.203.4.33 
194
	NAME 'dhcpRelayAgentInfo' 
195
	EQUALITY octetStringMatch
196
	DESC 'If the client request was received via a relay agent, this contains information about the relay agent that was available from the DHCP request.  This is a hex-encoded option value.' 
197
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
198
199
attributetype ( 2.16.840.1.113719.1.203.4.34 
200
	NAME 'dhcpHWAddress' 
201
	EQUALITY caseIgnoreIA5Match
202
	DESC 'The clients hardware address that requested this IP address.' 
203
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
204
205
attributetype ( 2.16.840.1.113719.1.203.4.35 
206
	NAME 'dhcpHashBucketAssignment' 
207
	EQUALITY octetStringMatch
208
	DESC 'HashBucketAssignment bit map for the DHCP Server, as defined in DHC Load Balancing Algorithm [RFC 3074].' 
209
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
210
211
attributetype ( 2.16.840.1.113719.1.203.4.36 
212
	NAME 'dhcpDelayedServiceParameter' 
213
	EQUALITY integerMatch
214
	DESC 'Delay in seconds corresponding to Delayed Service Parameter configuration, as defined in  DHC Load Balancing Algorithm [RFC 3074]. '
215
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
216
217
attributetype ( 2.16.840.1.113719.1.203.4.37 
218
	NAME 'dhcpMaxClientLeadTime' 
219
	EQUALITY integerMatch
220
	DESC 'Maximum Client Lead Time configuration in seconds, as defined in DHCP Failover Protocol [FAILOVR]' 
221
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
222
223
attributetype ( 2.16.840.1.113719.1.203.4.38 
224
	NAME 'dhcpFailOverEndpointState' 
225
	EQUALITY caseIgnoreIA5Match
226
	DESC 'Server (Failover Endpoint) state, as defined in DHCP Failover Protocol [FAILOVR]' 
227
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
228
229
attributetype ( 2.16.840.1.113719.1.203.4.39 
230
	NAME 'dhcpErrorLog' 
231
	EQUALITY caseIgnoreIA5Match
232
	DESC 'Generic error log attribute that allows logging error conditions within a dhcpService or a dhcpSubnet, like no IP addresses available for lease.'
233
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
234
235
attributetype ( 2.16.840.1.113719.1.203.4.40 
236
	NAME 'dhcpLocatorDN' 
237
	EQUALITY distinguishedNameMatch 
238
	DESC 'The DN of dhcpLocator object which contain the DNs of all DHCP configuration objects. There will be a single dhcpLocator object in the tree with links to all the DHCP objects in the tree' 
239
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
240
241
attributetype  ( 2.16.840.1.113719.1.203.4.41 
242
	NAME 'dhcpKeyAlgorithm' 
243
	EQUALITY caseIgnoreIA5Match 
244
	DESC 'Algorithm to generate TSIG Key' 
245
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
246
247
attributetype  ( 2.16.840.1.113719.1.203.4.42 
248
	NAME 'dhcpKeySecret' 
249
	EQUALITY octetStringMatch 
250
	DESC 'Secret to generate TSIG Key' SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
251
252
attributetype ( 2.16.840.1.113719.1.203.4.43 
253
	NAME 'dhcpDnsZoneServer' 
254
	EQUALITY caseIgnoreIA5Match 
255
	DESC 'Master server of the DNS Zone' 
256
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
257
258
attributetype ( 2.16.840.1.113719.1.203.4.44 
259
	NAME 'dhcpKeyDN' 
260
	EQUALITY distinguishedNameMatch 
261
	DESC 'The DNs of TSIG Key to use in secure dynamic updates. In case of locator object, this will be list of TSIG keys.  In case of DHCP Service, Shared Network, Subnet and DNS Zone, it will be a single key.' 
262
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12)
263
264
attributetype ( 2.16.840.1.113719.1.203.4.45 
265
	NAME 'dhcpZoneDN' 
266
	EQUALITY distinguishedNameMatch 
267
	DESC 'The DNs of DNS Zone. In case of locator object, this will be list of DNS Zones in the tree. In case of DHCP Service, Shared Network and Subnet, it will be a single DNS Zone.' 
268
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12)
269
270
attributetype ( 2.16.840.1.113719.1.203.4.46 
271
	NAME 'dhcpFailOverPrimaryServer' 
272
	EQUALITY caseIgnoreIA5Match 
273
	DESC 'IP address or DNS name of the server playing primary role in DHC Load Balancing and Fail over.' 
274
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26  )
275
276
attributetype ( 2.16.840.1.113719.1.203.4.47 
277
	NAME 'dhcpFailOverSecondaryServer' 
278
	EQUALITY caseIgnoreIA5Match 
279
	DESC 'IP address or DNS name of the server playing secondary role in DHC Load Balancing and Fail over.' 
280
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26  )
281
282
attributetype ( 2.16.840.1.113719.1.203.4.48
283
	NAME 'dhcpFailOverPrimaryPort' 
284
	EQUALITY integerMatch 
285
	DESC 'Port on which primary server listens for connections from its fail over peer (secondary server)' 
286
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27  )
287
	
288
attributetype ( 2.16.840.1.113719.1.203.4.49
289
	NAME 'dhcpFailOverSecondaryPort' 
290
	EQUALITY integerMatch 
291
	DESC 'Port on which secondary server listens for connections from its fail over peer (primary server)' 
292
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27  )
293
294
attributetype ( 2.16.840.1.113719.1.203.4.50
295
	NAME 'dhcpFailOverResponseDelay' 
296
	EQUALITY integerMatch 
297
	DESC 'Maximum response time in seconds, before Server assumes that connection to fail over peer has failed' 
298
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27  )
299
300
attributetype ( 2.16.840.1.113719.1.203.4.51
301
	NAME 'dhcpFailOverUnackedUpdates' 
302
	EQUALITY integerMatch 
303
	DESC 'Number of BNDUPD messages that server can send before it receives BNDACK from its fail over peer' 
304
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27  )
305
306
attributetype ( 2.16.840.1.113719.1.203.4.52
307
	NAME 'dhcpFailOverSplit' 
308
	EQUALITY integerMatch 
309
	DESC 'Split between the primary and secondary servers for fail over purpose' 
310
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27  )
311
312
attributetype ( 2.16.840.1.113719.1.203.4.53
313
	NAME 'dhcpFailOverLoadBalanceTime' 
314
	EQUALITY integerMatch 
315
	DESC 'Cutoff time in seconds, after which load balance is disabled' 
316
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.27  )
317
318
attributetype ( 2.16.840.1.113719.1.203.4.54
319
	NAME 'dhcpFailOverPeerDN' 
320
	EQUALITY distinguishedNameMatch 
321
	DESC 'The DNs of Fail over peers. In case of locator object, this will be list of fail over peers in the tree. In case of Subnet and pool, it will be a single Fail Over Peer' 
322
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 ) 
323
324
#List of all servers in the tree
325
attributetype ( 2.16.840.1.113719.1.203.4.55
326
	NAME 'dhcpServerDN' 
327
	EQUALITY distinguishedNameMatch 
328
	DESC 'List of all  DHCP Servers in the tree. Used by dhcpLocatorObject' 
329
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
330
331
attributetype ( 2.16.840.1.113719.1.203.4.56
332
	NAME 'dhcpComments' 
333
	EQUALITY caseIgnoreIA5Match 
334
	DESC 'Generic attribute that allows coments  within any DHCP object' 
335
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
336
337
# Classes
338
339
objectclass ( 2.16.840.1.113719.1.203.6.1 
340
	NAME 'dhcpService' 
341
	DESC 'Service object that represents the actual DHCP Service configuration. This is a container object.' 
342
	SUP top 
343
	MUST (cn) 
344
	MAY ( dhcpPrimaryDN $ dhcpSecondaryDN $ dhcpServerDN $ dhcpSharedNetworkDN $ dhcpSubnetDN $ dhcpGroupDN $ dhcpHostDN $  dhcpClassesDN $ dhcpOptionsDN $ dhcpZoneDN $ dhcpKeyDN $ dhcpFailOverPeerDN $ dhcpStatements $dhcpComments $ dhcpOption) )
345
346
objectclass ( 2.16.840.1.113719.1.203.6.2 
347
	NAME 'dhcpSharedNetwork' 
348
	DESC 'This stores configuration information for a shared network.' 
349
	SUP top 
350
	MUST cn 
351
	MAY ( dhcpSubnetDN $ dhcpPoolDN $ dhcpOptionsDN $ dhcpZoneDN $ dhcpStatements $dhcpComments $ dhcpOption) X-NDS_CONTAINMENT ('dhcpService' ) )
352
353
objectclass ( 2.16.840.1.113719.1.203.6.3 
354
	NAME 'dhcpSubnet' 
355
	DESC 'This class defines a subnet. This is a container object.' 
356
	SUP top 
357
	MUST ( cn $ dhcpNetMask ) 
358
	MAY ( dhcpRange $ dhcpPoolDN $ dhcpGroupDN $ dhcpHostDN $ dhcpClassesDN $ dhcpLeasesDN $ dhcpOptionsDN $ dhcpZoneDN $ dhcpKeyDN $ dhcpFailOverPeerDN $ dhcpStatements $ dhcpComments $ dhcpOption ) X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork') )
359
360
objectclass ( 2.16.840.1.113719.1.203.6.4 
361
	NAME 'dhcpPool' 
362
	DESC 'This stores configuration information about a pool.' 
363
	SUP top 
364
	MUST ( cn $ dhcpRange ) 
365
	MAY ( dhcpClassesDN $ dhcpPermitList $ dhcpLeasesDN $ dhcpOptionsDN $ dhcpZoneDN $dhcpKeyDN $ dhcpStatements $ dhcpComments $ dhcpOption ) 
366
	X-NDS_CONTAINMENT ('dhcpSubnet' 'dhcpSharedNetwork') )
367
368
objectclass ( 2.16.840.1.113719.1.203.6.5 
369
	NAME 'dhcpGroup' 
370
	DESC 'Group object that lists host DNs and parameters. This is a container object.' 
371
	SUP top 
372
	MUST cn 
373
	MAY ( dhcpHostDN $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption )
374
	X-NDS_CONTAINMENT ('dhcpSubnet' 'dhcpService' ) )
375
376
objectclass ( 2.16.840.1.113719.1.203.6.6 
377
	NAME 'dhcpHost' 
378
	DESC 'This represents information about a particular client' 
379
	SUP top 
380
	MUST cn 
381
	MAY  (dhcpLeaseDN $ dhcpHWAddress $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption) 
382
	X-NDS_CONTAINMENT ('dhcpService' 'dhcpSubnet' 'dhcpGroup') )
383
384
objectclass ( 2.16.840.1.113719.1.203.6.7 
385
	NAME 'dhcpClass' 
386
	DESC 'Represents information about a collection of related clients.' 
387
	SUP top 
388
	MUST cn 
389
	MAY (dhcpSubClassesDN $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption) 
390
	X-NDS_CONTAINMENT ('dhcpService' 'dhcpSubnet' ) )
391
392
objectclass ( 2.16.840.1.113719.1.203.6.8 
393
	NAME 'dhcpSubClass' 
394
	DESC 'Represents information about a collection of related classes.' 
395
	SUP top 
396
	MUST cn 
397
	MAY (dhcpClassData $ dhcpOptionsDN $ dhcpStatements $ dhcpComments $ dhcpOption) X-NDS_CONTAINMENT 'dhcpClass' )
398
399
objectclass ( 2.16.840.1.113719.1.203.6.9 
400
	NAME 'dhcpOptions' 
401
	DESC 'Represents information about a collection of options defined.' 
402
	SUP top AUXILIARY
403
	MUST cn 
404
	MAY ( dhcpOption $ dhcpComments ) 
405
	X-NDS_CONTAINMENT  ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet' 'dhcpPool' 'dhcpGroup' 'dhcpHost' 'dhcpClass' ) )
406
407
objectclass ( 2.16.840.1.113719.1.203.6.10 
408
	NAME 'dhcpLeases' 
409
	DESC 'This class represents an IP Address, which may or may not have been leased.' 
410
	SUP top 
411
	MUST ( cn $ dhcpAddressState ) 
412
	MAY ( dhcpExpirationTime $ dhcpStartTimeOfState $ dhcpLastTransactionTime $ dhcpBootpFlag $ dhcpDomainName $ dhcpDnsStatus $ dhcpRequestedHostName $ dhcpAssignedHostName $ dhcpReservedForClient $ dhcpAssignedToClient $ dhcpRelayAgentInfo $ dhcpHWAddress ) 
413
	X-NDS_CONTAINMENT ( 'dhcpService' 'dhcpSubnet' 'dhcpPool') )
414
415
objectclass ( 2.16.840.1.113719.1.203.6.11 
416
	NAME 'dhcpLog' 
417
	DESC 'This is the object that holds past information about the IP address. The cn is the time/date stamp when the address was assigned or released, the address state at the time, if the address was assigned or released.' 
418
	SUP top 
419
	MUST ( cn ) 
420
	MAY ( dhcpAddressState $ dhcpExpirationTime $ dhcpStartTimeOfState $ dhcpLastTransactionTime $ dhcpBootpFlag $ dhcpDomainName $ dhcpDnsStatus $ dhcpRequestedHostName $ dhcpAssignedHostName $ dhcpReservedForClient $ dhcpAssignedToClient $ dhcpRelayAgentInfo $ dhcpHWAddress $ dhcpErrorLog) 
421
	X-NDS_CONTAINMENT ('dhcpLeases' 'dhcpPool' 'dhcpSubnet' 'dhcpSharedNetwork' 'dhcpService' ) )
422
423
objectclass ( 2.16.840.1.113719.1.203.6.12 
424
	NAME 'dhcpServer' 
425
	DESC 'DHCP Server Object' 
426
	SUP top 
427
	MUST ( cn ) 
428
	MAY (dhcpServiceDN  $ dhcpLocatorDN $ dhcpVersion $ dhcpImplementation $ dhcpHashBucketAssignment $ dhcpDelayedServiceParameter $ dhcpMaxClientLeadTime $ dhcpFailOverEndpointState $ dhcpStatements $ dhcpComments $ dhcpOption) 
429
	X-NDS_CONTAINMENT ('organization' 'organizationalunit' 'domain') )
430
431
objectclass ( 2.16.840.1.113719.1.203.6.13 
432
	NAME 'dhcpTSigKey' 
433
	DESC 'TSIG key for secure dynamic updates' 
434
	SUP top 
435
	MUST (cn $ dhcpKeyAlgorithm $ dhcpKeySecret ) 
436
	MAY ( dhcpComments ) 
437
	X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet') )
438
439
objectclass ( 2.16.840.1.113719.1.203.6.14 
440
	NAME 'dhcpDnsZone' 
441
	DESC 'DNS Zone for updating leases' 
442
	SUP top 
443
	MUST (cn $ dhcpDnsZoneServer ) 
444
	MAY (dhcpKeyDN $ dhcpComments) 
445
	X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet') )
446
447
objectclass ( 2.16.840.1.113719.1.203.6.15 
448
	NAME 'dhcpFailOverPeer' 
449
	DESC 'This class defines the Fail over peer' 
450
	SUP top 
451
  MUST ( cn $ dhcpFailOverPrimaryServer $ dhcpFailOverSecondaryServer $ dhcpFailoverPrimaryPort $ dhcpFailOverSecondaryPort) MAY (dhcpFailOverResponseDelay  $ dhcpFailOverUnackedUpdates $ dhcpMaxClientLeadTime $ dhcpFailOverSplit $ dhcpHashBucketAssignment $ dhcpFailOverLoadBalanceTime $ dhcpComments ) 
452
	X-NDS_CONTAINMENT ('dhcpService' 'dhcpSharedNetwork' 'dhcpSubnet') )
453
454
objectclass ( 2.16.840.1.113719.1.203.6.16 
455
	NAME 'dhcpLocator' 
456
	DESC 'Locator object for DHCP configuration in the tree. There will be a single dhcpLocator object in the tree with links to all the DHCP objects in the tree' 
457
	SUP top 
458
	MUST ( cn ) 
459
	MAY ( dhcpServiceDN $dhcpServerDN $ dhcpSharedNetworkDN $ dhcpSubnetDN $ dhcpPoolDN $ dhcpGroupDN $ dhcpHostDN $  dhcpClassesDN $ dhcpKeyDN $ dhcpZoneDN $ dhcpFailOverPeerDN $ dhcpOption $ dhcpComments) 
460
	X-NDS_CONTAINMENT ('organization' 'organizationalunit' 'domain') )
461
462
(-)dhcp-3.0.5/contrib/dhcpd-conf-to-ldap.pl (+760 lines)
Line 0 Link Here
1
#!/usr/bin/perl -w
2
3
# Brian Masney <masneyb@ntelos.net>
4
# To use this script, set your base DN below. Then run 
5
# ./dhcpd-conf-to-ldap.pl < /path-to-dhcpd-conf/dhcpd.conf > output-file
6
# The output of this script will generate entries in LDIF format. You can use
7
# the slapadd command to add these entries into your LDAP server. You will
8
# definately want to double check that your LDAP entries are correct before
9
# you load them into LDAP.
10
11
# This script does not do much error checking. Make sure before you run this
12
# that the DHCP server doesn't give any errors about your config file
13
14
# FailOver notes:
15
#   Failover is disabled by default, since it may need manually intervention.
16
#   You can try the '--use=failover' option to see what happens :-)
17
#
18
#   If enabled, the failover pool references will be written to LDIF output.
19
#   The failover configs itself will be added to the dhcpServer statements
20
#   and not to the dhcpService object (since this script uses only one and
21
#   it may be usefull to have multiple service containers in failover mode).
22
#   Further, this script does not check if primary or secondary makes sense,
23
#   it simply converts what it gets...
24
25
use Net::Domain qw(hostname hostfqdn hostdomain);
26
use Getopt::Long;
27
28
my $domain = hostdomain();           # your.domain
29
my $basedn = "dc=".$domain;
30
   $basedn =~ s/\./,dc=/g;           # dc=your,dc=domain
31
my $server = hostname();             # hostname (nodename)
32
my $dhcpcn = 'DHCP Config';          # CN of DHCP config tree
33
my $dhcpdn = "cn=$dhcpcn, $basedn";  # DHCP config tree DN
34
my $second = '';                     # secondary server DN / hostname
35
my $i_conf = '';                     # dhcp.conf file to read or stdin
36
my $o_ldif = '';                     # output ldif file name or stdout
37
my @use    = ();                     # extended flags (failover)
38
39
sub usage($;$)
40
{
41
  my $rc = shift;
42
  my $err= shift;
43
44
  print STDERR "Error: $err\n\n" if(defined $err);
45
  print STDERR <<__EOF_USAGE__;
46
usage: 
47
  $0 [options] < dhcpd.conf > dhcpd.ldif
48
49
options:
50
51
  --basedn  "dc=your,dc=domain"        ("$basedn")
52
53
  --dhcpdn  "dhcp config DN"           ("$dhcpdn")
54
55
  --server  "dhcp server name"         ("$server")
56
57
  --second  "secondary server or DN"   ("$second")
58
59
  --conf    "/path/to/dhcpd.conf"      (default is stdin)
60
  --ldif    "/path/to/output.ldif"     (default is stdout)
61
62
  --use     "extended features"        (see source comments)
63
__EOF_USAGE__
64
  exit($rc);
65
}
66
67
68
sub next_token
69
{
70
  local ($lowercase) = @_;
71
  local ($token, $newline);
72
73
  do 
74
    {
75
      if (!defined ($line) || length ($line) == 0)
76
        {
77
          $line = <>;
78
          return undef if !defined ($line);
79
          chop $line;
80
          $line_number++;
81
          $token_number = 0;
82
        }
83
84
      $line =~ s/#.*//;
85
      $line =~ s/^\s+//;
86
      $line =~ s/\s+$//;
87
    }
88
  while (length ($line) == 0);
89
90
  if (($token, $newline) = $line =~ /^(.*?)\s+(.*)/)
91
    {
92
      if ($token =~ /^"/) {
93
       #handle quoted token
94
       if ($token !~ /"\s*$/)
95
       {
96
         ($tok, $newline)  = $newline =~ /([^"]+")(.*)/;
97
         $token .= " $tok";
98
        }
99
      }
100
      $line = $newline;
101
    }
102
  else
103
    {
104
      $token = $line;
105
      $line = '';
106
    }
107
  $token_number++;
108
109
  $token =~ y/[A-Z]/[a-z]/ if $lowercase;
110
111
  return ($token);
112
}
113
114
115
sub remaining_line
116
{
117
  local ($block) = shift || 0;
118
  local ($tmp, $str);
119
120
  $str = "";
121
  while (defined($tmp = next_token (0)))
122
    {
123
      $str .= ' ' if !($str eq "");
124
      $str .= $tmp;
125
      last if $tmp =~ /;\s*$/;
126
      last if($block and $tmp =~ /\s*[}{]\s*$/);
127
    }
128
129
  $str =~ s/;$//;
130
  return ($str);
131
}
132
133
134
sub
135
add_dn_to_stack
136
{
137
  local ($dn) = @_;
138
139
  $current_dn = "$dn, $current_dn";
140
}
141
142
143
sub
144
remove_dn_from_stack
145
{
146
  $current_dn =~ s/^.*?,\s*//;
147
}
148
149
150
sub
151
parse_error
152
{
153
  print "Parse error on line number $line_number at token number $token_number\n";
154
  exit (1);
155
}
156
157
158
sub
159
print_entry
160
{
161
  return if (scalar keys %curentry == 0);
162
163
  if (!defined ($curentry{'type'}))
164
    {
165
      $hostdn = "cn=$server, $basedn";
166
      print "dn: $hostdn\n";
167
      print "cn: $server\n";
168
      print "objectClass: top\n";
169
      print "objectClass: dhcpServer\n";
170
      print "dhcpServiceDN: $current_dn\n";
171
      if(grep(/FaIlOvEr/i, @use))
172
        {
173
          foreach my $fo_peer (keys %failover)
174
            {
175
              next if(scalar(@{$failover{$fo_peer}}) <= 1);
176
              print "dhcpStatements: failover peer $fo_peer { ",
177
                    join('; ', @{$failover{$fo_peer}}), "; }\n";
178
            }
179
        }
180
      print "\n";
181
182
      print "dn: $current_dn\n";
183
      print "cn: $dhcpcn\n";
184
      print "objectClass: top\n";
185
      print "objectClass: dhcpService\n";
186
      if (defined ($curentry{'options'}))
187
        {
188
          print "objectClass: dhcpOptions\n";
189
        }
190
      print "dhcpPrimaryDN: $hostdn\n";
191
      if(grep(/FaIlOvEr/i, @use) and ($second ne ''))
192
        {
193
          print "dhcpSecondaryDN: $second\n";
194
        }
195
    }
196
  elsif ($curentry{'type'} eq 'subnet')
197
    {
198
      print "dn: $current_dn\n";
199
      print "cn: " . $curentry{'ip'} . "\n";
200
      print "objectClass: top\n";
201
      print "objectClass: dhcpSubnet\n";
202
      if (defined ($curentry{'options'}))
203
        {
204
          print "objectClass: dhcpOptions\n";
205
        }
206
      
207
      print "dhcpNetMask: " . $curentry{'netmask'} . "\n";
208
      if (defined ($curentry{'ranges'}))
209
        {
210
          foreach $statement (@{$curentry{'ranges'}})
211
            {
212
              print "dhcpRange: $statement\n";
213
            }
214
        }
215
    }
216
  elsif ($curentry{'type'} eq 'shared-network')
217
    {
218
      print "dn: $current_dn\n";
219
      print "cn: " . $curentry{'descr'} . "\n";
220
      print "objectClass: top\n";
221
      print "objectClass: dhcpSharedNetwork\n";
222
      if (defined ($curentry{'options'}))
223
        {
224
          print "objectClass: dhcpOptions\n";
225
        }
226
    }
227
  elsif ($curentry{'type'} eq 'group')
228
    {
229
      print "dn: $current_dn\n";
230
      print "cn: group", $curentry{'idx'}, "\n";
231
      print "objectClass: top\n";
232
      print "objectClass: dhcpGroup\n";
233
      if (defined ($curentry{'options'}))
234
        {
235
          print "objectClass: dhcpOptions\n";
236
        }
237
    }
238
  elsif ($curentry{'type'} eq 'host')
239
    {
240
      print "dn: $current_dn\n";
241
      print "cn: " . $curentry{'host'} . "\n";
242
      print "objectClass: top\n";
243
      print "objectClass: dhcpHost\n";
244
      if (defined ($curentry{'options'}))
245
        {
246
          print "objectClass: dhcpOptions\n";
247
        }
248
249
      if (defined ($curentry{'hwaddress'}))
250
        {
251
          $curentry{'hwaddress'} =~ y/[A-Z]/[a-z]/;
252
          print "dhcpHWAddress: " . $curentry{'hwaddress'} . "\n";
253
        }
254
    }
255
  elsif ($curentry{'type'} eq 'pool')
256
    {
257
      print "dn: $current_dn\n";
258
      print "cn: pool", $curentry{'idx'}, "\n";
259
      print "objectClass: top\n";
260
      print "objectClass: dhcpPool\n";
261
      if (defined ($curentry{'options'}))
262
        {
263
          print "objectClass: dhcpOptions\n";
264
        }
265
266
      if (defined ($curentry{'ranges'}))
267
        {
268
          foreach $statement (@{$curentry{'ranges'}})
269
            {
270
              print "dhcpRange: $statement\n";
271
            }
272
        }
273
    }
274
  elsif ($curentry{'type'} eq 'class')
275
    {
276
      print "dn: $current_dn\n";
277
      print "cn: " . $curentry{'class'} . "\n";
278
      print "objectClass: top\n";
279
      print "objectClass: dhcpClass\n";
280
      if (defined ($curentry{'options'}))
281
        {
282
          print "objectClass: dhcpOptions\n";
283
        }
284
    }
285
  elsif ($curentry{'type'} eq 'subclass')
286
    {
287
      print "dn: $current_dn\n";
288
      print "cn: " . $curentry{'subclass'} . "\n";
289
      print "objectClass: top\n";
290
      print "objectClass: dhcpSubClass\n";
291
      if (defined ($curentry{'options'}))
292
        {
293
          print "objectClass: dhcpOptions\n";
294
        }
295
      print "dhcpClassData: " . $curentry{'class'} . "\n";
296
    }
297
298
  if (defined ($curentry{'statements'}))
299
    {
300
      foreach $statement (@{$curentry{'statements'}})
301
        {
302
          print "dhcpStatements: $statement\n";
303
        }
304
    }
305
306
  if (defined ($curentry{'options'}))
307
    {
308
      foreach $statement (@{$curentry{'options'}})
309
        {
310
          print "dhcpOption: $statement\n";
311
        }
312
    }
313
314
  print "\n";
315
  undef (%curentry);
316
}
317
318
319
sub parse_netmask
320
{
321
  local ($netmask) = @_;
322
  local ($i);
323
324
  if ((($a, $b, $c, $d) = $netmask =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) != 4)
325
    {
326
      parse_error ();
327
    }
328
329
  $num = (($a & 0xff) << 24) |
330
         (($b & 0xff) << 16) |
331
         (($c & 0xff) << 8) |
332
          ($d & 0xff);
333
334
  for ($i=1; $i<=32 && $num & (1 << (32 - $i)); $i++)
335
    {
336
    }
337
  $i--;
338
339
  return ($i);
340
}
341
342
343
sub parse_subnet
344
{
345
  local ($ip, $tmp, $netmask);
346
347
  print_entry () if %curentry;
348
    
349
  $ip = next_token (0);
350
  parse_error () if !defined ($ip);
351
352
  $tmp = next_token (1);
353
  parse_error () if !defined ($tmp);
354
  parse_error () if !($tmp eq 'netmask');
355
356
  $tmp = next_token (0);
357
  parse_error () if !defined ($tmp);
358
  $netmask = parse_netmask ($tmp);
359
360
  $tmp = next_token (0);
361
  parse_error () if !defined ($tmp);
362
  parse_error () if !($tmp eq '{');
363
364
  add_dn_to_stack ("cn=$ip");
365
  $curentry{'type'} = 'subnet';
366
  $curentry{'ip'} = $ip;
367
  $curentry{'netmask'} = $netmask;
368
  $cursubnet = $ip;
369
  $curcounter{$ip} = { pool  => 0, group => 0 };
370
}
371
372
373
sub parse_shared_network
374
{
375
  local ($descr, $tmp);
376
377
  print_entry () if %curentry;
378
379
  $descr = next_token (0);
380
  parse_error () if !defined ($descr);
381
382
  $tmp = next_token (0);
383
  parse_error () if !defined ($tmp);
384
  parse_error () if !($tmp eq '{');
385
386
  add_dn_to_stack ("cn=$descr");
387
  $curentry{'type'} = 'shared-network';
388
  $curentry{'descr'} = $descr;
389
}
390
391
392
sub parse_host
393
{
394
  local ($descr, $tmp);
395
396
  print_entry () if %curentry;
397
398
  $host = next_token (0);
399
  parse_error () if !defined ($host);
400
401
  $tmp = next_token (0);
402
  parse_error () if !defined ($tmp);
403
  parse_error () if !($tmp eq '{');
404
405
  add_dn_to_stack ("cn=$host");
406
  $curentry{'type'} = 'host';
407
  $curentry{'host'} = $host;
408
}
409
410
411
sub parse_group
412
{
413
  local ($descr, $tmp);
414
415
  print_entry () if %curentry;
416
417
  $tmp = next_token (0);
418
  parse_error () if !defined ($tmp);
419
  parse_error () if !($tmp eq '{');
420
421
  my $idx;
422
  if(exists($curcounter{$cursubnet})) {
423
    $idx = ++$curcounter{$cursubnet}->{'group'};
424
  } else {
425
    $idx = ++$curcounter{''}->{'group'};
426
  }
427
428
  add_dn_to_stack ("cn=group".$idx);
429
  $curentry{'type'} = 'group';
430
  $curentry{'idx'} = $idx;
431
}
432
433
434
sub parse_pool
435
{
436
  local ($descr, $tmp);
437
438
  print_entry () if %curentry;
439
440
  $tmp = next_token (0);
441
  parse_error () if !defined ($tmp);
442
  parse_error () if !($tmp eq '{');
443
444
  my $idx;
445
  if(exists($curcounter{$cursubnet})) {
446
    $idx = ++$curcounter{$cursubnet}->{'pool'};
447
  } else {
448
    $idx = ++$curcounter{''}->{'pool'};
449
  }
450
451
  add_dn_to_stack ("cn=pool".$idx);
452
  $curentry{'type'} = 'pool';
453
  $curentry{'idx'} = $idx;
454
}
455
456
457
sub parse_class
458
{
459
  local ($descr, $tmp);
460
461
  print_entry () if %curentry;
462
463
  $class = next_token (0);
464
  parse_error () if !defined ($class);
465
466
  $tmp = next_token (0);
467
  parse_error () if !defined ($tmp);
468
  parse_error () if !($tmp eq '{');
469
470
  $class =~ s/\"//g;
471
  add_dn_to_stack ("cn=$class");
472
  $curentry{'type'} = 'class';
473
  $curentry{'class'} = $class;
474
}
475
476
477
sub parse_subclass
478
{
479
  local ($descr, $tmp);
480
481
  print_entry () if %curentry;
482
483
  $class = next_token (0);
484
  parse_error () if !defined ($class);
485
486
  $subclass = next_token (0);
487
  parse_error () if !defined ($subclass);
488
489
  $tmp = next_token (0);
490
  parse_error () if !defined ($tmp);
491
  parse_error () if !($tmp eq '{');
492
493
  add_dn_to_stack ("cn=$subclass");
494
  $curentry{'type'} = 'subclass';
495
  $curentry{'class'} = $class;
496
  $curentry{'subclass'} = $subclass;
497
}
498
499
500
sub parse_hwaddress
501
{
502
  local ($type, $hw, $tmp);
503
504
  $type = next_token (1);
505
  parse_error () if !defined ($type);
506
507
  $hw = next_token (1);
508
  parse_error () if !defined ($hw);
509
  $hw =~ s/;$//;
510
511
  $curentry{'hwaddress'} = "$type $hw";
512
}
513
514
    
515
sub parse_range
516
{
517
  local ($tmp, $str);
518
519
  $str = remaining_line ();
520
521
  if (!($str eq ''))
522
    {
523
      $str =~ s/;$//;
524
      push (@{$curentry{'ranges'}}, $str);
525
    }
526
}
527
528
529
sub parse_statement
530
{
531
  local ($token) = shift;
532
  local ($str);
533
534
  if ($token eq 'option')
535
    {
536
      $str = remaining_line ();
537
      push (@{$curentry{'options'}}, $str);
538
    }
539
  elsif($token eq 'failover')
540
    {
541
      $str = remaining_line (1); # take care on block
542
      if($str =~ /[{]/)
543
        {
544
          my ($peername, @statements);
545
546
          parse_error() if($str !~ /^\s*peer\s+(.+?)\s+[{]\s*$/);
547
          parse_error() if(($peername = $1) !~ /^\"?[^\"]+\"?$/);
548
549
          #
550
          # failover config block found:
551
          # e.g. 'failover peer "some-name" {'
552
          #
553
          if(not grep(/FaIlOvEr/i, @use))
554
            {
555
              print STDERR "Warning: Failover config 'peer $peername' found!\n";
556
              print STDERR "         Skipping it, since failover disabled!\n";
557
              print STDERR "         You may try out --use=failover option.\n";
558
            }
559
560
          until($str =~ /[}]/ or $str eq "")
561
            {
562
                $str = remaining_line (1);
563
                # collect all statements, except ending '}'
564
                push(@statements, $str) if($str !~ /[}]/);
565
            }
566
          $failover{$peername} = [@statements];
567
        }
568
      else
569
        {
570
          #
571
          # pool reference to failover config is fine
572
          # e.g. 'failover peer "some-name";'
573
          #
574
          if(not grep(/FaIlOvEr/i, @use))
575
            {
576
              print STDERR "Warning: Failover reference '$str' found!\n";
577
              print STDERR "         Skipping it, since failover disabled!\n";
578
              print STDERR "         You may try out --use=failover option.\n";
579
            }
580
          else
581
            {
582
              push (@{$curentry{'statements'}}, $token. " " . $str);
583
            }
584
        }
585
    }
586
  elsif($token eq 'zone')
587
    {
588
      $str = $token;
589
      while($str !~ /}$/) {
590
        $str .= ' ' . next_token (0);
591
      }
592
      push (@{$curentry{'statements'}}, $str);
593
    }
594
  elsif($token =~ /^(authoritative)[;]*$/)
595
    {
596
      push (@{$curentry{'statements'}}, $1);
597
    }
598
  else
599
    {
600
      $str = $token . " " . remaining_line ();
601
      push (@{$curentry{'statements'}}, $str);
602
    }
603
}
604
605
606
my $ok = GetOptions(
607
    'basedn=s'      => \$basedn,
608
    'dhcpdn=s'      => \$dhcpdn,
609
    'server=s'      => \$server,
610
    'second=s'      => \$second,
611
    'conf=s'        => \$i_conf,
612
    'ldif=s'        => \$o_ldif,
613
    'use=s'         => \@use,
614
    'h|help|usage'  => sub { usage(0); },
615
);
616
617
unless($server =~ /^\w+/)
618
  {
619
    usage(1, "invalid server name '$server'");
620
  }
621
unless($basedn =~ /^\w+=[^,]+/)
622
  {
623
    usage(1, "invalid base dn '$basedn'");
624
  }
625
626
if($dhcpdn =~ /^cn=([^,]+)/i)
627
  {
628
    $dhcpcn = "$1";
629
  }
630
$second = '' if not defined $second;
631
unless($second eq '' or $second =~ /^cn=[^,]+\s*,\s*\w+=[^,]+/i)
632
  {
633
    if($second =~ /^cn=[^,]+$/i)
634
      {
635
        # relative DN 'cn=name'
636
        $second = "$second, $basedn";
637
      }
638
    elsif($second =~ /^\w+/)
639
      {
640
        # assume hostname only
641
        $second = "cn=$second, $basedn";
642
      }
643
    else
644
      {
645
        usage(1, "invalid secondary '$second'")
646
      }
647
  }
648
649
usage(1) unless($ok);
650
651
if($i_conf ne "" and -f $i_conf)
652
  {
653
    if(not open(STDIN, '<', $i_conf))
654
      {
655
        print STDERR "Error: can't open conf file '$i_conf': $!\n";
656
        exit(1);
657
      }
658
  }
659
if($o_ldif ne "")
660
  {
661
    if(-e $o_ldif)
662
      {
663
        print STDERR "Error: output ldif name '$o_ldif' already exists!\n";
664
        exit(1);
665
      }
666
    if(not open(STDOUT, '>', $o_ldif))
667
      {
668
        print STDERR "Error: can't open ldif file '$o_ldif': $!\n";
669
        exit(1);
670
      }
671
  }
672
673
674
print STDERR "Creating LDAP Configuration with the following options:\n";
675
print STDERR "\tBase DN: $basedn\n";
676
print STDERR "\tDHCP DN: $dhcpdn\n";
677
print STDERR "\tServer DN: cn=$server, $basedn\n";
678
print STDERR "\tSecondary DN: $second\n"
679
             if(grep(/FaIlOvEr/i, @use) and $second ne '');
680
print STDERR "\n";
681
682
my $token;
683
my $token_number = 0;
684
my $line_number = 0;
685
my %curentry;
686
my $cursubnet = '';
687
my %curcounter = ( '' => { pool => 0, group => 0 } );
688
689
$current_dn = "$dhcpdn";
690
$curentry{'descr'} = $dhcpcn;
691
$line = '';
692
%failover = ();
693
694
while (($token = next_token (1)))
695
  {
696
    if ($token eq '}')
697
      {
698
        print_entry () if %curentry;
699
        if($current_dn =~ /.+?,\s*${dhcpdn}$/) {
700
          # don't go below dhcpdn ...
701
          remove_dn_from_stack ();
702
        }
703
      }
704
    elsif ($token eq 'subnet')
705
      {
706
        parse_subnet ();
707
        next;
708
      }
709
    elsif ($token eq 'shared-network')
710
      {
711
        parse_shared_network ();
712
        next;
713
      }
714
    elsif ($token eq 'class')
715
      {
716
        parse_class ();
717
        next;
718
      }
719
    elsif ($token eq 'subclass')
720
      {
721
        parse_subclass ();
722
        next;
723
      }
724
    elsif ($token eq 'pool')
725
      {
726
        parse_pool ();
727
        next;
728
      }
729
    elsif ($token eq 'group')
730
      {
731
        parse_group ();
732
        next;
733
      }
734
    elsif ($token eq 'host')
735
      {
736
        parse_host ();
737
        next;
738
      }
739
    elsif ($token eq 'hardware')
740
      {
741
        parse_hwaddress ();
742
        next;
743
      }
744
    elsif ($token eq 'range')
745
      {
746
        parse_range ();
747
        next;
748
      }
749
    else
750
      {
751
        parse_statement ($token);
752
        next;
753
      }
754
  }
755
756
close(STDIN)  if($i_conf);
757
close(STDOUT) if($o_ldif);
758
759
print STDERR "Done.\n";
760
(-)dhcp-3.0.5/debian/changelog (+25 lines)
Line 0 Link Here
1
dhcp3-server-ldap (3.0.4-1) unstable; urgency=low
2
3
  * See ChangeLog-LDAP for changes in this release
4
5
 -- Brian Masney <masneyb@gftp.org>  Mon, 08 May 2006 08:31:46 -0400
6
7
dhcp3-server-ldap (3.0.1rc13-1) unstable; urgency=low
8
9
  * See ChangeLog-LDAP for changes in this release
10
11
 -- Brian Masney <masneyb@gftp.org>  Wed, 05 May 2004 07:20:13 -0400
12
13
dhcp3-server-ldap (3.0.1rc12-1) unstable; urgency=low
14
15
  * Updated patch to work against ISC DHCPD 3.0.1rc12
16
17
 -- Brian Masney <masneyb@gftp.org>  Mon, 08 Sep 2003 16:34:00 -0400
18
19
dhcp3-server-ldap (3.0.1rc11-2) unstable; urgency=low
20
21
  * Added these Debian files. They are mostly from the existing dhcp3-server
22
    package in Debian.
23
24
 -- Brian Masney <masneyb@gftp.org>  Mon, 04 Aug 2003 13:34:00 -0400
25
(-)dhcp-3.0.5/debian/control (+12 lines)
Line 0 Link Here
1
Source: dhcp3-server-ldap
2
Section: net
3
Priority: optional
4
Maintainer: Brian Masney <masneyb@gftp.org>
5
Build-Depends: debhelper (>= 2.1.18), dpkg-dev (>= 1.7.0), groff, libldap2-dev
6
Standards-Version: 2.4.0.0
7
8
Package: dhcp3-server-ldap
9
Architecture: any
10
Depends: ${shlibs:Depends}, debconf, debianutils (>= 1.7), dhcp3-server (>= 3.0+3.0.1rc9)
11
Conflicts: dhcp, dhcp3-ldap-ntelos
12
Description: This is the DHCP server with LDAP patches applied to it
(-)dhcp-3.0.5/debian/copyright (+30 lines)
Line 0 Link Here
1
/*
2
 * Copyright (c) 1996, 1997 The Internet Software Consortium.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * 1. Redistributions of source code must retain the above copyright
10
 *    notice, this list of conditions and the following disclaimer.
11
 * 2. Redistributions in binary form must reproduce the above copyright
12
 *    notice, this list of conditions and the following disclaimer in the
13
 *    documentation and/or other materials provided with the distribution.
14
 * 3. Neither the name of The Internet Software Consortium nor the names of its
15
 *    contributors may be used to endorse or promote products derived
16
 *    from this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
19
 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
20
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
22
 * THE INTERNET SOFTWARE CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29
 * OF THE POSSIBILITY OF SUCH DAMAGE.
30
 */
(-)dhcp-3.0.5/debian/dhcp3-server-ldap.files (+1 lines)
Line 0 Link Here
1
usr/sbin/dhcpd3
(-)dhcp-3.0.5/debian/dhcp3-server-ldap.postinst (+13 lines)
Line 0 Link Here
1
#!/bin/sh
2
3
set -e 
4
5
# Removes the left over diversions of the old package
6
7
if [ "$1" = remove -o "$1" = upgrade ]; then
8
	for v in `list_versions`; do
9
	        dpkg-divert --package dhcp3-server-ldap --remove \
10
			--rename --divert /usr/sbin/dhcpd3-noldap \
11
			/usr/sbin/dhcpd3
12
	done
13
fi
(-)dhcp-3.0.5/debian/dhcp3-server-ldap.postrm (+8 lines)
Line 0 Link Here
1
#!/bin/sh
2
3
set -e 
4
5
if [ "$1" = remove ]; then
6
	dpkg-divert --package dhcp3-server-ldap --remove --rename \
7
		--divert /usr/sbin/dhcpd3-noldap /usr/sbin/dhcpd3
8
fi
(-)dhcp-3.0.5/debian/dhcp3-server-ldap.preinst (+14 lines)
Line 0 Link Here
1
#!/bin/sh
2
3
set -e 
4
5
if [ "$1" = install -o "$1" = upgrade ]; then
6
	if dpkg-divert --list /usr/sbin/dhcpd3 \
7
		| grep -q "by dhcp3-server-ldap";
8
	then
9
		exit 0
10
	fi
11
		
12
	dpkg-divert --package dhcp3-server-ldap --add --rename \
13
		--divert /usr/sbin/dhcpd3-noldap /usr/sbin/dhcpd3
14
fi
(-)dhcp-3.0.5/debian/dirs (+1 lines)
Line 0 Link Here
1
usr/sbin
(-)dhcp-3.0.5/debian/rules (+87 lines)
Line 0 Link Here
1
#!/usr/bin/make -f
2
# Made with the iad of dh_make, by Craig Small
3
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
4
# Also some stuff taken from debmake scripts, by Cristopt Lameter.
5
6
# Uncomment this to turn on verbose mode.
7
#export DH_VERBOSE=1
8
9
export DH_COMPAT=3
10
11
DESTDIR = `pwd`/debian/tmp
12
13
IVARS = DESTDIR=$(DESTDIR)
14
15
BVARS = PREDEFINES='-D_PATH_DHCPD_DB=\"/var/lib/dhcp3/dhcpd.leases\" \
16
	-D_PATH_DHCLIENT_DB=\"/var/lib/dhcp3/dhclient.leases\" \
17
	-D_PATH_DHCLIENT_SCRIPT=\"/etc/dhcp3/dhclient-script\" \
18
	-D_PATH_DHCPD_CONF=\"/etc/dhcp3/dhcpd.conf\" \
19
        -D_PATH_DHCLIENT_CONF=\"/etc/dhcp3/dhclient.conf\"'
20
21
build: build-stamp
22
build-stamp:
23
	dh_testdir
24
25
	./configure
26
	$(MAKE) $(BVARS)
27
28
	touch build-stamp
29
30
clean: 
31
	dh_testdir
32
	rm -f build-stamp install-stamp
33
34
	# Add here commands to clean up after the build process.
35
	-$(MAKE) distclean
36
37
	# Remove leftover junk...
38
	rm -Rf work.linux-2.2/
39
40
	dh_clean
41
42
install: install-stamp
43
install-stamp: build-stamp
44
	dh_testdir
45
	dh_testroot
46
	dh_clean -k
47
	dh_installdirs
48
49
	# Add here commands to install the package into debian/tmp.
50
	$(MAKE) install $(IVARS)
51
52
	mv $(DESTDIR)/usr/sbin/dhcpd $(DESTDIR)/usr/sbin/dhcpd3
53
54
	dh_movefiles
55
56
	# Remove unwanted directories that dh_movefiles leaves around
57
	rmdir $(DESTDIR)/etc
58
	rm -Rf $(DESTDIR)/sbin/
59
	rm -Rf $(DESTDIR)/usr/bin/
60
	rm -Rf $(DESTDIR)/usr/include/
61
	rm -Rf $(DESTDIR)/usr/lib/
62
	rm -Rf $(DESTDIR)/usr/local/
63
	rm -Rf $(DESTDIR)/usr/man/
64
	rm -Rf $(DESTDIR)/var/
65
	rm -f $(DESTDIR)/usr/sbin/dhcrelay
66
67
	touch install-stamp
68
69
# Build architecture-dependent files here (this package does not contain
70
#	architecture-independent files).
71
binary-arch: build install
72
	dh_testdir -a
73
	dh_testroot -a
74
	dh_strip -a
75
	dh_compress -a
76
	dh_fixperms -a
77
	dh_installdeb -a
78
	dh_shlibdeps -a
79
	dh_gencontrol -a
80
	dh_md5sums -a
81
	dh_builddeb -a
82
83
source diff:                                                                  
84
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
85
86
binary: binary-arch
87
.PHONY: build clean binary-indep binary-arch binary
(-)dhcp-3.0.5/doc/draft-ietf-dhc-ldap-schema-01.txt (+1089 lines)
Line 0 Link Here
1
2
3
4
5
6
Network Working Group                                  M. Meredith,
7
Internet Draft                                         V. Nanjundaswamy,
8
Document: <draft-ietf-dhc-ldap-schema-00.txt>          M. Hinckley
9
Category: Proposed Standard                            Novell Inc.
10
Expires: 15th December 2001                            16th June 2001
11
12
13
                          LDAP Schema for DHCP
14
15
Status of this Memo
16
17
This document is an Internet-Draft and is in full conformance with all
18
provisions of Section 10 of RFC2026 [ ].
19
20
Internet-Drafts are working documents of the Internet Engineering Task
21
Force (IETF), its areas, and its working groups.  Note that other groups
22
may also distribute working documents as Internet-Drafts. Internet-
23
Drafts are draft documents valid for a maximum of six months and may be
24
updated, replaced, or obsolete by other documents at any time.  It is
25
inappropriate to use Internet-Drafts as reference material or to cite
26
them other than as "work in progress."  The list of current Internet-
27
Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt The
28
list of Internet-Draft Shadow Directories can be accessed at
29
http://www.ietf.org/shadow.html.
30
31
1. Abstract
32
33
This document defines a schema for representing DHCP configuration in an
34
LDAP directory. It can be used to represent the DHCP Service
35
configuration(s) for an entire enterprise network, a subset of the
36
network, or even a single server. Representing DHCP configuration in an
37
LDAP directory enables centralized management of DHCP services offered
38
by one or more DHCP Servers within the enterprise.
39
40
2. Conventions used in this document
41
42
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
43
"SHOULD", "SHOULD NOT", "RECOMMENDED",  "MAY", and "OPTIONAL" in this
44
document are to be interpreted as described in RFC-2119 [ ].
45
46
In places where different sets of terminology are commonly used to
47
represent similar DHCP concepts, this schema uses the terminology of the
48
Internet Software Consortium's DHCP server reference implementation.
49
For more information see www.isc.org.
50
51
3. Design Considerations
52
53
The DHCP LDAP schema is designed to be a simple multi-server schema. The
54
55
56
57
M. Meredith et al.        Expires December 2001                 [Page 1]
58
59
60
61
62
63
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
64
65
66
intent of this schema is to provide a basic framework for representing
67
the most common elements used in the configuration of DHCP Server.  This
68
should allow other network services to obtain and use basic DHCP
69
configuration information in a server-independent but knowledgeable way.
70
71
It is expected that some implementations may need to extend the schema
72
objects, in order to implement all of their features or needs. It is
73
recommended that you use the schema defined in this draft to represent
74
DHCP configuration information in an LDAP directory.  Conforming to a
75
standard schema improves interoperability between DHCP implementations
76
from different vendors.
77
78
Some implementations may choose not to support all of the objects
79
defined here.
80
81
Two decisions are explicitly left up to each implementation:
82
83
First, implementations may choose not to store the lease information in
84
the directory, so those objects would not be used.
85
86
Second, implementations may choose not to implement the auditing
87
information.
88
89
It is up to the implementation to determine if the data in the directory
90
is considered "authoritative", or if it is simply a copy of data from an
91
authoritative source. Validity of the information if used as a copy is
92
to be ensured by the implementation.
93
94
Primarily two types of applications will use the information in this
95
schema: 1. DHCP servers (for loading their configuration) 2. Management
96
Interfaces (for defining/editing configurations).
97
98
The schema should be efficient for the needs of both types of
99
applications.  The schema is designed to allow objects managed by DHCP
100
(such as computers, subnets, etc) to be present anywhere in a directory
101
hierarchy (to allow those objects to be placed in the directory for
102
managing administrative control and access to the objects).
103
104
The schema uses a few naming conventions - all object classes and
105
attributes are prefixed with "dhcp" to decrease the chance that object
106
classes and attributes will have the same name.  The schema also uses
107
standard naming attributes ("cn", "ou", etc) for all objects.
108
109
4. Common DHCP Configuration Attributes
110
111
Although DHCP manages several different types of objects, the
112
configuration of those objects is often similar.  Consequently, most of
113
these objects have a common set of attributes, which are defined below.
114
115
116
117
M. Meredith et al.        Expires December 2001                 [Page 2]
118
119
120
121
122
123
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
124
125
126
4.1. Attributes Definitions
127
128
The schema definitions listed below are for readability.  The LDIF
129
layout for this schema will follow in section 8.
130
131
Name: dhcpPrimaryDN Description: The Distinguished Name of the
132
dhcpServer object, which is the primary server for the configuration.
133
Syntax: DN Flags: SINGLE-VALUE
134
135
Named: dhcpSecondaryDN Description: The Distinguished Name(s) of the
136
dhcpServer object(s), which are secondary servers for the configuration.
137
Syntax: DN
138
139
Name: dhcpStatements Description: Flexible storage for representing any
140
specific data depending on the object to which it is attached. Examples
141
include conditional statements, Server parameters, etc.  This also
142
serves as a 'catch-all' attribute that allows the standard to evolve
143
without needing to update the schema.  Syntax: IA5String
144
145
Name: dhcpRange Description: The starting and ending IP Addresses in the
146
range (inclusive), separated by a hyphen; if the range only contains one
147
address, then just the address can be specified with no hyphen.  Each
148
range is defined as a separate value.  Syntax: IA5String
149
150
Name: dhcpPermitList Description: This attribute contains the permit
151
lists associated with a pool. Each permit list is defined as a separate
152
value.  Syntax: IA5String
153
154
Name: dhcpNetMask Description: The subnet mask length for the subnet.
155
The mask can be easily computed from this length.  Syntax: Integer
156
Flags: SINGLE-VALUE
157
158
Name: dhcpOption Description: Encoded option values to be sent to
159
clients.  Each value represents a single option and contains (OptionTag,
160
Length, OptionData) encoded in the format used by DHCP.  For more
161
information see [DHCPOPT].  Syntax: OctetString
162
163
Name: dhcpClassData Description: Encoded text string or list of bytes
164
expressed in hexadecimal, separated by colons. Clients match subclasses
165
based on matching the class data with the results of a 'match' or 'spawn
166
with' statement in the class name declarations.  Syntax: IA5String
167
Flags: SINGLE-VALUE
168
169
Name: dhcpSubclassesDN Description: List of subclasses, these are the
170
actual DN of each subclass object.  Syntax: DN
171
172
Name: dhcpClassesDN Description: List of classes, these are the actual
173
DN of each class object.  Syntax: DN
174
175
176
177
M. Meredith et al.        Expires December 2001                 [Page 3]
178
179
180
181
182
183
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
184
185
186
Name: dhcpSubnetDN Description: List of subnets, these are the actual DN
187
of each subnet object.  Syntax: DN
188
189
Name: dhcpPoolDN Description: List of pools, these are the actual DN of
190
each Pool object.  Syntax: DN
191
192
Name: dhcpOptionsDN Description: List of options, these are the actual
193
DN of each Options object.  Syntax: DN
194
195
Name: dhcpHostDN Description: List of hosts, these are the actual DN of
196
each host object.  Syntax: DN
197
198
Name: dhcpSharedNetworkDN Description: List of shared networks, these
199
are the actual DN of each shared network object.  Syntax: DN
200
201
Name: dhcpGroupDN Description: List of groups, these are the actual DN
202
of each Group object.  Syntax: DN
203
204
Name: dhcpLeaseDN Description: Single Lease DN. A dhcpHost configuration
205
uses this attribute to identify a static IP address assignment.  Syntax:
206
DN Flags: SINGLE-VALUE
207
208
Name: dhcpLeasesDN Description: List of leases, these are the actual DN
209
of each lease object.  Syntax: DN
210
211
Name: dhcpServiceDN Description: The DN of dhcpService object(s)which
212
contain the configuration information. Each dhcpServer object has this
213
attribute identifying the DHCP configuration(s) that the server is
214
associated with.  Syntax: DN
215
216
Name: dhcpHWAddress Description: The hardware address of the client
217
associated with a lease Syntax: OctetString Flags: SINGLE-VALUE
218
219
Name: dhcpVersion Description: This is the version identified for the
220
object that this attribute is part of. In case of the dhcpServer object,
221
this represents the DHCP software version.  Syntax: IA5String Flags:
222
SINGLE-VALUE
223
224
Name: dhcpImplementation Description: DHCP Server implementation
225
description e.g. DHCP Vendor information.  Syntax: IA5String Flags:
226
SINGLE-VALUE
227
228
Name: dhcpHashBucketAssignment Description: HashBucketAssignment bit map
229
for the DHCP Server, as defined in DHC Load Balancing Algorithm [RFC
230
3074].  Syntax: Octet String Flags: SINGLE-VALUE
231
232
Name: dhcpDelayedServiceParameter Description: Delay in seconds
233
corresponding to Delayed Service Parameter configuration, as defined in
234
235
236
237
M. Meredith et al.        Expires December 2001                 [Page 4]
238
239
240
241
242
243
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
244
245
246
DHC Load Balancing Algorithm [RFC 3074].  Syntax: Integer Flags: SINGLE-
247
VALUE
248
249
Name: dhcpMaxClientLeadTime Description: Maximum Client Lead Time
250
configuration in seconds, as defined in DHCP Failover Protocol [FAILOVR]
251
Syntax: Integer Flags: SINGLE-VALUE
252
253
Name: dhcpFailOverEndpointState Description: Server (Failover Endpoint)
254
state, as defined in DHCP Failover Protocol [FAILOVR] Syntax: IA5String
255
Flags: SINGLE-VALUE
256
257
5. Configurations and Services
258
259
The schema definitions below are for readability the LDIF layout for
260
this schema will follow in section 8.
261
262
The DHC working group is currently considering several proposals for
263
fail-over and redundancy of DHCP servers.  These may require sharing of
264
configuration information between servers.  This schema provides a
265
generalized mechanism for supporting any of these proposals, by
266
separating the definition of a server from the definition of
267
configuration service provided by the server.
268
269
Separating the DHCP Server (dhcpServer) and the DHCP Configuration
270
(dhcpService) representations allows a configuration service to be
271
provided by one or more servers. Similarly, a server may provide one or
272
more configurations. The schema allows a server to be configured as
273
either a primary or secondary provider of a DHCP configuration.
274
275
Configurations are also defined so that one configuration can include
276
some of the objects that are defined in another configuration.  This
277
allows for sharing and/or a hierarchy of related configuration items.
278
279
Name: dhcpService Description:  Service object that represents the
280
actual DHCP Service configuration. This will be a container with the
281
following attributes.  Must: cn, dhcpPrimaryDN May: dhcpSecondaryDN,
282
dhcpSharedNetworkDN, dhcpSubnetDN, dhcpGroupDN, dhcpHostDN,
283
dhcpClassesDN, dhcpOptionsDN, dhcpStatements
284
285
The following objects could exist inside the dhcpService container:
286
dhcpSharedNetwork, dhcpSubnet, dhcpGroup, dhcpHost, dhcpClass,
287
dhcpOptions, dhcpLog
288
289
Name: dhcpServer Description:  Server object that the DHCP server will
290
login as.  The configuration information is in the dhcpService container
291
that the dhcpServiceDN points to.  Must: cn, dhcpServiceDN May:
292
dhcpVersion, dhcpImplementation, dhcpHashBucketAssignment,
293
dhcpDelayedServiceParameter, dhcpMaxClientLeadTime, 
294
295
296
297
M. Meredith et al.        Expires December 2001                 [Page 5]
298
299
300
301
302
303
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
304
dhcpFailOverEndpointState, dhcpStatements
305
306
5.1. DHCP Declaration related classes:
307
308
Name: dhcpSharedNetwork Description: Shared Network class will list what
309
pools and subnets are in this network.
310
311
This will be a container with the following attributes.  Must: cn May:
312
dhcpSubnetDN, dhcpPoolDN, dhcpOptionsDN, dhcpStatements
313
314
The following objects can exist within a dhcpSharedNetwork container:
315
dhcpSubnet, dhcpPool, dhcpOptions, dhcpLog
316
317
Name: dhcpSubnet Description: Subnet object will include configuration
318
information associated with a subnet, including a range and a net mask.
319
320
This will be a container with the following attributes.  Must: cn
321
(Subnet address), dhcpNetMask May: dhcpRange, dhcpPoolDN, dhcpGroupDN,
322
dhcpHostDN, dhcpClassesDN, dhcpLeasesDN, dhcpOptionsDN, dhcpStatements
323
324
The following objects can exist within a dhcpSubnet container: dhcpPool,
325
dhcpGroup, dhcpHost, dhcpClass, dhcpOptions, dhcpLease, dhcpLog
326
327
Name: dhcpGroup Description: Group object will have configuration
328
information associated with a group.
329
330
This will be a container with the following attributes.  Must: cn May:
331
dhcpHostDN, dhcpOptionsDN, dhcpStatements
332
333
The following objects can exist within a dhcpGroup container: dhcpHost,
334
dhcpOptions
335
336
Name: dhcpHost Description: The host object includes DHCP host
337
declarations to assign a static IP address or declare the client as
338
known or specify statements for a specific client.  Must: cn May:
339
dhcpLeaseDN, dhcpHWAddress, dhcpOptionsDN, dhcpStatements
340
341
The following objects can exist within a dhcpHost container: dhcpLease,
342
dhcpOptions
343
344
Name: dhcpOptions Description: The options class is for option space
345
declarations, it contains a list of options.  Must: cn, dhcpOption
346
347
Name: dhcpClass Description: This is a class to group clients together
348
based on matching rules.
349
350
This will be a container with the following attributes.  Must: cn May:
351
dhcpSubClassesDN, dhcpOptionsDN, dhcpStatements
352
353
The following object can exist within a dhcpClass container:
354
dhcpSubclass, dhcpOptions
355
356
357
358
M. Meredith et al.        Expires December 2001                 [Page 6]
359
360
361
362
363
364
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
365
366
367
Name: dhcpSubClass Description: This includes configuration information
368
for a subclass associated with a class. The dhcpSubClass object will
369
always be contained within the corresponding class container object.
370
Must: cn May:  dhcpClassData, dhcpOptionsDN, dhcpStatements
371
372
Name: dhcpPool Description: This contains configuration for a pool that
373
will have the range of addresses, permit lists and point to classes and
374
leases that are members of this pool.
375
376
This will be a container that could be contained by dhcpSubnet or a
377
dhcpSharedNetwork.  Must: cn, dhcpRange May: dhcpClassesDN,
378
dhcpPermitList, dhcpLeasesDN, dhcpOptionsDN, dhcpStatements
379
380
The following objects can exist within a dhcpPool container: dhcpClass,
381
dhcpOptions, dhcpLease, dhcpLog
382
383
6. Tracking Address Assignments
384
385
The behavior of a DHCP server is influenced by two factors - it's
386
configuration and the current state of the addresses that have been
387
assigned to clients. This schema defines a set of objects for
388
representing the DHCP configuration associated with a server. The
389
following object classes provide the ability to record how addresses are
390
used including maintaining history (audit log) on individual leases.
391
Recording lease information in a directory could result in a significant
392
performance impact and is therefore optional. Implementations supporting
393
logging of leases need to consider the performance impact.
394
395
6.1. dhcpLeases Attribute Definitions
396
397
The schema definitions below are for readability the LDIF layout for
398
this schema will follow in section 8.
399
400
Name: dhcpAddressState Description: This stores information about the
401
current binding-status of an address.  For dynamic addresses managed by
402
DHCP, the values should be restricted to the states defined in the DHCP
403
Failover Protocol draft [FAILOVR]: 'FREE', 'ACTIVE', 'EXPIRED',
404
'RELEASED', 'RESET', 'ABANDONED', 'BACKUP'.  For more information on
405
these states see [FAILOVR].  For other addresses, it SHOULD be one of
406
the following: 'UNKNOWN', 'RESERVED' (an address that is managed by DHCP
407
that is reserved for a specific client), 'RESERVED-ACTIVE' (same as
408
reserved, but address is currently in use),  'ASSIGNED' (assigned
409
manually or by some other mechanism), 'UNASSIGNED', 'NOTASSIGNABLE'.
410
Syntax: IA5String Flags: SINGLE-VALUE
411
412
Name: dhcpExpirationTime Description: This is the time the current lease
413
for an address expires.  Syntax: DateTime Flags: SINGLE-VALUE
414
415
416
417
418
M. Meredith et al.        Expires December 2001                 [Page 7]
419
420
421
422
423
424
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
425
426
427
Name: dhcpStartTimeOfState Description: This is the time of the last
428
state change for a leased address.  Syntax: DateTime Flags: SINGLE-VALUE
429
430
Name: dhcpLastTransactionTime Description: This is the last time a valid
431
DHCP packet was received from the client.  Syntax: DateTime Flags:
432
SINGLE-VALUE
433
434
Name: dhcpBootpFlag Description: This indicates whether the address was
435
assigned via BOOTP Syntax: Boolean Flags: SINGLE-VALUE
436
437
Name: dhcpDomainName Description: This is the name of the domain sent to
438
the client by the server.  It is essentially the same as the value for
439
DHCP option 15 sent to the client, and represents only the domain - not
440
the full FQDN.  To obtain the full FQDN assigned to the client you must
441
prepend the "dhcpAssignedHostName" to this value with a ".".  Syntax:
442
IA5String Flags: SINGLE-VALUE
443
444
Name: dhcpDnsStatus Description: This indicates the status of updating
445
DNS resource records on behalf of the client by the DHCP server for this
446
address.  The value is a 16-bit bitmask that has the same values as
447
specified by the Failover-DDNS option (see [FAILOVR]).  Syntax: Integer
448
Flags: SINGLE-VALUE
449
450
Name: dhcpRequestedHostName Description: This is the hostname that was
451
requested by the client.  Syntax: IA5String Flags: SINGLE-VALUE
452
453
Name: dhcpAssignedHostName Description: This is the actual hostname that
454
was assigned to a client. It may not be the name that was requested by
455
the client.  The fully qualified domain name can be determined by
456
appending the value of "dhcpDomainName" (with a dot separator) to this
457
name.  Syntax: IA5String Flags: SINGLE-VALUE
458
459
Name: dhcpReservedForClient Description: This is the distinguished name
460
of the "dhcpHost" that an address is reserved for.  This may not be the
461
same as the "dhcpAssignedToClient" attribute if the address is being
462
reassigned but the current lease has not yet expired.  Syntax: DN Flags:
463
SINGLE-VALUE
464
465
Name: dhcpAssignedToClient Description: This is the distinguished name
466
of a "dhcpHost" that an address is currently assigned to.  This
467
attribute is only present in the class when the address is leased.
468
Syntax: DN Flags: SINGLE-VALUE
469
470
Name: dhcpRelayAgentInfo Description: If the client request was received
471
via a relay agent, this contains information about the relay agent that
472
was available from the DHCP request.  This is a hex-encoded option
473
value.  Syntax: OctetString Flags: SINGLE-VALUE
474
475
Name: dhcpErrorLog Description: Generic error log attribute that allows
476
logging error conditions within a dhcpService or a dhcpSubnet, like no IP 
477
addresses available for lease. Syntax: IA5String 
478
479
M. Meredith et al.        Expires December 2001                 [Page 8]
480
481
482
483
484
485
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
486
487
488
6.2.  dhcpLeases Object Class
489
490
This class represents an IP address.  It may or may not be leaseable,
491
and the object may exist even though a lease is not currently active for
492
the associated IP address.
493
494
It is recommended that all Lease objects for a single DHCP Service be
495
centrally located within a single container. This ensures that the lease
496
objects and the corresponding logs do not have to be relocated, when
497
address ranges allocated to individual DHCP subnets and/or pools change.
498
499
The schema definitions below are for readability the LDIF layout for
500
this schema will follow in section 8.
501
502
Name: dhcpLeases Description: This is the object that holds state
503
information about an IP address. The cn (which is the IP address), and
504
the current address-state are mandatory attributes. If the address is
505
assigned then, some of the optional attributes will have valid data.
506
Must: cn, dhcpAddressState May: dhcpExpirationTime,
507
dhcpStartTimeOfState, dhcpLastTransactionTime, dhcpBootpFlag,
508
dhcpDomainName, dhcpDnsStatus, dhcpRequestedHostName,
509
dhcpAssignedHostName, dhcpReservedForClient, dhcpAssignedToClient,
510
dhcpRelayAgentInfo, dhcpHWAddress
511
512
6.3 Audit Log Information
513
514
A dhcpLog object is created whenever a lease is assigned or released.
515
This object is intended to be created under the corresponding dhcpLeases
516
container, or dhcpPool, dhcpSubnet, dhcpSharedNetwork or dhcpService
517
containers.
518
519
The log information under the dhcpLeases container would be for
520
addresses matching that lease information. The log information in the
521
other containers could be used for errors, i.e. when a pool or subnet is
522
out our addresses or if a server is not able to assign any more
523
addresses for a particular dhcpService.
524
525
Name: dhcpLog Description: This is the object that holds past
526
information about an IP address. The cn is the time/date stamp when the
527
address was assigned or released, the address state at the time, if the
528
address was assigned or released.  Must: cn May: dhcpAddressState,
529
dhcpExpirationTime, dhcpStartTimeOfState, dhcpLastTransactionTime,
530
dhcpBootpFlag, dhcpDomainName, dhcpDnsStatus, dhcpRequestedHostName,
531
dhcpAssignedHostName, dhcpReservedForClient, dhcpAssignedToClient,
532
dhcpRelayAgentInfo, dhcpHWAddress, dhcpErrorLog
533
534
535
536
537
538
539
M. Meredith et al.        Expires December 2001                 [Page 9]
540
541
542
543
544
545
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
546
547
548
7. Determining settings
549
550
The dhcpStatements attribute is the key to DHC enhancements that may
551
come along, and the different key words that a particular server
552
implementation may use. This attribute can be used to hold conditional
553
DHCP Statements and DHCP server parameters. Having a generic settings
554
attribute that is just a string, allows this schema to be extensible and
555
easy to configure.
556
557
All of the attributes that end with DN are references to the class that
558
precedes the DN e.g. the dhcpPrimaryDN and dhcpSecondaryDN attributes
559
hold the Distinguished Names of the dhcpServer objects that are
560
associated with the dhcpService object.
561
562
8. LDIF format for attributes and classes.
563
564
# Attributes
565
566
( 2.16.840.1.113719.1.203.4.1 NAME 'dhcpPrimaryDN' DESC
567
'The DN of the dhcpServer which is the primary server for the
568
configuration.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
569
570
( 2.16.840.1.113719.1.203.4.2 NAME 'dhcpSecondaryDN' DESC 'The DN of
571
dhcpServer(s) which provide backup service for the configuration.'
572
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
573
574
( 2.16.840.1.113719.1.203.4.3 NAME 'dhcpStatements' DESC 'Flexible
575
storage for specific data depending on what object this exists in. Like
576
conditional statements, server parameters, etc. This allows the standard
577
to evolve without needing to adjust the schema.' SYNTAX
578
1.3.6.1.4.1.1466.115.121.1.26 )
579
580
( 2.16.840.1.113719.1.203.4.4 NAME 'dhcpRange' DESC 'The starting &
581
ending IP Addresses in the range (inclusive), separated by a hyphen; if
582
the range only contains one address, then just the address can be
583
specified with no hyphen.  Each range is defined as a separate value.'
584
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
585
586
( 2.16.840.1.113719.1.203.4.5 NAME 'dhcpPermitList' DESC 'This attribute
587
contains the permit lists associated with a pool. Each permit list is
588
defined as a separate value.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
589
590
( 2.16.840.1.113719.1.203.4.6 NAME 'dhcpNetMask' DESC 'The subnet mask
591
length for the subnet.  The mask can be easily computed from this
592
length.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
593
594
( 2.16.840.1.113719.1.203.4.7 NAME 'dhcpOption' DESC 'Encoded option
595
values to be sent to clients.  Each value represents a single option and
596
contains (OptionTag, Length, OptionValue) encoded in the format used by
597
DHCP.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )
598
599
M. Meredith et al.        Expires December 2001                [Page 10]
600
601
602
603
604
605
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
606
607
608
( 2.16.840.1.113719.1.203.4.8 NAME 'dhcpClassData' DESC 'Encoded text
609
string or list of bytes expressed in hexadecimal, separated by colons.
610
Clients match subclasses based on matching the class data with the
611
results of match or spawn with statements in the class name
612
declarations.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
613
614
( 2.16.840.1.113719.1.203.4.9 NAME 'dhcpOptionsDN' DESC 'The
615
distinguished name(s) of the dhcpOption objects containing the
616
configuration options provided by the server.' SYNTAX
617
1.3.6.1.4.1.1466.115.121.1.12 )
618
619
( 2.16.840.1.113719.1.203.4.10 NAME 'dhcpHostDN' DESC 'the distinguished
620
name(s) of the dhcpHost objects.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
621
622
( 2.16.840.1.113719.1.203.4.11 NAME 'dhcpPoolDN' DESC 'The distinguished
623
name(s) of pools.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )
624
625
( 2.16.840.1.113719.1.203.4.12 NAME 'dhcpGroupDN' DESC 'The
626
distinguished name(s)   of the groups.' SYNTAX
627
1.3.6.1.4.1.1466.115.121.1.12 )
628
629
( 2.16.840.1.113719.1.203.4.13 NAME 'dhcpSubnetDN' DESC 'The
630
distinguished name(s) of the subnets.' SYNTAX
631
1.3.6.1.4.1.1466.115.121.1.12 )
632
633
( 2.16.840.1.113719.1.203.4.14 NAME 'dhcpLeaseDN' DESC 'The
634
distinguished name of a client address.' SYNTAX
635
1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE)
636
637
( 2.16.840.1.113719.1.203.4.15 NAME 'dhcpLeasesDN' DESC 'The
638
distinguished name(s) client addresses.' SYNTAX
639
1.3.6.1.4.1.1466.115.121.1.12 )
640
641
( 2.16.840.1.113719.1.203.4.16 NAME 'dhcpClassesDN' DESC 'The
642
distinguished name(s) of a class(es) in a subclass.' SYNTAX
643
1.3.6.1.4.1.1466.115.121.1.12 )
644
645
( 2.16.840.1.113719.1.203.4.17 NAME 'dhcpSubclassesDN' DESC 'The
646
distinguished name(s) of subclass(es).' SYNTAX
647
1.3.6.1.4.1.1466.115.121.1.12 )
648
649
( 2.16.840.1.113719.1.203.4.18 NAME 'dhcpSharedNetworkDN' DESC 'The
650
distinguished name(s) of sharedNetworks.' SYNTAX
651
1.3.6.1.4.1.1466.115.121.1.12 )
652
653
( 2.16.840.1.113719.1.203.4.19 NAME 'dhcpServiceDN' DESC 'The DN of
654
dhcpService object(s)which contain the configuration information. Each
655
dhcpServer object has this attribute identifying the DHCP
656
657
658
659
M. Meredith et al.        Expires December 2001                [Page 11]
660
661
662
663
664
665
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
666
667
668
configuration(s) that the server is associated with.' SYNTAX
669
1.3.6.1.4.1.1466.115.121.1.12 )
670
671
( 2.16.840.1.113719.1.203.4.20 NAME 'dhcpVersion' DESC 'The version
672
attribute of this object.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-
673
VALUE )
674
675
( 2.16.840.1.113719.1.203.4.21 NAME 'dhcpImplementation' DESC
676
'Description of the DHCP Server implementation e.g. DHCP Server's
677
vendor.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
678
679
( 2.16.840.1.113719.1.203.4.22 NAME 'dhcpAddressState' DESC 'This stores
680
information about the current binding-status of an address.  For dynamic
681
addresses managed by DHCP, the values should be restricted to the
682
following: "FREE", "ACTIVE", "EXPIRED", "RELEASED", "RESET",
683
"ABANDONED", "BACKUP".  For other addresses, it SHOULD be one of the
684
following: "UNKNOWN", "RESERVED" (an address that is managed by DHCP
685
that is reserved for a specific client), "RESERVED-ACTIVE" (same as
686
reserved, but address is currently in use), "ASSIGNED" (assigned
687
manually or by some other mechanism), "UNASSIGNED", "NOTASSIGNABLE".'
688
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
689
690
( 2.16.840.1.113719.1.203.4.23 NAME 'dhcpExpirationTime' DESC 'This is
691
the time the current lease for an address expires.' SYNTAX
692
1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
693
694
( 2.16.840.1.113719.1.203.4.24 NAME 'dhcpStartTimeOfState' DESC 'This is
695
the time of the last state change for a leased address.' SYNTAX
696
1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
697
698
( 2.16.840.1.113719.1.203.4.25 NAME 'dhcpLastTransactionTime' DESC 'This
699
is the last time a valid DHCP packet was received from the client.'
700
SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )
701
702
( 2.16.840.1.113719.1.203.4.26 NAME 'dhcpBootpFlag' DESC 'This indicates
703
whether the address was assigned via BOOTP.' SYNTAX
704
1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )
705
706
( 2.16.840.1.113719.1.203.4.27 NAME 'dhcpDomainName' DESC 'This is the
707
name of the domain sent to the client by the server.  It is essentially
708
the same as the value for DHCP option 15 sent to the client, and
709
represents only the domain - not the full FQDN.  To obtain the full FQDN
710
assigned to the client you must prepend the "dhcpAssignedHostName" to
711
this value with a ".".' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-
712
VALUE )
713
714
( 2.16.840.1.113719.1.203.4.28 NAME 'dhcpDnsStatus' DESC 'This indicates
715
the status of updating DNS resource records on behalf of the client by
716
717
718
719
M. Meredith et al.        Expires December 2001                [Page 12]
720
721
722
723
724
725
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
726
727
728
the DHCP server for this address.  The value is a 16-bit bitmask.'
729
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
730
731
( 2.16.840.1.113719.1.203.4.29 NAME 'dhcpRequestedHostName' DESC 'This
732
is the hostname that was requested by the client.' SYNTAX
733
1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
734
735
( 2.16.840.1.113719.1.203.4.30 NAME 'dhcpAssignedHostName' DESC 'This is
736
the actual hostname that was assigned to a client. It may not be the
737
name that was requested by the client.  The fully qualified domain name
738
can be determined by appending the value of "dhcpDomainName" (with a dot
739
separator) to this name.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-
740
VALUE )
741
742
( 2.16.840.1.113719.1.203.4.31 NAME 'dhcpReservedForClient' DESC 'The
743
distinguished name of a "dhcpClient" that an address is reserved for.
744
This may not be the same as the "dhcpAssignedToClient" attribute if the
745
address is being reassigned but the current lease has not yet expired.'
746
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
747
748
( 2.16.840.1.113719.1.203.4.32 NAME 'dhcpAssignedToClient' DESC 'This is
749
the distinguished name of a "dhcpClient" that an address is currently
750
assigned to.  This attribute is only present in the class when the
751
address is leased.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
752
753
( 2.16.840.1.113719.1.203.4.33 NAME 'dhcpRelayAgentInfo' DESC 'If the
754
client request was received via a relay agent, this contains information
755
about the relay agent that was available from the DHCP request.  This is
756
a hex-encoded option value.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.40
757
SINGLE-VALUE )
758
759
( 2.16.840.1.113719.1.203.4.34 NAME 'dhcpHWAddress' DESC 'The clients
760
hardware address that requested this IP address.' SYNTAX
761
1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
762
763
( 2.16.840.1.113719.1.203.4.35 NAME 'dhcpHashBucketAssignment' DESC
764
'HashBucketAssignment bit map for the DHCP Server, as defined in DHC
765
Load Balancing Algorithm [RFC 3074].' SYNTAX
766
1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE )
767
768
( 2.16.840.1.113719.1.203.4.36 NAME 'dhcpDelayedServiceParameter' DESC
769
'Delay in seconds corresponding to Delayed Service Parameter
770
configuration, as defined in  DHC Load Balancing Algorithm [RFC 3074]. '
771
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
772
773
( 2.16.840.1.113719.1.203.4.37 NAME 'dhcpMaxClientLeadTime' DESC
774
'Maximum Client Lead Time configuration in seconds, as defined in DHCP
775
Failover Protocol [FAILOVR]' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
776
777
778
779
M. Meredith et al.        Expires December 2001                [Page 13]
780
781
782
783
784
785
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
786
787
788
SINGLE-VALUE )
789
790
( 2.16.840.1.113719.1.203.4.38 NAME 'dhcpFailOverEndpointState' DESC
791
'Server (Failover Endpoint) state, as defined in DHCP Failover Protocol
792
[FAILOVR]' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
793
794
( 2.16.840.1.113719.1.203.4.39 NAME 'dhcpErrorLog' DESC
795
Generic error log attribute that allows logging error conditions within a 
796
dhcpService or a dhcpSubnet, like no IP addresses available for lease. 
797
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
798
799
#Classes
800
801
( 2.16.840.1.113719.1.203.6.1 NAME 'dhcpService' DESC ' Service object
802
that represents the actual DHCP Service configuration. This is a
803
container object.' SUP top MUST (cn $ dhcpPrimaryDN) MAY
804
(dhcpSecondaryDN $ dhcpSharedNetworkDN $ dhcpSubnetDN $ dhcpGroupDN $
805
dhcpHostDN $  dhcpClassesDN $ dhcpOptionsDN $ dhcpStatements ) )
806
807
( 2.16.840.1.113719.1.203.6.2 NAME 'dhcpSharedNetwork' DESC 'This stores
808
configuration information for a shared network.' SUP top MUST  cn MAY
809
(dhcpSubnetDN $ dhcpPoolDN $ dhcpOptionsDN $ dhcpStatements) X-
810
NDS_CONTAINMENT ('dhcpService' ) )
811
812
( 2.16.840.1.113719.1.203.6.3 NAME 'dhcpSubnet' DESC 'This class defines
813
a subnet. This is a container object.' SUP top MUST ( cn $ dhcpNetMask )
814
MAY (dhcpRange $ dhcpPoolDN $ dhcpGroupDN $ dhcpHostDN $ dhcpClassesDN $
815
dhcpLeasesDN $ dhcpOptionsDN $ dhcpStatements) X-NDS_CONTAINMENT
816
('dhcpService' 'dhcpSharedNetwork') )
817
818
( 2.16.840.1.113719.1.203.6.4 NAME 'dhcpPool' DESC 'This stores
819
configuration information about a pool.' SUP top MUST ( cn $ dhcpRange )
820
MAY (dhcpClassesDN $ dhcpPermitList $ dhcpLeasesDN $ dhcpOptionsDN $
821
dhcpStatements) X-NDS_CONTAINMENT ('dhcpSubnet' 'dhcpSharedNetwork') )
822
823
( 2.16.840.1.113719.1.203.6.5 NAME 'dhcpGroup' DESC 'Group object that
824
lists host DNs and parameters. This is a container object.' SUP top MUST
825
cn MAY ( dhcpHostDN $ dhcpOptionsDN $ dhcpStatements ) X-NDS_CONTAINMENT
826
('dhcpSubnet' 'dhcpService' ) )
827
828
( 2.16.840.1.113719.1.203.6.6 NAME 'dhcpHost' DESC 'This represents
829
information about a particular client' SUP top MUST cn MAY  (dhcpLeaseDN
830
$ dhcpHWAddress $ dhcpOptionsDN $ dhcpStatements) X-NDS_CONTAINMENT
831
('dhcpService' 'dhcpSubnet' 'dhcpGroup') )
832
833
( 2.16.840.1.113719.1.203.6.7 NAME 'dhcpClass' DESC 'Represents
834
information about a collection of related clients.' SUP top MUST cn MAY
835
(dhcpSubClassesDN $ dhcpOptionsDN $ dhcpStatements) X-NDS_CONTAINMENT
836
('dhcpService' 'dhcpSubnet' ) )
837
838
( 2.16.840.1.113719.1.203.6.8 NAME 'dhcpSubClass' DESC 'Represents
839
information about a collection of related classes.' SUP top MUST cn MAY
840
(dhcpClassData $ dhcpOptionsDN $ dhcpStatements) X-NDS_CONTAINMENT
841
842
843
844
M. Meredith et al.        Expires December 2001                [Page 14]
845
846
847
848
849
850
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
851
852
853
'dhcpClass' )
854
855
( 2.16.840.1.113719.1.203.6.9 NAME 'dhcpOptions' DESC 'Represents
856
information about a collection of options defined.' SUP top MUST cn MAY
857
( dhcpOption ) X-NDS_CONTAINMENT  ('dhcpService' 'dhcpSharedNetwork'
858
'dhcpSubnet' 'dhcpPool' 'dhcpGroup' 'dhcpHost' 'dhcpClass' )
859
860
( 2.16.840.1.113719.1.203.6.10 NAME 'dhcpLeases' DESC 'This class
861
represents an IP Address, which may or may not have been leased.' SUP
862
top MUST ( cn $ dhcpAddressState ) MAY ( dhcpExpirationTime $
863
dhcpStartTimeOfState $ dhcpLastTransactionTime $ dhcpBootpFlag $
864
dhcpDomainName $ dhcpDnsStatus $ dhcpRequestedHostName $
865
dhcpAssignedHostName $ dhcpReservedForClient $ dhcpAssignedToClient $
866
dhcpRelayAgentInfo $ dhcpHWAddress ) X-NDS_CONTAINMENT ( 'dhcpService'
867
'dhcpSubnet' 'dhcpPool') )
868
869
( 2.16.840.1.113719.1.203.6.11 NAME 'dhcpLog' DESC 'This is the object
870
that holds past information about the IP address. The cn is the
871
time/date stamp when the address was assigned or released, the address
872
state at the time, if the address was assigned or released.' SUP top
873
MUST ( cn ) MAY ( dhcpAddressState $ dhcpExpirationTime $
874
dhcpStartTimeOfState $ dhcpLastTransactionTime $ dhcpBootpFlag $
875
dhcpDomainName $ dhcpDnsStatus $ dhcpRequestedHostName $
876
dhcpAssignedHostName $ dhcpReservedForClient $ dhcpAssignedToClient $
877
dhcpRelayAgentInfo $ dhcpHWAddress $ dhcpErrorLog) X-NDS_CONTAINMENT 
878
('dhcpLeases' 'dhcpPool' 'dhcpSubnet' 'dhcpSharedNetwork' 'dhcpService' ) )
879
880
( 2.16.840.1.113719.1.203.6.12 NAME 'dhcpServer' DESC 'DHCP Server
881
Object' SUP top MUST (cn, dhcpServiceDN) MAY (dhcpVersion $
882
dhcpImplementation $ dhcpHashBucketAssignment $
883
dhcpDelayedServiceParameter $ dhcpMaxClientLeadTime $
884
dhcpFailOverEndpointState $ dhcpStatements) X-NDS_CONTAINMENT ('O' 'OU' 
885
'dc') )
886
887
9. Security Considerations
888
889
Since the DHCP Configuration information is stored in a directory, the
890
security of the information is limited to the security offered by the
891
directory including the security of the objects within that directory.
892
893
10.  Intellectual Property Rights Notices
894
895
The IETF takes no position regarding the validity or scope of any
896
intellectual property or other rights that might be claimed to pertain
897
to the implementation or use of the technology described in this
898
document or the extent to which any license under such rights might or
899
might not be available; neither does it represent that it has made any
900
effort to identify any such rights.  Information on the IETF's
901
procedures with respect to rights in standards-track and standards-
902
903
904
905
M. Meredith et al.        Expires December 2001                [Page 15]
906
907
908
909
910
911
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
912
913
914
related documentation can be found in BCP-11.  Copies of claims of
915
rights made available for publication and any assurances of licenses to
916
be made available, or the result of an attempt made to obtain a general
917
license or permission for the use of such proprietary rights by
918
implementors or users of this specification can be obtained from the
919
IETF Secretariat.
920
921
The IETF invites any interested party to bring to its attention any
922
copyrights, patents or patent applications, or other proprietary rights
923
which may cover technology that may be required to practice this
924
standard.  Please address the information to the IETF Executive
925
Director.
926
927
11.  Full Copyright Statement
928
929
Copyright (C) The Internet Society (2001).  All Rights Reserved.
930
931
This document and translations of it may be copied and furnished to
932
others, and derivative works that comment on or otherwise explain it or
933
assist in its implementation may be prepared, copied, published and
934
distributed, in whole or in part, without restriction of any kind,
935
provided that the above copyright notice and this paragraph are included
936
on all such copies and derivative works.  However, this document itself
937
may not be modified in any way, such as by removing the copyright notice
938
or references to the Internet Society or other Internet organizations,
939
except as needed for the purpose of developing Internet standards in
940
which case the procedures for copyrights defined in the Internet
941
Standards process must be followed, or as required to translate it into
942
languages other than English.
943
944
The limited permissions granted above are perpetual and will not be
945
revoked by the Internet Society or its successors or assigns.
946
947
This document and the information contained herein is provided on an "AS
948
IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK
949
FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
950
LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT
951
INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR
952
FITNESS FOR A PARTICULAR PURPOSE.
953
954
12. References
955
956
[RFC2131] Droms, R., "Dynamic Host Configuration Protocol", RFC 2131,
957
March 1997.
958
959
[RFC2132] Alexander, S., Droms, R., "DHCP Options and BOOTP Vendor
960
Extensions", RFC 2132, March 1997.
961
962
963
964
965
M. Meredith et al.        Expires December 2001                [Page 16]
966
967
968
969
970
971
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
972
973
974
[MSDHCP]  Gu, Y., Vyaghrapuri, R., "An LDAP Schema for Dynamic Host
975
Configuration Protocol Service", Internet Draft <draft-gu-dhcp-ldap-
976
schema-00.txt>, August 1998.
977
978
[NOVDHCP] Miller, T., Patel, A., Rao, P., "Lightweight Directory Access
979
Protocol (v3): Schema for Dynamic Host Configuration Protocol (DHCP)",
980
Internet Draft <draft-miller-dhcp-ldap-schema-00.txt>, June 1998.
981
982
[FAILOVR] Droms, R., Rabil, G., Dooley, M., Kapur, A., Gonczi, S., Volz,
983
B., "DHCP Failover Protocol", Internet Draft <draft-ietf-dhc-
984
failover-08.txt>, July 2000.
985
986
[RFC 3074] Volz B., Gonczi S., Lemon T., Stevens R., "DHC Load Balancing
987
Algorithm", February 2001
988
989
[AGENT]   Patrick, M., "DHCP Relay Agent Information Option", Internet
990
Draft <draft-ietf-dhc-agent-options-09.txt>, March 2000.
991
992
[DHCPOPT] Carney, M., "New Option Review Guidelines and Additional
993
Option Namespace", Internet Draft <draft-ietf-dhc-
994
option_review_and_namespace-01.txt>, October 1999.
995
996
[POLICY]  Strassner, J., Elleson, E., Moore, B., "Policy Framework LDAP
997
Core Schema", Internet Draft <draft-ietf-policy-core-schema-06.txt>,
998
November 1999.
999
1000
[RFC2251] Wahl, M., Howes, T., Kille, S., "Lightweight Directory Access
1001
Protocol (v3)", RFC 2251, December 1997.
1002
1003
[RFC2252] Wahl, M., Coulbeck, A., Howes, T., Kille, S., "Lightweight
1004
Directory Access Protocol (v3) Attribute Syntax Definitions", RFC 2252,
1005
December 1997.
1006
1007
[RFC2255] Howes, T., Smith, M., "The LDAP URL Format", RFC 2255,
1008
December 1997.
1009
1010
[RFC951]  Croft, B., Gilmore, J., "Bootstrap Protocol (BOOTP)", RFC 951,
1011
September 1985.
1012
1013
[RFC2119] Bradner, S. "Key words for use in RFCs to Indicate Requirement
1014
Levels", RFC 2119, March 1997.
1015
1016
13. Acknowledgments
1017
1018
This work is partially based on a previous draft draft-ietf-dhc-
1019
schema-02.doc.
1020
1021
1022
1023
1024
1025
M. Meredith et al.        Expires December 2001                [Page 17]
1026
1027
1028
1029
1030
1031
INTERNET-DRAFT            LDAP Schema for DHCP              16 June 2001
1032
1033
1034
14. Author's Addresses
1035
1036
Comments regarding this draft may be sent to the authors at the
1037
following address:
1038
1039
Mark Meredith
1040
Mark Hinckley
1041
Novell Inc.
1042
1800 S. Novell Place
1043
Provo, Utah 84606
1044
1045
Vijay K. Nanjundaswamy
1046
Novell Software Development (I) Ltd
1047
49/1 & 49/3, Garvebhavi Palya,
1048
7th Mile, Hosur Road
1049
Bangalore 560068
1050
1051
email: mark_meredith@novell.com
1052
email: knvijay@novell.com
1053
email: mhinckley@novell.com
1054
1055
This Internet Draft expires December 16, 2001.
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
M. Meredith et al.        Expires December 2001                [Page 18]
1086
1087
1088
1089
(-)dhcp-3.0.5/dst/Makefile.dist (-2 / +8 lines)
Lines 23-34 Link Here
23
23
24
SRC    = dst_support.c dst_api.c hmac_link.c md5_dgst.c base64.c prandom.c
24
SRC    = dst_support.c dst_api.c hmac_link.c md5_dgst.c base64.c prandom.c
25
OBJ    = dst_support.o dst_api.o hmac_link.o md5_dgst.o base64.o prandom.o
25
OBJ    = dst_support.o dst_api.o hmac_link.o md5_dgst.o base64.o prandom.o
26
OBJ_NM5= dst_support.o dst_api.o hmac_link.o base64.o prandom.o
26
HDRS   = dst_internal.h md5.h md5_locl.h
27
HDRS   = dst_internal.h md5.h md5_locl.h
27
28
28
INCLUDES = $(BINDINC) -I$(TOP)/includes
29
INCLUDES = $(BINDINC) -I$(TOP)/includes
29
CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUDES) $(COPTS) -DHMAC_MD5 -DMINIRES_LIB
30
CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUDES) $(COPTS) -DHMAC_MD5 -DMINIRES_LIB
30
31
31
all:	libdst.a
32
all:	libdst.a libdst-nomd5.a
32
33
33
install:
34
install:
34
35
Lines 37-47 Link Here
37
	ar cruv libdst.a $(OBJ)
38
	ar cruv libdst.a $(OBJ)
38
	$(RANLIB) libdst.a
39
	$(RANLIB) libdst.a
39
40
41
libdst-nomd5.a:	$(OBJ_NM5)
42
	rm -f libdst-nomd5.a
43
	ar cruv libdst-nomd5.a $(OBJ_NM5)
44
	$(RANLIB) libdst-nomd5.a
45
40
depend:
46
depend:
41
	$(MKDEP) $(INCLUDES) $(PREDEFINES) $(SRC)
47
	$(MKDEP) $(INCLUDES) $(PREDEFINES) $(SRC)
42
48
43
clean:
49
clean:
44
	-rm -f $(OBJ) libdst.a
50
	-rm -f $(OBJ) libdst.a libdst-nomd5.a
45
51
46
realclean: clean
52
realclean: clean
47
	-rm -f *~ $(CATMANPAGES) $(SEDMANPAGES)
53
	-rm -f *~ $(CATMANPAGES) $(SEDMANPAGES)
(-)dhcp-3.0.5/includes/dhcpd.h (-1 / +73 lines)
Lines 79-84 Link Here
79
#include <isc-dhcp/result.h>
79
#include <isc-dhcp/result.h>
80
#include <omapip/omapip_p.h>
80
#include <omapip/omapip_p.h>
81
81
82
#if defined(LDAP_CONFIGURATION)
83
# include <ldap.h>
84
# include <sys/utsname.h> /* for uname() */
85
#endif
86
82
#if !defined (OPTION_HASH_SIZE)
87
#if !defined (OPTION_HASH_SIZE)
83
# define OPTION_HASH_SIZE 17
88
# define OPTION_HASH_SIZE 17
84
# define OPTION_HASH_PTWO 32	/* Next power of two above option hash. */
89
# define OPTION_HASH_PTWO 32	/* Next power of two above option hash. */
Lines 139-144 Link Here
139
	char *inbuf;
144
	char *inbuf;
140
	unsigned bufix, buflen;
145
	unsigned bufix, buflen;
141
	unsigned bufsiz;
146
	unsigned bufsiz;
147
148
	int (*read_function) (struct parse *);
142
};
149
};
143
150
144
/* Variable-length array of data. */
151
/* Variable-length array of data. */
Lines 244-249 Link Here
244
	u_int8_t hbuf [17];
251
	u_int8_t hbuf [17];
245
};
252
};
246
253
254
#if defined(LDAP_CONFIGURATION)
255
# define LDAP_BUFFER_SIZE		8192
256
# define LDAP_METHOD_STATIC		0
257
# define LDAP_METHOD_DYNAMIC		1
258
#if defined (USE_SSL)
259
# define LDAP_SSL_OFF			0
260
# define LDAP_SSL_ON			1
261
# define LDAP_SSL_TLS			2
262
# define LDAP_SSL_LDAPS			3
263
#endif
264
265
/* This is a tree of the current configuration we are building from LDAP */
266
267
struct ldap_config_stack {
268
	LDAPMessage * res; 	/* Pointer returned from ldap_search */
269
	LDAPMessage * ldent; 	/* Current item in LDAP that we're processing 
270
				   in res */
271
	int close_brace;	/* Put a closing } after we're through with
272
				   this item */
273
	int processed; 		/* We set this flag if this base item has been
274
				   processed. After this base item is processed,
275
				   we can start processing the children */
276
	struct ldap_config_stack *next;
277
};
278
#endif
279
247
typedef enum {
280
typedef enum {
248
	server_startup = 0,
281
	server_startup = 0,
249
	server_running = 1,
282
	server_running = 1,
Lines 426-431 Link Here
426
# define DEFAULT_PING_TIMEOUT 1
459
# define DEFAULT_PING_TIMEOUT 1
427
#endif
460
#endif
428
461
462
#if defined(LDAP_CONFIGURATION)
463
# define SV_LDAP_SERVER  		47
464
# define SV_LDAP_PORT  			48
465
# define SV_LDAP_USERNAME  		49
466
# define SV_LDAP_PASSWORD  		50
467
# define SV_LDAP_BASE_DN 		51
468
# define SV_LDAP_METHOD			52
469
# define SV_LDAP_DEBUG_FILE		53
470
# define SV_LDAP_DHCP_SERVER_CN		54
471
# define SV_LDAP_REFERRALS              55
472
#if defined (USE_SSL)
473
# define SV_LDAP_SSL			56
474
# define SV_LDAP_TLS_REQCERT		57
475
# define SV_LDAP_TLS_CA_FILE		58
476
# define SV_LDAP_TLS_CA_DIR		59
477
# define SV_LDAP_TLS_CERT		60
478
# define SV_LDAP_TLS_KEY		61
479
# define SV_LDAP_TLS_CRLCHECK		62
480
# define SV_LDAP_TLS_CIPHERS		63
481
# define SV_LDAP_TLS_RANDFILE		64
482
#endif
483
#endif
484
429
#if !defined (DEFAULT_DEFAULT_LEASE_TIME)
485
#if !defined (DEFAULT_DEFAULT_LEASE_TIME)
430
# define DEFAULT_DEFAULT_LEASE_TIME 43200
486
# define DEFAULT_DEFAULT_LEASE_TIME 43200
431
#endif
487
#endif
Lines 1531-1537 Link Here
1531
char *quotify_string (const char *, const char *, int);
1587
char *quotify_string (const char *, const char *, int);
1532
char *quotify_buf (const unsigned char *, unsigned, const char *, int);
1588
char *quotify_buf (const unsigned char *, unsigned, const char *, int);
1533
char *print_base64 (const unsigned char *, unsigned, const char *, int);
1589
char *print_base64 (const unsigned char *, unsigned, const char *, int);
1534
char *print_hw_addr PROTO ((int, int, unsigned char *));
1590
char *print_hw_addr PROTO ((const int, const int, const unsigned char *));
1535
void print_lease PROTO ((struct lease *));
1591
void print_lease PROTO ((struct lease *));
1536
void dump_raw PROTO ((const unsigned char *, unsigned));
1592
void dump_raw PROTO ((const unsigned char *, unsigned));
1537
void dump_packet_option (struct option_cache *, struct packet *,
1593
void dump_packet_option (struct option_cache *, struct packet *,
Lines 2632-2634 Link Here
2632
#endif /* FAILOVER_PROTOCOL */
2688
#endif /* FAILOVER_PROTOCOL */
2633
2689
2634
const char *binding_state_print (enum failover_state);
2690
const char *binding_state_print (enum failover_state);
2691
2692
/* ldap.c */
2693
#if defined(LDAP_CONFIGURATION)
2694
extern struct enumeration ldap_methods;
2695
#if defined (USE_SSL)
2696
extern struct enumeration ldap_ssl_usage_enum;
2697
extern struct enumeration ldap_tls_reqcert_enum;
2698
extern struct enumeration ldap_tls_crlcheck_enum;
2699
#endif
2700
isc_result_t ldap_read_config (void);
2701
int find_haddr_in_ldap (struct host_decl **, int, unsigned,
2702
                        const unsigned char *, const char *, int);
2703
int find_subclass_in_ldap (struct class *, struct class **, 
2704
			   struct data_string *);
2705
#endif
2706
(-)dhcp-3.0.5/includes/ldap_casa.h (+83 lines)
Line 0 Link Here
1
/* ldap_casa.h
2
   
3
   Definition for CASA modules... */
4
5
/* Copyright (c) 2004 Internet Systems Consorium, Inc. ("ISC")
6
 * Copyright (c) 1995-2003 Internet Software Consortium.
7
 * Copyright (c) 2006 Novell, Inc.
8
9
 * All rights reserved.
10
 * Redistribution and use in source and binary forms, with or without 
11
 * modification, are permitted provided that the following conditions are met: 
12
 * 1.Redistributions of source code must retain the above copyright notice, 
13
 *   this list of conditions and the following disclaimer. 
14
 * 2.Redistributions in binary form must reproduce the above copyright notice, 
15
 *   this list of conditions and the following disclaimer in the documentation 
16
 *   and/or other materials provided with the distribution. 
17
 * 3.Neither the name of ISC, ISC DHCP, nor the names of its contributors 
18
 *   may be used to endorse or promote products derived from this software 
19
 *   without specific prior written permission. 
20
21
 * THIS SOFTWARE IS PROVIDED BY INTERNET SYSTEMS CONSORTIUM AND CONTRIBUTORS 
22
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
24
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ISC OR CONTRIBUTORS BE LIABLE 
25
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
26
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
27
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
28
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
29
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
30
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
31
 * POSSIBILITY OF SUCH DAMAGE.
32
33
 * This file was written by S Kalyanasundaram <skalyanasundaram@novell.com>
34
 */
35
36
#if defined(LDAP_CASA_AUTH)
37
#ifndef __LDAP_CASA_H__
38
#define __LDAP_CASA_H__
39
40
#include <micasa_mgmd.h>
41
#include <dlfcn.h>
42
#include <string.h>
43
44
#define MICASA_LIB     "libmicasa.so.1"
45
46
SSCS_TYPEDEF_LIBCALL(int, CASA_GetCredential_T)
47
(
48
       uint32_t            ssFlags,
49
       SSCS_SECRET_ID_T   *appSecretID,
50
       SSCS_SECRET_ID_T   *sharedSecretID,
51
       uint32_t           *credentialType,
52
       void               *credential,
53
       SSCS_EXT_T         *ext 
54
);
55
SSCS_TYPEDEF_LIBCALL(int, CASA_SetCredential_T)
56
(
57
       uint32_t            ssFlags,
58
       SSCS_SECRET_ID_T   *appSecretID,
59
       SSCS_SECRET_ID_T   *sharedSecretID,
60
       uint32_t            credentialType,
61
       void               *credential,
62
       SSCS_EXT_T         *ext
63
);
64
65
SSCS_TYPEDEF_LIBCALL(int, CASA_RemoveCredential_T)
66
(
67
       uint32_t            ssFlags,
68
       SSCS_SECRET_ID_T   *appSecretID,
69
       SSCS_SECRET_ID_T   *sharedSecretID,
70
       SSCS_EXT_T         *ext
71
);
72
static CASA_GetCredential_T            p_miCASAGetCredential = NULL;
73
static CASA_SetCredential_T            p_miCASASetCredential = NULL;
74
static CASA_RemoveCredential_T         p_miCASARemoveCredential = NULL;
75
static void                            *casaIDK = NULL;
76
77
int load_casa(void);
78
static void release_casa(void);
79
int load_uname_pwd_from_miCASA(char **, char **);
80
81
#endif /* __LDAP_CASA_H__ */
82
#endif /* LDAP_CASA_AUTH */
83
(-)dhcp-3.0.5/includes/site.h (+10 lines)
Lines 177-179 Link Here
177
   traces. */
177
   traces. */
178
178
179
#define TRACING
179
#define TRACING
180
181
/* Define this if you want to read your config from LDAP. Read README.ldap
182
   about how to set this up */
183
184
#define LDAP_CONFIGURATION
185
186
/* Define this if you want to enable LDAP over a SSL connection. You will need
187
   to add -lcrypto -lssl to the LIBS= line of server/Makefile */
188
189
/* #define USE_SSL */
(-)dhcp-3.0.5/server/Makefile.dist (-3 / +3 lines)
Lines 25-38 Link Here
25
CATMANPAGES = dhcpd.cat8 dhcpd.conf.cat5 dhcpd.leases.cat5
25
CATMANPAGES = dhcpd.cat8 dhcpd.conf.cat5 dhcpd.leases.cat5
26
SEDMANPAGES = dhcpd.man8 dhcpd.conf.man5 dhcpd.leases.man5
26
SEDMANPAGES = dhcpd.man8 dhcpd.conf.man5 dhcpd.leases.man5
27
SRCS   = dhcpd.c dhcp.c bootp.c confpars.c db.c class.c failover.c \
27
SRCS   = dhcpd.c dhcp.c bootp.c confpars.c db.c class.c failover.c \
28
	 omapi.c mdb.c stables.c salloc.c ddns.c
28
	 ldap.c ldap_casa.c omapi.c mdb.c stables.c salloc.c ddns.c
29
OBJS   = dhcpd.o dhcp.o bootp.o confpars.o db.o class.o failover.o \
29
OBJS   = dhcpd.o dhcp.o bootp.o confpars.o db.o class.o failover.o \
30
	 omapi.o mdb.o stables.o salloc.o ddns.o
30
	 ldap.o ldap_casa.o omapi.o mdb.o stables.o salloc.o ddns.o
31
PROG   = dhcpd
31
PROG   = dhcpd
32
MAN    = dhcpd.8 dhcpd.conf.5 dhcpd.leases.5
32
MAN    = dhcpd.8 dhcpd.conf.5 dhcpd.leases.5
33
33
34
INCLUDES = -I$(TOP) $(BINDINC) -I$(TOP)/includes
34
INCLUDES = -I$(TOP) $(BINDINC) -I$(TOP)/includes
35
DHCPLIB = ../common/libdhcp.a $(BINDLIB) ../omapip/libomapi.a ../dst/libdst.a
35
DHCPLIB = ../common/libdhcp.a $(BINDLIB) ../omapip/libomapi.a ../dst/libdst-nomd5.a -lssl -lcrypto -lldap -llber
36
CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUDES) $(COPTS)
36
CFLAGS = $(DEBUG) $(PREDEFINES) $(INCLUDES) $(COPTS)
37
37
38
all:	$(PROG) $(CATMANPAGES)
38
all:	$(PROG) $(CATMANPAGES)
(-)dhcp-3.0.5/server/class.c (-3 / +14 lines)
Lines 90-95 Link Here
90
	int matched = 0;
90
	int matched = 0;
91
	int status;
91
	int status;
92
	int ignorep;
92
	int ignorep;
93
	int classfound;
93
94
94
	for (class = collection -> classes; class; class = class -> nic) {
95
	for (class = collection -> classes; class; class = class -> nic) {
95
#if defined (DEBUG_CLASS_MATCHING)
96
#if defined (DEBUG_CLASS_MATCHING)
Lines 135-143 Link Here
135
				   class -> submatch, MDL));
136
				   class -> submatch, MDL));
136
			if (status && data.len) {
137
			if (status && data.len) {
137
				nc = (struct class *)0;
138
				nc = (struct class *)0;
138
				if (class_hash_lookup (&nc, class -> hash,
139
                                classfound = class_hash_lookup (&nc, 
139
						       (const char *)data.data,
140
						class -> hash, 
140
						       data.len, MDL)) {
141
						(const char *)data.data,
142
						data.len, MDL);
143
144
#ifdef LDAP_CONFIGURATION
145
                                if (!classfound && 
146
						find_subclass_in_ldap (class, 
147
								&nc, &data)) 
148
					classfound = 1;
149
#endif
150
151
				if (classfound) {
141
#if defined (DEBUG_CLASS_MATCHING)
152
#if defined (DEBUG_CLASS_MATCHING)
142
					log_info ("matches subclass %s.",
153
					log_info ("matches subclass %s.",
143
					      print_hex_1 (data.len,
154
					      print_hex_1 (data.len,
(-)dhcp-3.0.5/server/confpars.c (-1 / +11 lines)
Lines 63-69 Link Here
63
63
64
isc_result_t readconf ()
64
isc_result_t readconf ()
65
{
65
{
66
	return read_conf_file (path_dhcpd_conf, root_group, ROOT_GROUP, 0);
66
	isc_result_t res;
67
68
	res = read_conf_file (path_dhcpd_conf, root_group, ROOT_GROUP, 0);
69
#if defined(LDAP_CONFIGURATION)
70
	if (res != ISC_R_SUCCESS)
71
		return (res);
72
73
	return ldap_read_config ();
74
#else
75
	return (res);
76
#endif
67
}
77
}
68
78
69
isc_result_t read_conf_file (const char *filename, struct group *group,
79
isc_result_t read_conf_file (const char *filename, struct group *group,
(-)dhcp-3.0.5/server/dhcpd.c (+8 lines)
Lines 436-441 Link Here
436
	/* Add the ddns update style enumeration prior to parsing. */
436
	/* Add the ddns update style enumeration prior to parsing. */
437
	add_enumeration (&ddns_styles);
437
	add_enumeration (&ddns_styles);
438
	add_enumeration (&syslog_enum);
438
	add_enumeration (&syslog_enum);
439
#if defined (LDAP_CONFIGURATION)
440
	add_enumeration (&ldap_methods);
441
#if defined (USE_SSL)
442
	add_enumeration (&ldap_ssl_usage_enum);
443
	add_enumeration (&ldap_tls_reqcert_enum);
444
	add_enumeration (&ldap_tls_crlcheck_enum);
445
#endif
446
#endif
439
447
440
	if (!group_allocate (&root_group, MDL))
448
	if (!group_allocate (&root_group, MDL))
441
		log_fatal ("Can't allocate root group!");
449
		log_fatal ("Can't allocate root group!");
(-)dhcp-3.0.5/server/ldap.c (+1977 lines)
Line 0 Link Here
1
/* ldap.c
2
3
   Routines for reading the configuration from LDAP */
4
5
/*
6
 * Copyright (c) 2003-2006 Ntelos, Inc.
7
 * All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions
11
 * are met:
12
 *
13
 * 1. Redistributions of source code must retain the above copyright
14
 *    notice, this list of conditions and the following disclaimer.
15
 * 2. Redistributions in binary form must reproduce the above copyright
16
 *    notice, this list of conditions and the following disclaimer in the
17
 *    documentation and/or other materials provided with the distribution.
18
 * 3. Neither the name of The Internet Software Consortium nor the names
19
 *    of its contributors may be used to endorse or promote products derived
20
 *    from this software without specific prior written permission.
21
 *
22
 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23
 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
 * DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34
 * SUCH DAMAGE.
35
 *
36
 * This LDAP module was written by Brian Masney <masneyb@ntelos.net>. Its
37
 * development was sponsored by Ntelos, Inc. (www.ntelos.com).
38
 */
39
40
#include "dhcpd.h"
41
#include <signal.h>
42
43
#if defined(LDAP_CONFIGURATION)
44
45
#if defined(LDAP_CASA_AUTH)
46
#include "ldap_casa.h"
47
#endif
48
49
static LDAP * ld = NULL;
50
static char *ldap_server = NULL, 
51
            *ldap_username = NULL, 
52
            *ldap_password = NULL,
53
            *ldap_base_dn = NULL,
54
            *ldap_dhcp_server_cn = NULL,
55
            *ldap_debug_file = NULL;
56
static int ldap_port = LDAP_PORT,
57
           ldap_method = LDAP_METHOD_DYNAMIC,
58
           ldap_referrals = -1,
59
           ldap_debug_fd = -1;
60
#if defined (USE_SSL)
61
static int ldap_use_ssl = -1,        /* try TLS if possible */
62
           ldap_tls_reqcert = -1,
63
           ldap_tls_crlcheck = -1;
64
static char *ldap_tls_ca_file = NULL,
65
            *ldap_tls_ca_dir = NULL,
66
            *ldap_tls_cert = NULL,
67
            *ldap_tls_key = NULL,
68
            *ldap_tls_ciphers = NULL,
69
            *ldap_tls_randfile = NULL;
70
#endif
71
static struct ldap_config_stack *ldap_stack = NULL;
72
73
typedef struct ldap_dn_node {
74
    struct ldap_dn_node *next;
75
    size_t refs;
76
    char *dn;
77
} ldap_dn_node;
78
79
static ldap_dn_node *ldap_service_dn_head = NULL;
80
static ldap_dn_node *ldap_service_dn_tail = NULL;
81
82
83
static char *
84
x_strncat(char *dst, const char *src, size_t dst_size)
85
{
86
  size_t len = strlen(dst);
87
  return strncat(dst, src, dst_size > len ? dst_size - len - 1: 0);
88
}
89
90
static void
91
ldap_parse_class (struct ldap_config_stack *item, struct parse *cfile)
92
{
93
  char **tempstr;
94
95
  if ((tempstr = ldap_get_values (ld, item->ldent, "cn")) == NULL ||
96
      tempstr[0] == NULL)
97
    {
98
      if (tempstr != NULL)
99
        ldap_value_free (tempstr);
100
101
      return;
102
    }
103
104
  x_strncat (cfile->inbuf, "class \"", LDAP_BUFFER_SIZE);
105
  x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
106
  x_strncat (cfile->inbuf, "\" {\n", LDAP_BUFFER_SIZE);
107
108
  item->close_brace = 1;
109
  ldap_value_free (tempstr);
110
}
111
112
113
static void
114
ldap_parse_subclass (struct ldap_config_stack *item, struct parse *cfile)
115
{
116
  char **tempstr, **classdata;
117
118
  if ((tempstr = ldap_get_values (ld, item->ldent, "cn")) == NULL ||
119
      tempstr[0] == NULL)
120
    {
121
      if (tempstr != NULL)
122
        ldap_value_free (tempstr);
123
124
      return;
125
    }
126
127
  if ((classdata = ldap_get_values (ld, item->ldent, 
128
                                  "dhcpClassData")) == NULL || 
129
      classdata[0] == NULL)
130
    {
131
      if (classdata != NULL)
132
        ldap_value_free (classdata);
133
      ldap_value_free (tempstr);
134
135
      return;
136
    }
137
138
  x_strncat (cfile->inbuf, "subclass ", LDAP_BUFFER_SIZE);
139
  x_strncat (cfile->inbuf, classdata[0], LDAP_BUFFER_SIZE);
140
  x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);
141
  x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
142
  x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
143
144
  item->close_brace = 1;
145
  ldap_value_free (tempstr);
146
  ldap_value_free (classdata);
147
}
148
149
150
static void
151
ldap_parse_host (struct ldap_config_stack *item, struct parse *cfile)
152
{
153
  char **tempstr, **hwaddr;
154
155
  if ((tempstr = ldap_get_values (ld, item->ldent, "cn")) == NULL ||
156
      tempstr[0] == NULL)
157
    {
158
      if (tempstr != NULL)
159
        ldap_value_free (tempstr);
160
161
      return;
162
    }
163
164
  hwaddr = ldap_get_values (ld, item->ldent, "dhcpHWAddress");
165
166
  x_strncat (cfile->inbuf, "host ", LDAP_BUFFER_SIZE);
167
  x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
168
169
  if (hwaddr != NULL && hwaddr[0] != NULL)
170
    {
171
      x_strncat (cfile->inbuf, " {\nhardware ", LDAP_BUFFER_SIZE);
172
      x_strncat (cfile->inbuf, hwaddr[0], LDAP_BUFFER_SIZE);
173
      x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
174
      ldap_value_free (hwaddr);
175
    }
176
177
  item->close_brace = 1;
178
  ldap_value_free (tempstr);
179
}
180
181
182
static void
183
ldap_parse_shared_network (struct ldap_config_stack *item, struct parse *cfile)
184
{
185
  char **tempstr;
186
187
  if ((tempstr = ldap_get_values (ld, item->ldent, "cn")) == NULL ||
188
      tempstr[0] == NULL)
189
    {
190
      if (tempstr != NULL)
191
        ldap_value_free (tempstr);
192
193
      return;
194
    }
195
196
  x_strncat (cfile->inbuf, "shared-network \"", LDAP_BUFFER_SIZE);
197
  x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
198
  x_strncat (cfile->inbuf, "\" {\n", LDAP_BUFFER_SIZE);
199
200
  item->close_brace = 1;
201
  ldap_value_free (tempstr);
202
}
203
204
205
static void
206
parse_netmask (int netmask, char *netmaskbuf)
207
{
208
  unsigned long nm;
209
  int i;
210
211
  nm = 0;
212
  for (i=1; i <= netmask; i++)
213
    {
214
      nm |= 1 << (32 - i);
215
    }
216
217
  sprintf (netmaskbuf, "%d.%d.%d.%d", (int) (nm >> 24) & 0xff, 
218
                                      (int) (nm >> 16) & 0xff, 
219
                                      (int) (nm >> 8) & 0xff, 
220
                                      (int) nm & 0xff);
221
}
222
223
224
static void
225
ldap_parse_subnet (struct ldap_config_stack *item, struct parse *cfile)
226
{
227
  char **tempstr, **netmaskstr, netmaskbuf[16];
228
  int i;
229
230
  if ((tempstr = ldap_get_values (ld, item->ldent, "cn")) == NULL ||
231
      tempstr[0] == NULL)
232
    {
233
      if (tempstr != NULL)
234
        ldap_value_free (tempstr);
235
236
      return;
237
    }
238
239
  if ((netmaskstr = ldap_get_values (ld, item->ldent, 
240
                                     "dhcpNetmask")) == NULL || 
241
      netmaskstr[0] == NULL)
242
    {
243
      if (netmaskstr != NULL)
244
        ldap_value_free (netmaskstr);
245
      ldap_value_free (tempstr);
246
247
      return;
248
    }
249
250
  x_strncat (cfile->inbuf, "subnet ", LDAP_BUFFER_SIZE);
251
  x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
252
253
  x_strncat (cfile->inbuf, " netmask ", LDAP_BUFFER_SIZE);
254
  parse_netmask (strtol (netmaskstr[0], NULL, 10), netmaskbuf);
255
  x_strncat (cfile->inbuf, netmaskbuf, LDAP_BUFFER_SIZE);
256
257
  x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
258
259
  ldap_value_free (tempstr);
260
  ldap_value_free (netmaskstr);
261
262
  if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpRange")) != NULL)
263
    {
264
      for (i=0; tempstr[i] != NULL; i++)
265
        {
266
          x_strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE);
267
          x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);
268
          x_strncat (cfile->inbuf, tempstr[i], LDAP_BUFFER_SIZE);
269
          x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
270
        }
271
      ldap_value_free (tempstr);
272
    }
273
274
  item->close_brace = 1;
275
}
276
277
278
static void
279
ldap_parse_pool (struct ldap_config_stack *item, struct parse *cfile)
280
{
281
  char **tempstr;
282
  int i;
283
284
  x_strncat (cfile->inbuf, "pool {\n", LDAP_BUFFER_SIZE);
285
286
  if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpRange")) != NULL)
287
    {
288
      x_strncat (cfile->inbuf, "range", LDAP_BUFFER_SIZE);
289
      for (i=0; tempstr[i] != NULL; i++)
290
        {
291
          x_strncat (cfile->inbuf, " ", LDAP_BUFFER_SIZE);
292
          x_strncat (cfile->inbuf, tempstr[i], LDAP_BUFFER_SIZE);
293
        }
294
      x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
295
      ldap_value_free (tempstr);
296
    }
297
298
  if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpPermitList")) != NULL)
299
    {
300
      for (i=0; tempstr[i] != NULL; i++)
301
        {
302
          x_strncat (cfile->inbuf, tempstr[i], LDAP_BUFFER_SIZE);
303
          x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
304
        }
305
      ldap_value_free (tempstr);
306
    }
307
308
  item->close_brace = 1;
309
}
310
311
312
static void
313
ldap_parse_group (struct ldap_config_stack *item, struct parse *cfile)
314
{
315
  x_strncat (cfile->inbuf, "group {\n", LDAP_BUFFER_SIZE);
316
  item->close_brace = 1;
317
}
318
319
320
static void
321
ldap_parse_key (struct ldap_config_stack *item, struct parse *cfile)
322
{
323
  char **tempstr;
324
325
  if ((tempstr = ldap_get_values (ld, item->ldent, "cn")) != NULL)
326
    {
327
      x_strncat (cfile->inbuf, "key ", LDAP_BUFFER_SIZE);
328
      x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
329
      x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
330
      ldap_value_free (tempstr);
331
    }
332
333
  if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpKeyAlgorithm")) != NULL)
334
    {
335
      x_strncat (cfile->inbuf, "algorithm ", LDAP_BUFFER_SIZE);
336
      x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
337
      x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
338
      ldap_value_free (tempstr);
339
    }
340
341
  if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpKeySecret")) != NULL)
342
    {
343
      x_strncat (cfile->inbuf, "secret ", LDAP_BUFFER_SIZE);
344
      x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
345
      x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
346
      ldap_value_free (tempstr);
347
    }
348
349
  item->close_brace = 1;
350
}
351
352
353
static void
354
ldap_parse_zone (struct ldap_config_stack *item, struct parse *cfile)
355
{
356
  char *cnFindStart, *cnFindEnd;
357
  char **tempstr;
358
  char *keyCn;
359
  size_t len;
360
361
  if ((tempstr = ldap_get_values (ld, item->ldent, "cn")) != NULL)
362
    {
363
      x_strncat (cfile->inbuf, "zone ", LDAP_BUFFER_SIZE);
364
      x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
365
      x_strncat (cfile->inbuf, " {\n", LDAP_BUFFER_SIZE);
366
      ldap_value_free (tempstr);
367
    }
368
369
  if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpDnsZoneServer")) != NULL)
370
    {
371
      x_strncat (cfile->inbuf, "primary ", LDAP_BUFFER_SIZE);
372
      x_strncat (cfile->inbuf, tempstr[0], LDAP_BUFFER_SIZE);
373
374
      x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
375
      ldap_value_free (tempstr);
376
    }
377
378
  if ((tempstr = ldap_get_values (ld, item->ldent, "dhcpKeyDN")) != NULL)
379
    {
380
      cnFindStart = strchr(tempstr[0],'=');
381
      if (cnFindStart != NULL)
382
        cnFindEnd = strchr(++cnFindStart,',');
383
      else
384
        cnFindEnd = NULL;
385
386
      if (cnFindEnd != NULL && cnFindEnd > cnFindStart)
387
        {
388
          len = cnFindEnd - cnFindStart;
389
          keyCn = dmalloc (len + 1, MDL);
390
        }
391
      else
392
        {
393
          len = 0;
394
          keyCn = NULL;
395
        }
396
397
      if (keyCn != NULL)
398
        {
399
          strncpy (keyCn, cnFindStart, len);
400
          keyCn[len] = '\0';
401
402
          x_strncat (cfile->inbuf, "key ", LDAP_BUFFER_SIZE);
403
          x_strncat (cfile->inbuf, keyCn, LDAP_BUFFER_SIZE);
404
          x_strncat (cfile->inbuf, ";\n", LDAP_BUFFER_SIZE);
405
406
          dfree (keyCn, MDL);
407
        }
408
409
      ldap_value_free (tempstr);
410
     }
411
412
  item->close_brace = 1;
413
}
414
415
416
static void
417
add_to_config_stack (LDAPMessage * res, LDAPMessage * ent)
418
{
419
  struct ldap_config_stack *ns;
420
421
  ns = dmalloc (sizeof (*ns), MDL);
422
  ns->res = res;
423
  ns->ldent = ent;
424
  ns->close_brace = 0;
425
  ns->processed = 0;
426
  ns->next = ldap_stack;
427
  ldap_stack = ns;
428
}
429
430
431
static void
432
ldap_stop()
433
{
434
  struct sigaction old, new;
435
436
  if (ld == NULL)
437
    return;
438
439
  /*
440
   ** ldap_unbind after a LDAP_SERVER_DOWN result
441
   ** causes a SIGPIPE and dhcpd gets terminated,
442
   ** since it doesn't handle it...
443
   */
444
445
  new.sa_flags   = 0;
446
  new.sa_handler = SIG_IGN;
447
  sigemptyset (&new.sa_mask);
448
  sigaction (SIGPIPE, &new, &old);
449
450
  ldap_unbind (ld);
451
  ld = NULL;
452
453
  sigaction (SIGPIPE, &old, &new);
454
}
455
456
457
static char *
458
_do_lookup_dhcp_string_option (struct option_state *options, int option_name)
459
{
460
  struct option_cache *oc;
461
  struct data_string db;
462
  char *ret;
463
464
  memset (&db, 0, sizeof (db));
465
  oc = lookup_option (&server_universe, options, option_name);
466
  if (oc &&
467
      evaluate_option_cache (&db, (struct packet*) NULL,
468
                             (struct lease *) NULL,
469
                             (struct client_state *) NULL, options,
470
                             (struct option_state *) NULL,
471
                             &global_scope, oc, MDL) &&
472
      db.data != NULL && *db.data != '\0')
473
474
    {
475
      ret = dmalloc (db.len + 1, MDL);
476
      if (ret == NULL)
477
        log_fatal ("no memory for ldap option %d value", option_name);
478
479
      memcpy (ret, db.data, db.len);
480
      ret[db.len] = 0;
481
      data_string_forget (&db, MDL);
482
    }
483
  else
484
    ret = NULL;
485
486
  return (ret);
487
}
488
489
490
static int
491
_do_lookup_dhcp_int_option (struct option_state *options, int option_name)
492
{
493
  struct option_cache *oc;
494
  struct data_string db;
495
  int ret;
496
497
  memset (&db, 0, sizeof (db));
498
  oc = lookup_option (&server_universe, options, option_name);
499
  if (oc &&
500
      evaluate_option_cache (&db, (struct packet*) NULL,
501
                             (struct lease *) NULL,
502
                             (struct client_state *) NULL, options,
503
                             (struct option_state *) NULL,
504
                             &global_scope, oc, MDL) &&
505
      db.data != NULL && *db.data != '\0')
506
    {
507
      ret = strtol (db.data, NULL, 10);
508
      data_string_forget (&db, MDL);
509
    }
510
  else
511
    ret = 0;
512
513
  return (ret);
514
}
515
516
517
static int
518
_do_lookup_dhcp_enum_option (struct option_state *options, int option_name)
519
{
520
  struct option_cache *oc;
521
  struct data_string db;
522
  int ret;
523
524
  memset (&db, 0, sizeof (db));
525
  oc = lookup_option (&server_universe, options, option_name);
526
  if (oc &&
527
      evaluate_option_cache (&db, (struct packet*) NULL,
528
                             (struct lease *) NULL,
529
                             (struct client_state *) NULL, options,
530
                             (struct option_state *) NULL,
531
                             &global_scope, oc, MDL) &&
532
      db.data != NULL && *db.data != '\0')
533
    {
534
      if (db.len == 1) 
535
        ret = db.data [0];
536
      else
537
        log_fatal ("invalid option name %d", option_name);
538
539
      data_string_forget (&db, MDL);
540
    }
541
  else
542
    ret = 0;
543
544
  return (ret);
545
}
546
547
int
548
ldap_rebind_cb (LDAP *ld, LDAP_CONST char *url, ber_tag_t request, ber_int_t msgid, void *parms)
549
{
550
  int ret;
551
  LDAPURLDesc *ldapurl = NULL;
552
  char *who = NULL, *pwd = NULL;
553
554
  log_info("LDAP rebind to '%s'", url);
555
  if ((ret = ldap_url_parse(url, &ldapurl)) != LDAP_SUCCESS)
556
    {
557
      log_error ("Error: Can not parse ldap rebind url '%s': %s",
558
                 url, ldap_err2string(ret));
559
      return ret;
560
    }
561
562
563
#if defined (USE_SSL)
564
  if (strcasecmp(ldapurl->lud_scheme, "ldaps") == 0)
565
    {
566
      int opt = LDAP_OPT_X_TLS_HARD;
567
      if ((ret = ldap_set_option (ld, LDAP_OPT_X_TLS, &opt)) != LDAP_SUCCESS)
568
        {
569
          log_error ("Error: Cannot init LDAPS session to %s:%d: %s",
570
                    ldapurl->lud_host, ldapurl->lud_port, ldap_err2string (ret));
571
          return ret;
572
        }
573
      else
574
        {
575
          log_info ("LDAPS session successfully enabled to %s", ldap_server);
576
        }
577
    }
578
  else
579
  if (strcasecmp(ldapurl->lud_scheme, "ldap") == 0 &&
580
      ldap_use_ssl != LDAP_SSL_OFF)
581
    {
582
      if ((ret = ldap_start_tls_s (ld, NULL, NULL)) != LDAP_SUCCESS)
583
        {
584
          log_error ("Error: Cannot start TLS session to %s:%d: %s",
585
                     ldapurl->lud_host, ldapurl->lud_port, ldap_err2string (ret));
586
          return ret;
587
        }
588
      else
589
        {
590
          log_info ("TLS session successfully started to %s:%d",
591
                    ldapurl->lud_host, ldapurl->lud_port);
592
        }
593
    }
594
#endif
595
596
597
  if (ldap_username != NULL || *ldap_username != '\0')
598
    {
599
      who = ldap_username;
600
      pwd = ldap_password;
601
    }
602
603
  if ((ret = ldap_simple_bind_s (ld, who, pwd)) != LDAP_SUCCESS)
604
    {
605
      log_error ("Error: Cannot login into ldap server %s:%d: %s",
606
                 ldapurl->lud_host, ldapurl->lud_port, ldap_err2string (ret));
607
    }
608
  return ret;
609
}
610
611
static void
612
ldap_start (void)
613
{
614
  struct option_state *options;
615
  int ret, version;
616
617
  if (ld != NULL)
618
    return;
619
620
  if (ldap_server == NULL)
621
    {
622
      options = NULL;
623
      option_state_allocate (&options, MDL);
624
625
      execute_statements_in_scope ((struct binding_value **) NULL,
626
                 (struct packet *) NULL, (struct lease *) NULL,
627
                 (struct client_state *) NULL, (struct option_state *) NULL,
628
                 options, &global_scope, root_group, (struct group *) NULL);
629
630
      ldap_server = _do_lookup_dhcp_string_option (options, SV_LDAP_SERVER);
631
      ldap_dhcp_server_cn = _do_lookup_dhcp_string_option (options,
632
                                                      SV_LDAP_DHCP_SERVER_CN);
633
      ldap_port = _do_lookup_dhcp_int_option (options, SV_LDAP_PORT);
634
      ldap_base_dn = _do_lookup_dhcp_string_option (options, SV_LDAP_BASE_DN);
635
      ldap_method = _do_lookup_dhcp_enum_option (options, SV_LDAP_METHOD);
636
      ldap_debug_file = _do_lookup_dhcp_string_option (options,
637
                                                       SV_LDAP_DEBUG_FILE);
638
      ldap_referrals = _do_lookup_dhcp_enum_option (options, SV_LDAP_REFERRALS);
639
640
#if defined (USE_SSL)
641
      ldap_use_ssl = _do_lookup_dhcp_enum_option (options, SV_LDAP_SSL);
642
      if( ldap_use_ssl != LDAP_SSL_OFF)
643
        {
644
          ldap_tls_reqcert = _do_lookup_dhcp_enum_option (options, SV_LDAP_TLS_REQCERT);
645
          ldap_tls_ca_file = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CA_FILE);
646
          ldap_tls_ca_dir = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CA_DIR);
647
          ldap_tls_cert = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CERT);
648
          ldap_tls_key = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_KEY);
649
          ldap_tls_crlcheck = _do_lookup_dhcp_enum_option (options, SV_LDAP_TLS_CRLCHECK);
650
          ldap_tls_ciphers = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_CIPHERS);
651
          ldap_tls_randfile = _do_lookup_dhcp_string_option (options, SV_LDAP_TLS_RANDFILE);
652
        }
653
#endif
654
655
#if defined (LDAP_CASA_AUTH)
656
      if (!load_uname_pwd_from_miCASA(&ldap_username,&ldap_password))
657
        {
658
#if defined (DEBUG_LDAP)
659
          log_info ("Authentication credential taken from file");
660
#endif
661
#endif
662
663
      ldap_username = _do_lookup_dhcp_string_option (options, SV_LDAP_USERNAME);
664
      ldap_password = _do_lookup_dhcp_string_option (options, SV_LDAP_PASSWORD);
665
666
#if defined (LDAP_CASA_AUTH)
667
      }
668
#endif
669
670
      option_state_dereference (&options, MDL);
671
    }
672
673
  if (ldap_server == NULL || ldap_base_dn == NULL)
674
    {
675
      log_info ("Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file");
676
      ldap_method = LDAP_METHOD_STATIC;
677
      return;
678
    }
679
680
  if (ldap_debug_file != NULL && ldap_debug_fd == -1)
681
    {
682
      if ((ldap_debug_fd = open (ldap_debug_file, O_CREAT | O_TRUNC | O_WRONLY,
683
                                 S_IRUSR | S_IWUSR)) < 0)
684
        log_error ("Error opening debug LDAP log file %s: %s", ldap_debug_file,
685
                   strerror (errno));
686
    }
687
688
#if defined (DEBUG_LDAP)
689
  log_info ("Connecting to LDAP server %s:%d", ldap_server, ldap_port);
690
#endif
691
692
#if defined (USE_SSL)
693
  if (ldap_use_ssl == -1)
694
    {
695
      /*
696
      ** There was no "ldap-ssl" option in dhcpd.conf (also not "off").
697
      ** Let's try, if we can use an anonymous TLS session without to
698
      ** verify the server certificate -- if not continue without TLS.
699
      */
700
      int opt = LDAP_OPT_X_TLS_ALLOW;
701
      if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_REQUIRE_CERT,
702
                                  &opt)) != LDAP_SUCCESS)
703
        {
704
          log_error ("Warning: Cannot set LDAP TLS require cert option to 'allow': %s",
705
                     ldap_err2string (ret));
706
        }
707
    }
708
709
  if (ldap_use_ssl != LDAP_SSL_OFF)
710
    {
711
      if (ldap_tls_reqcert != -1)
712
        {
713
          if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_REQUIRE_CERT,
714
                                      &ldap_tls_reqcert)) != LDAP_SUCCESS)
715
            {
716
              log_error ("Cannot set LDAP TLS require cert option: %s",
717
                         ldap_err2string (ret));
718
            }
719
        }
720
721
      if( ldap_tls_ca_file != NULL)
722
        {
723
          if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CACERTFILE,
724
                                      ldap_tls_ca_file)) != LDAP_SUCCESS)
725
            {
726
              log_error ("Cannot set LDAP TLS CA certificate file %s: %s",
727
                         ldap_tls_ca_file, ldap_err2string (ret));
728
            }
729
        }
730
      if( ldap_tls_ca_dir != NULL)
731
        {
732
          if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CACERTDIR,
733
                                      ldap_tls_ca_dir)) != LDAP_SUCCESS)
734
            {
735
              log_error ("Cannot set LDAP TLS CA certificate dir %s: %s",
736
                         ldap_tls_ca_dir, ldap_err2string (ret));
737
            }
738
        }
739
      if( ldap_tls_cert != NULL)
740
        {
741
          if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CERTFILE,
742
                                      ldap_tls_cert)) != LDAP_SUCCESS)
743
            {
744
              log_error ("Cannot set LDAP TLS client certificate file %s: %s",
745
                         ldap_tls_cert, ldap_err2string (ret));
746
            }
747
        }
748
      if( ldap_tls_key != NULL)
749
        {
750
          if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_KEYFILE,
751
                                      ldap_tls_key)) != LDAP_SUCCESS)
752
            {
753
              log_error ("Cannot set LDAP TLS certificate key file %s: %s",
754
                         ldap_tls_key, ldap_err2string (ret));
755
            }
756
        }
757
      if( ldap_tls_crlcheck != -1)
758
        {
759
          int opt = ldap_tls_crlcheck;
760
          if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CRLCHECK,
761
                                      &opt)) != LDAP_SUCCESS)
762
            {
763
              log_error ("Cannot set LDAP TLS crl check option: %s",
764
                         ldap_err2string (ret));
765
            }
766
        }
767
      if( ldap_tls_ciphers != NULL)
768
        {
769
          if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_CIPHER_SUITE,
770
                                      ldap_tls_ciphers)) != LDAP_SUCCESS)
771
            {
772
              log_error ("Cannot set LDAP TLS cipher suite %s: %s",
773
                         ldap_tls_ciphers, ldap_err2string (ret));
774
            }
775
        }
776
      if( ldap_tls_randfile != NULL)
777
        {
778
          if ((ret = ldap_set_option (NULL, LDAP_OPT_X_TLS_RANDOM_FILE,
779
                                      ldap_tls_randfile)) != LDAP_SUCCESS)
780
            {
781
              log_error ("Cannot set LDAP TLS random file %s: %s",
782
                         ldap_tls_randfile, ldap_err2string (ret));
783
            }
784
        }
785
    }
786
#endif
787
788
  if ((ld = ldap_init (ldap_server, ldap_port)) == NULL)
789
    {
790
      log_error ("Cannot init ldap session to %s:%d", ldap_server, ldap_port);
791
      return;
792
    }
793
794
  version = LDAP_VERSION3;
795
  if ((ret = ldap_set_option (ld, LDAP_OPT_PROTOCOL_VERSION, &version)) != LDAP_OPT_SUCCESS)
796
    {
797
      log_error ("Cannot set LDAP version to %d: %s", version,
798
                 ldap_err2string (ret));
799
    }
800
801
  if (ldap_referrals != -1)
802
    {
803
      if ((ret = ldap_set_option (ld, LDAP_OPT_REFERRALS, ldap_referrals ?
804
                                  LDAP_OPT_ON : LDAP_OPT_OFF)) != LDAP_OPT_SUCCESS)
805
        {
806
          log_error ("Cannot %s LDAP referrals option: %s",
807
                     (ldap_referrals ? "enable" : "disable"),
808
                     ldap_err2string (ret));
809
        }
810
    }
811
812
  if ((ret = ldap_set_rebind_proc(ld, ldap_rebind_cb, NULL)) != LDAP_SUCCESS)
813
    {
814
      log_error ("Warning: Cannot set ldap rebind procedure: %s",
815
                 ldap_err2string (ret));
816
    }
817
818
#if defined (USE_SSL)
819
  if (ldap_use_ssl == LDAP_SSL_LDAPS ||
820
     (ldap_use_ssl == LDAP_SSL_ON && ldap_port == LDAPS_PORT))
821
    {
822
      int opt = LDAP_OPT_X_TLS_HARD;
823
      if ((ret = ldap_set_option (ld, LDAP_OPT_X_TLS, &opt)) != LDAP_SUCCESS)
824
        {
825
          log_error ("Error: Cannot init LDAPS session to %s:%d: %s",
826
                    ldap_server, ldap_port, ldap_err2string (ret));
827
          ldap_stop();
828
          return;
829
        }
830
      else
831
        {
832
          log_info ("LDAPS session successfully enabled to %s:%d",
833
                    ldap_server, ldap_port);
834
        }
835
    }
836
  else if (ldap_use_ssl != LDAP_SSL_OFF)
837
    {
838
      if ((ret = ldap_start_tls_s (ld, NULL, NULL)) != LDAP_SUCCESS)
839
        {
840
          log_error ("Error: Cannot start TLS session to %s:%d: %s",
841
                     ldap_server, ldap_port, ldap_err2string (ret));
842
          ldap_stop();
843
          return;
844
        }
845
      else
846
        {
847
          log_info ("TLS session successfully started to %s:%d",
848
                    ldap_server, ldap_port);
849
        }
850
    }
851
#endif
852
853
  if (ldap_username != NULL && *ldap_username != '\0')
854
    {
855
      if ((ret = ldap_simple_bind_s (ld, ldap_username,
856
                                     ldap_password)) != LDAP_SUCCESS)
857
        {
858
          log_error ("Error: Cannot login into ldap server %s:%d: %s",
859
                     ldap_server, ldap_port, ldap_err2string (ret));
860
          ldap_stop();
861
          return;
862
        }
863
    }
864
865
#if defined (DEBUG_LDAP)
866
  log_info ("Successfully logged into LDAP server %s", ldap_server);
867
#endif
868
}
869
870
871
static void
872
parse_external_dns (LDAPMessage * ent)
873
{
874
  char *search[] = {"dhcpOptionsDN", "dhcpSharedNetworkDN", "dhcpSubnetDN",
875
                    "dhcpGroupDN", "dhcpHostDN", "dhcpClassesDN",
876
                    "dhcpPoolDN", NULL};
877
  LDAPMessage * newres, * newent;
878
  struct ldap_config_stack *ns;
879
  char **tempstr;
880
  int i, j, ret;
881
#if defined (DEBUG_LDAP)
882
  char *dn;
883
884
  dn = ldap_get_dn (ld, ent);
885
  if (dn != NULL)
886
    {
887
      log_info ("Parsing external DNs for '%s'", dn);
888
      ldap_memfree (dn);
889
    }
890
#endif
891
892
  if (ld == NULL)
893
    ldap_start ();
894
  if (ld == NULL)
895
    return;
896
897
  for (i=0; search[i] != NULL; i++)
898
    {
899
      if ((tempstr = ldap_get_values (ld, ent, search[i])) == NULL)
900
        continue;
901
902
      for (j=0; tempstr[j] != NULL; j++)
903
        {
904
          if (*tempstr[j] == '\0')
905
            continue;
906
907
          if ((ret = ldap_search_s (ld, tempstr[j], LDAP_SCOPE_BASE, 
908
                                    "objectClass=*", NULL, 0, 
909
                                    &newres)) != LDAP_SUCCESS)
910
            {
911
              ldap_value_free (tempstr);
912
              ldap_stop();
913
              return;
914
            }
915
    
916
#if defined (DEBUG_LDAP)
917
          log_info ("Adding contents of subtree '%s' to config stack from '%s' reference", tempstr[j], search[i]);
918
#endif
919
          for (newent = ldap_first_entry (ld, newres);
920
               newent != NULL;
921
               newent = ldap_next_entry (ld, newent))
922
            {
923
#if defined (DEBUG_LDAP)
924
              dn = ldap_get_dn (ld, newent);
925
              if (dn != NULL)
926
                {
927
                  log_info ("Adding LDAP result set starting with '%s' to config stack", dn);
928
                  ldap_memfree (dn);
929
                }
930
#endif
931
932
              add_to_config_stack (newres, newent);
933
              /* don't free newres here */
934
            }
935
        }
936
937
      ldap_value_free (tempstr);
938
    }
939
}
940
941
942
static void
943
free_stack_entry (struct ldap_config_stack *item)
944
{
945
  struct ldap_config_stack *look_ahead_pointer = item;
946
  int may_free_msg = 1;
947
948
  while (look_ahead_pointer->next != NULL)
949
    {
950
      look_ahead_pointer = look_ahead_pointer->next;
951
      if (look_ahead_pointer->res == item->res)
952
        {
953
          may_free_msg = 0;
954
          break;
955
        }
956
    }
957
958
  if (may_free_msg) 
959
    ldap_msgfree (item->res);
960
961
  dfree (item, MDL);
962
}
963
964
965
static void
966
next_ldap_entry (struct parse *cfile)
967
{
968
  struct ldap_config_stack *temp_stack;
969
970
  if (ldap_stack != NULL && ldap_stack->close_brace)
971
    {
972
      x_strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE);
973
      ldap_stack->close_brace = 0;
974
    }
975
976
  while (ldap_stack != NULL && 
977
         (ldap_stack->ldent == NULL ||
978
          (ldap_stack->ldent = ldap_next_entry (ld, ldap_stack->ldent)) == NULL))
979
    {
980
      if (ldap_stack->close_brace)
981
        {
982
          x_strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE);
983
          ldap_stack->close_brace = 0;
984
        }
985
986
      temp_stack = ldap_stack;
987
      ldap_stack = ldap_stack->next;
988
      free_stack_entry (temp_stack);
989
    }
990
991
  if (ldap_stack != NULL && ldap_stack->close_brace)
992
    {
993
      x_strncat (cfile->inbuf, "}\n", LDAP_BUFFER_SIZE);
994
      ldap_stack->close_brace = 0;
995
    }
996
}
997
998
999
static char
1000
check_statement_end (const char *statement)
1001
{
1002
  char *ptr;
1003
1004
  if (statement == NULL || *statement == '\0')
1005
    return ('\0');
1006
1007
  /*
1008
  ** check if it ends with "}", e.g.:
1009
  **   "zone my.domain. { ... }"
1010
  ** optionally followed by spaces
1011
  */
1012
  ptr = strrchr (statement, '}');
1013
  if (ptr != NULL)
1014
    {
1015
      /* skip following white-spaces */
1016
      for (++ptr; isspace ((int)*ptr); ptr++);
1017
1018
      /* check if we reached the end */
1019
      if (*ptr == '\0')
1020
        return ('}'); /* yes, block end */
1021
      else
1022
        return (*ptr);
1023
    }
1024
1025
  /*
1026
  ** this should not happen, but...
1027
  ** check if it ends with ";", e.g.:
1028
  **   "authoritative;"
1029
  ** optionally followed by spaces
1030
  */
1031
  ptr = strrchr (statement, ';');
1032
  if (ptr != NULL)
1033
    {
1034
      /* skip following white-spaces */
1035
      for (++ptr; isspace ((int)*ptr); ptr++);
1036
1037
      /* check if we reached the end */
1038
      if (*ptr == '\0')
1039
        return (';'); /* ends with a ; */
1040
      else
1041
        return (*ptr);
1042
    }
1043
1044
  return ('\0');
1045
}
1046
1047
1048
static isc_result_t
1049
ldap_parse_entry_options (LDAPMessage *ent, char *buffer, size_t size,
1050
                          int *lease_limit)
1051
{
1052
  char **tempstr;
1053
  int i;
1054
1055
  if (ent == NULL || buffer == NULL || size == 0)
1056
    return (ISC_R_FAILURE);
1057
1058
  if ((tempstr = ldap_get_values (ld, ent, "dhcpStatements")) != NULL)
1059
    {
1060
      for (i=0; tempstr[i] != NULL; i++)
1061
        {
1062
          if (lease_limit != NULL &&
1063
              strncasecmp ("lease limit ", tempstr[i], 12) == 0)
1064
            {
1065
              *lease_limit = (int) strtol ((tempstr[i]) + 12, NULL, 10);
1066
              continue;
1067
            }
1068
1069
          x_strncat (buffer, tempstr[i], size);
1070
1071
          switch((int) check_statement_end (tempstr[i]))
1072
            {
1073
              case '}':
1074
              case ';':
1075
                x_strncat (buffer, "\n", size);
1076
                break;
1077
              default:
1078
                x_strncat (buffer, ";\n", size);
1079
                break;
1080
            }
1081
        }
1082
      ldap_value_free (tempstr);
1083
    }
1084
1085
  if ((tempstr = ldap_get_values (ld, ent, "dhcpOption")) != NULL)
1086
    {
1087
      for (i=0; tempstr[i] != NULL; i++)
1088
        {
1089
          x_strncat (buffer, "option ", size);
1090
          x_strncat (buffer, tempstr[i], size);
1091
          switch ((int) check_statement_end (tempstr[i]))
1092
            {
1093
              case ';':
1094
                x_strncat (buffer, "\n", size);
1095
                break;
1096
              default:
1097
                x_strncat (buffer, ";\n", size);
1098
                break;
1099
            }
1100
        }
1101
      ldap_value_free (tempstr);
1102
    }
1103
1104
  return (ISC_R_SUCCESS);
1105
}
1106
1107
1108
static void
1109
ldap_generate_config_string (struct parse *cfile)
1110
{
1111
  char **objectClass, *dn;
1112
  struct ldap_config_stack *entry;
1113
  LDAPMessage * ent, * res;
1114
  int i, j, ignore, found;
1115
  int ret;
1116
1117
  if (ld == NULL)
1118
    ldap_start ();
1119
  if (ld == NULL)
1120
    return;
1121
1122
  entry = ldap_stack;
1123
  if ((objectClass = ldap_get_values (ld, entry->ldent, 
1124
                                      "objectClass")) == NULL)
1125
    return;
1126
    
1127
  ignore = 0;
1128
  found = 1;
1129
  for (i=0; objectClass[i] != NULL; i++)
1130
    {
1131
      if (strcasecmp (objectClass[i], "dhcpSharedNetwork") == 0)
1132
        ldap_parse_shared_network (entry, cfile);
1133
      else if (strcasecmp (objectClass[i], "dhcpClass") == 0)
1134
        ldap_parse_class (entry, cfile);
1135
      else if (strcasecmp (objectClass[i], "dhcpSubnet") == 0)
1136
        ldap_parse_subnet (entry, cfile);
1137
      else if (strcasecmp (objectClass[i], "dhcpPool") == 0)
1138
        ldap_parse_pool (entry, cfile);
1139
      else if (strcasecmp (objectClass[i], "dhcpGroup") == 0)
1140
        ldap_parse_group (entry, cfile);
1141
      else if (strcasecmp (objectClass[i], "dhcpTSigKey") == 0)
1142
        ldap_parse_key (entry, cfile);
1143
      else if (strcasecmp (objectClass[i], "dhcpDnsZone") == 0)
1144
        ldap_parse_zone (entry, cfile);
1145
      else if (strcasecmp (objectClass[i], "dhcpHost") == 0)
1146
        {
1147
          if (ldap_method == LDAP_METHOD_STATIC)
1148
            ldap_parse_host (entry, cfile);
1149
          else
1150
            {
1151
              ignore = 1;
1152
              break;
1153
            }
1154
        }
1155
      else if (strcasecmp (objectClass[i], "dhcpSubClass") == 0)
1156
        {
1157
          if (ldap_method == LDAP_METHOD_STATIC)
1158
            ldap_parse_subclass (entry, cfile);
1159
          else
1160
            {
1161
              ignore = 1;
1162
              break;
1163
            }
1164
        }
1165
      else
1166
        found = 0;
1167
1168
      if (found && cfile->inbuf[0] == '\0')
1169
        {
1170
          ignore = 1;
1171
          break;
1172
        }
1173
    }
1174
1175
  ldap_value_free (objectClass);
1176
1177
  if (ignore)
1178
    {
1179
      next_ldap_entry (cfile);
1180
      return;
1181
    }
1182
1183
  ldap_parse_entry_options(entry->ldent, cfile->inbuf,
1184
                           LDAP_BUFFER_SIZE-1, NULL);
1185
1186
  dn = ldap_get_dn (ld, entry->ldent);
1187
1188
#if defined(DEBUG_LDAP)
1189
  if (dn != NULL)
1190
    log_info ("Found LDAP entry '%s'", dn);
1191
#endif
1192
1193
  if (dn == NULL ||
1194
      (ret = ldap_search_s (ld, dn, LDAP_SCOPE_ONELEVEL, "objectClass=*", 
1195
                            NULL, 0, &res)) != LDAP_SUCCESS)
1196
    {
1197
      if (dn)
1198
        ldap_memfree (dn);
1199
1200
      ldap_stop();
1201
      return;
1202
    }
1203
1204
  ldap_memfree (dn);
1205
1206
  if ((ent = ldap_first_entry (ld, res)) != NULL)
1207
    {
1208
      add_to_config_stack (res, ent);
1209
      parse_external_dns (entry->ldent);
1210
    }
1211
  else
1212
    {
1213
      ldap_msgfree (res);
1214
      parse_external_dns (entry->ldent);
1215
      next_ldap_entry (cfile);
1216
    }
1217
}
1218
1219
1220
static void
1221
ldap_close_debug_fd()
1222
{
1223
  if (ldap_debug_fd != -1)
1224
    {
1225
      close (ldap_debug_fd);
1226
      ldap_debug_fd = -1;
1227
    }
1228
}
1229
1230
1231
static void
1232
ldap_write_debug (const void *buff, size_t size)
1233
{
1234
  if (ldap_debug_fd != -1)
1235
    {
1236
      if (write (ldap_debug_fd, buff, size) < 0)
1237
        {
1238
          log_error ("Error writing to LDAP debug file %s: %s."
1239
                     " Disabling log file.", ldap_debug_file,
1240
                     strerror (errno));
1241
          ldap_close_debug_fd();
1242
        }
1243
    }
1244
}
1245
1246
static int
1247
ldap_read_function (struct parse *cfile)
1248
{
1249
  cfile->inbuf[0] = '\0';
1250
  cfile->buflen = 0;
1251
 
1252
  while (ldap_stack != NULL && *cfile->inbuf == '\0')
1253
    ldap_generate_config_string (cfile);
1254
1255
  if (ldap_stack == NULL && *cfile->inbuf == '\0')
1256
    return (EOF);
1257
1258
  cfile->bufix = 1;
1259
  cfile->buflen = strlen (cfile->inbuf);
1260
  if (cfile->buflen > 0)
1261
    ldap_write_debug (cfile->inbuf, cfile->buflen);
1262
1263
#if defined (DEBUG_LDAP)
1264
  log_info ("Sending config line '%s'", cfile->inbuf);
1265
#endif
1266
1267
  return (cfile->inbuf[0]);
1268
}
1269
1270
1271
static char *
1272
ldap_get_host_name (LDAPMessage * ent)
1273
{
1274
  char **name, *ret;
1275
1276
  ret = NULL;
1277
  if ((name = ldap_get_values (ld, ent, "cn")) == NULL || name[0] == NULL)
1278
    {
1279
      if (name != NULL)
1280
        ldap_value_free (name);
1281
1282
#if defined (DEBUG_LDAP)
1283
      ret = ldap_get_dn (ld, ent);
1284
      if (ret != NULL)
1285
        {
1286
          log_info ("Cannot get cn attribute for LDAP entry %s", ret);
1287
          ldap_memfree(ret);
1288
        }
1289
#endif
1290
      return (NULL);
1291
    }
1292
1293
  ret = dmalloc (strlen (name[0]) + 1, MDL);
1294
  strcpy (ret, name[0]);
1295
  ldap_value_free (name);
1296
1297
  return (ret);
1298
}
1299
1300
1301
static int
1302
getfqhostname(char *fqhost, size_t size)
1303
{
1304
#if defined(MAXHOSTNAMELEN)
1305
  char   hname[MAXHOSTNAMELEN];
1306
#else
1307
  char   hname[65];
1308
#endif
1309
  struct hostent *hp;
1310
1311
  if(NULL == fqhost || 1 >= size)
1312
    return -1;
1313
1314
  memset(hname, 0, sizeof(hname));
1315
  if( gethostname(hname, sizeof(hname)-1))
1316
    return -1;
1317
1318
  if(NULL == (hp = gethostbyname(hname)))
1319
    return -1;
1320
1321
  strncpy(fqhost, hp->h_name, size-1);
1322
  fqhost[size-1] = '\0';
1323
  return 0;
1324
}
1325
1326
1327
isc_result_t
1328
ldap_read_config (void)
1329
{
1330
  LDAPMessage * ldres, * hostres, * ent, * hostent;
1331
  char hfilter[1024], sfilter[1024], fqdn[257];
1332
  char *buffer, **tempstr = NULL, *hostdn;
1333
  ldap_dn_node *curr = NULL;
1334
  struct parse *cfile;
1335
  struct utsname unme;
1336
  isc_result_t res;
1337
  size_t length;
1338
  int ret, cnt;
1339
1340
  if (ld == NULL)
1341
    ldap_start ();
1342
  if (ld == NULL)
1343
    return (ldap_server == NULL ? ISC_R_SUCCESS : ISC_R_FAILURE);
1344
 
1345
  buffer = dmalloc (LDAP_BUFFER_SIZE+1, MDL);
1346
  if (buffer == NULL)
1347
    return (ISC_R_FAILURE);
1348
1349
  cfile = (struct parse *) NULL;
1350
  res = new_parse (&cfile, -1, buffer, LDAP_BUFFER_SIZE, "LDAP", 0);
1351
  if (res != ISC_R_SUCCESS)
1352
    return (res);
1353
 
1354
  uname (&unme);
1355
  if (ldap_dhcp_server_cn != NULL)
1356
    {
1357
     snprintf (hfilter, sizeof (hfilter),
1358
                "(&(objectClass=dhcpServer)(cn=%s))", ldap_dhcp_server_cn);
1359
    }
1360
  else
1361
  {
1362
  if(0 == getfqhostname(fqdn, sizeof(fqdn)))
1363
    {
1364
      snprintf (hfilter, sizeof (hfilter),
1365
                "(&(objectClass=dhcpServer)(|(cn=%s)(cn=%s)))", 
1366
                unme.nodename, fqdn);
1367
    }
1368
  else
1369
    {
1370
      snprintf (hfilter, sizeof (hfilter),
1371
                "(&(objectClass=dhcpServer)(cn=%s))", unme.nodename);
1372
    }
1373
1374
  }
1375
  hostres = NULL;
1376
  if ((ret = ldap_search_s (ld, ldap_base_dn, LDAP_SCOPE_SUBTREE,
1377
                            hfilter, NULL, 0, &hostres)) != LDAP_SUCCESS)
1378
    {
1379
      log_error ("Cannot find host LDAP entry %s %s",
1380
		 ((ldap_dhcp_server_cn == NULL)?(unme.nodename):(ldap_dhcp_server_cn)), hfilter);
1381
      if(NULL != hostres)
1382
        ldap_msgfree (hostres);
1383
      ldap_stop();
1384
      return (ISC_R_FAILURE);
1385
    }
1386
1387
  if ((hostent = ldap_first_entry (ld, hostres)) == NULL)
1388
    {
1389
      log_error ("Error: Cannot find LDAP entry matching %s", hfilter);
1390
      ldap_msgfree (hostres);
1391
      ldap_stop();
1392
      return (ISC_R_FAILURE);
1393
    }
1394
1395
  hostdn = ldap_get_dn (ld, hostent);
1396
#if defined(DEBUG_LDAP)
1397
  if (hostdn != NULL)
1398
    log_info ("Found dhcpServer LDAP entry '%s'", hostdn);
1399
#endif
1400
1401
  if (hostdn == NULL ||
1402
      (tempstr = ldap_get_values (ld, hostent, "dhcpServiceDN")) == NULL ||
1403
      tempstr[0] == NULL)
1404
    {
1405
      log_error ("Error: Cannot find LDAP entry matching %s", hfilter);
1406
1407
      if (tempstr != NULL)
1408
        ldap_value_free (tempstr);
1409
1410
      if (hostdn)
1411
        ldap_memfree (hostdn);
1412
      ldap_msgfree (hostres);
1413
      ldap_stop();
1414
      return (ISC_R_FAILURE);
1415
    }
1416
1417
#if defined(DEBUG_LDAP)
1418
  log_info ("LDAP: Parsing dhcpServer options '%s' ...", hostdn);
1419
#endif
1420
1421
  cfile->inbuf[0] = '\0';
1422
  ldap_parse_entry_options(hostent, cfile->inbuf, LDAP_BUFFER_SIZE, NULL);
1423
  cfile->buflen = strlen (cfile->inbuf);
1424
  if(cfile->buflen > 0)
1425
    {
1426
      ldap_write_debug (cfile->inbuf, cfile->buflen);
1427
1428
      res = conf_file_subparse (cfile, root_group, ROOT_GROUP);
1429
      if (res != ISC_R_SUCCESS)
1430
        {
1431
          log_error ("LDAP: cannot parse dhcpServer entry '%s'", hostdn);
1432
          ldap_memfree (hostdn);
1433
          ldap_stop();
1434
          return res;
1435
        }
1436
      cfile->inbuf[0] = '\0';
1437
    }
1438
  ldap_msgfree (hostres);
1439
1440
  /*
1441
  ** attach ldap (tree) read function now
1442
  */
1443
  cfile->bufix = cfile->buflen = 0;
1444
  cfile->read_function = ldap_read_function;
1445
1446
  res = ISC_R_SUCCESS;
1447
  for (cnt=0; tempstr[cnt] != NULL; cnt++)
1448
    {
1449
      snprintf(sfilter, sizeof(sfilter), "(&(objectClass=dhcpService)"
1450
                        "(|(dhcpPrimaryDN=%s)(dhcpSecondaryDN=%s)))",
1451
                        hostdn, hostdn);
1452
      ldres = NULL;
1453
      if ((ret = ldap_search_s (ld, tempstr[cnt], LDAP_SCOPE_BASE,
1454
                                sfilter, NULL, 0, &ldres)) != LDAP_SUCCESS)
1455
        {
1456
          log_error ("Error searching for dhcpServiceDN '%s': %s. Please update the LDAP entry '%s'",
1457
                     tempstr[cnt], ldap_err2string (ret), hostdn);
1458
          if(NULL != ldres)
1459
            ldap_msgfree(ldres);
1460
          res = ISC_R_FAILURE;
1461
          break;
1462
        }
1463
1464
      if ((ent = ldap_first_entry (ld, ldres)) == NULL)
1465
        {
1466
          log_error ("Error: Cannot find dhcpService DN '%s' with primary or secondary server reference. Please update the LDAP server entry '%s'",
1467
                     tempstr[cnt], hostdn);
1468
1469
          ldap_msgfree(ldres);
1470
          res = ISC_R_FAILURE;
1471
          break;
1472
        }
1473
1474
      /*
1475
      ** FIXME: how to free the remembered dn's on exit?
1476
      **        This should be OK if dmalloc registers the
1477
      **        memory it allocated and frees it on exit..
1478
      */
1479
1480
      curr = dmalloc (sizeof (*curr), MDL);
1481
      if (curr != NULL)
1482
        {
1483
          length = strlen (tempstr[cnt]);
1484
          curr->dn = dmalloc (length + 1, MDL);
1485
          if (curr->dn == NULL)
1486
            {
1487
              dfree (curr, MDL);
1488
              curr = NULL;
1489
            }
1490
          else
1491
            strcpy (curr->dn, tempstr[cnt]);
1492
        }
1493
1494
      if (curr != NULL)
1495
        {
1496
          curr->refs++;
1497
1498
          /* append to service-dn list */
1499
          if (ldap_service_dn_tail != NULL)
1500
            ldap_service_dn_tail->next = curr;
1501
          else
1502
            ldap_service_dn_head = curr;
1503
1504
          ldap_service_dn_tail = curr;
1505
        }
1506
      else
1507
        log_fatal ("no memory to remember ldap service dn");
1508
1509
#if defined (DEBUG_LDAP)
1510
      log_info ("LDAP: Parsing dhcpService DN '%s' ...", tempstr[cnt]);
1511
#endif
1512
      add_to_config_stack (ldres, ent);
1513
      res = conf_file_subparse (cfile, root_group, ROOT_GROUP);
1514
      if (res != ISC_R_SUCCESS)
1515
        {
1516
          log_error ("LDAP: cannot parse dhcpService entry '%s'", tempstr[cnt]);
1517
          break;
1518
        }
1519
    }
1520
1521
  end_parse (&cfile);
1522
  ldap_close_debug_fd();
1523
1524
  ldap_memfree (hostdn);
1525
  ldap_value_free (tempstr);
1526
1527
  if (res != ISC_R_SUCCESS)
1528
    {
1529
      struct ldap_config_stack *temp_stack;
1530
1531
      while ((curr = ldap_service_dn_head) != NULL)
1532
        {
1533
          ldap_service_dn_head = curr->next;
1534
          dfree (curr->dn, MDL);
1535
          dfree (curr, MDL);
1536
        }
1537
1538
      ldap_service_dn_tail = NULL;
1539
1540
      while ((temp_stack = ldap_stack) != NULL)
1541
        {
1542
          ldap_stack = temp_stack->next;
1543
          free_stack_entry (temp_stack);
1544
        }
1545
1546
      ldap_stop();
1547
    }
1548
1549
  /* Unbind from ldap immediately after reading config in static mode. */
1550
  if (ldap_method == LDAP_METHOD_STATIC)
1551
    ldap_stop();
1552
1553
  return (res);
1554
}
1555
1556
1557
/* This function will parse the dhcpOption and dhcpStatements field in the LDAP
1558
   entry if it exists. Right now, type will be either HOST_DECL or CLASS_DECL.
1559
   If we are parsing a HOST_DECL, this always returns 0. If we are parsing a 
1560
   CLASS_DECL, this will return what the current lease limit is in LDAP. If
1561
   there is no lease limit specified, we return 0 */
1562
1563
static int
1564
ldap_parse_options (LDAPMessage * ent, struct group *group,
1565
                         int type, struct host_decl *host,
1566
                         struct class **class)
1567
{
1568
  int i, declaration, lease_limit;
1569
  char option_buffer[8192];
1570
  enum dhcp_token token;
1571
  struct parse *cfile;
1572
  isc_result_t res;
1573
  const char *val;
1574
1575
  lease_limit = 0;
1576
  *option_buffer = '\0';
1577
 
1578
 /* This block of code will try to find the parent of the host, and
1579
    if it is a group object, fetch the options and apply to the host. */
1580
  if (type == HOST_DECL) 
1581
    {
1582
      char *hostdn, *basedn, *temp1, *temp2, filter[1024];
1583
      LDAPMessage *groupdn, *entry;
1584
      int ret;
1585
1586
      hostdn = ldap_get_dn (ld, ent);
1587
      if( hostdn != NULL)
1588
        {
1589
          basedn = NULL;
1590
1591
          temp1 = strchr (hostdn, '=');
1592
          if (temp1 != NULL)
1593
            temp1 = strchr (++temp1, '=');
1594
          if (temp1 != NULL)
1595
            temp2 = strchr (++temp1, ',');
1596
          else
1597
            temp2 = NULL;
1598
1599
          if (temp2 != NULL)
1600
            {
1601
              snprintf (filter, sizeof(filter),
1602
                        "(&(cn=%.*s)(objectClass=dhcpGroup))",
1603
                        (int)(temp2 - temp1), temp1);
1604
1605
              basedn = strchr (temp1, ',');
1606
              if (basedn != NULL)
1607
                ++basedn;
1608
            }
1609
1610
          if (basedn != NULL && *basedn != '\0')
1611
            {
1612
              ret = ldap_search_s (ld, basedn, LDAP_SCOPE_SUBTREE,
1613
                                   filter, NULL, 0, &groupdn);
1614
              if (ret == LDAP_SUCCESS)
1615
                {
1616
                  if ((entry = ldap_first_entry (ld, groupdn)) != NULL)
1617
                    {
1618
                      res = ldap_parse_entry_options (entry, option_buffer,
1619
                                                      sizeof(option_buffer) - 1,
1620
                                                      &lease_limit);
1621
                      if (res != ISC_R_SUCCESS)
1622
                        {
1623
                          /* reset option buffer discarding any results */
1624
                          *option_buffer = '\0';
1625
                          lease_limit = 0;
1626
                        }
1627
                    }
1628
                  ldap_msgfree( groupdn);
1629
                }
1630
            }
1631
          ldap_memfree( hostdn);
1632
        }
1633
    }
1634
1635
  res = ldap_parse_entry_options (ent, option_buffer, sizeof(option_buffer) - 1,
1636
                                  &lease_limit);
1637
  if (res != ISC_R_SUCCESS)
1638
    return (lease_limit);
1639
1640
  option_buffer[sizeof(option_buffer) - 1] = '\0';
1641
  if (*option_buffer == '\0')
1642
    return (lease_limit);
1643
1644
  cfile = (struct parse *) NULL;
1645
  res = new_parse (&cfile, -1, option_buffer, strlen (option_buffer), 
1646
                   type == HOST_DECL ? "LDAP-HOST" : "LDAP-SUBCLASS", 0);
1647
  if (res != ISC_R_SUCCESS)
1648
    return (lease_limit);
1649
1650
#if defined (DEBUG_LDAP)
1651
  log_info ("Sending the following options: '%s'", option_buffer);
1652
#endif
1653
1654
  declaration = 0;
1655
  do
1656
    {
1657
      token = peek_token (&val, NULL, cfile);
1658
      if (token == END_OF_FILE)
1659
        break;
1660
       declaration = parse_statement (cfile, group, type, host, declaration);
1661
    } while (1);
1662
1663
  end_parse (&cfile);
1664
1665
  return (lease_limit);
1666
}
1667
1668
1669
1670
int
1671
find_haddr_in_ldap (struct host_decl **hp, int htype, unsigned hlen,
1672
                    const unsigned char *haddr, const char *file, int line)
1673
{
1674
  char buf[128], *type_str, **tempstr, *addr_str;
1675
  LDAPMessage * res, *ent;
1676
  struct host_decl * host;
1677
  isc_result_t status;
1678
  ldap_dn_node *curr;
1679
  int ret;
1680
1681
  if (ldap_method == LDAP_METHOD_STATIC)
1682
    return (0);
1683
1684
  if (ld == NULL)
1685
    ldap_start ();
1686
  if (ld == NULL)
1687
    return (0);
1688
1689
  switch (htype)
1690
    {
1691
      case HTYPE_ETHER:
1692
        type_str = "ethernet";
1693
        break;
1694
      case HTYPE_IEEE802:
1695
        type_str = "token-ring";
1696
        break;
1697
      case HTYPE_FDDI:
1698
        type_str = "fddi";
1699
        break;
1700
      default:
1701
        log_info ("Ignoring unknown type %d", htype);
1702
        return (0);
1703
    }
1704
1705
  /*
1706
  ** FIXME: It is not guaranteed, that the dhcpHWAddress attribute
1707
  **        contains _exactly_ "type addr" with one space between!
1708
  */
1709
  snprintf (buf, sizeof (buf),
1710
            "(&(objectClass=dhcpHost)(dhcpHWAddress=%s %s))",
1711
           type_str, print_hw_addr (htype, hlen, haddr));
1712
1713
  res = ent = NULL;
1714
  for (curr = ldap_service_dn_head;
1715
       curr != NULL && *curr->dn != '\0';
1716
       curr = curr->next)
1717
    {
1718
#if defined (DEBUG_LDAP)
1719
      log_info ("Searching for %s in LDAP tree %s", buf, curr->dn);
1720
#endif
1721
      ret = ldap_search_s (ld, curr->dn, LDAP_SCOPE_SUBTREE,
1722
                           buf, NULL, 0, &res);
1723
1724
      if(ret == LDAP_SERVER_DOWN)
1725
        {
1726
          log_info ("LDAP server was down, trying to reconnect...");
1727
1728
          ldap_stop();
1729
          ldap_start();
1730
          if(ld == NULL)
1731
            {
1732
              log_info ("LDAP reconnect failed - try again later...");
1733
              return (0);
1734
            }
1735
1736
          ret = ldap_search_s (ld, curr->dn, LDAP_SCOPE_SUBTREE,
1737
                               buf, NULL, 0, &res);
1738
        }
1739
1740
      if (ret == LDAP_SUCCESS)
1741
        {
1742
          if( (ent = ldap_first_entry (ld, res)) != NULL)
1743
            break; /* search OK and have entry */
1744
1745
#if defined (DEBUG_LDAP)
1746
          log_info ("No host entry for %s in LDAP tree %s",
1747
                    buf, curr->dn);
1748
#endif
1749
          if(res)
1750
            {
1751
              ldap_msgfree (res);
1752
              res = NULL;
1753
            }
1754
        }
1755
      else
1756
        {
1757
          if(res)
1758
            {
1759
              ldap_msgfree (res);
1760
              res = NULL;
1761
            }
1762
1763
          if (ret != LDAP_NO_SUCH_OBJECT && ret != LDAP_SUCCESS)
1764
            {
1765
              log_error ("Cannot search for %s in LDAP tree %s: %s", buf, 
1766
                         curr->dn, ldap_err2string (ret));
1767
              ldap_stop();
1768
              return (0);
1769
            }
1770
#if defined (DEBUG_LDAP)
1771
          else
1772
            {
1773
              log_info ("ldap_search_s returned %s when searching for %s in %s",
1774
                        ldap_err2string (ret), buf, curr->dn);
1775
            }
1776
#endif
1777
        }
1778
    }
1779
1780
  if (res && ent)
1781
    {
1782
#if defined (DEBUG_LDAP)
1783
      char *dn = ldap_get_dn (ld, ent);
1784
      if (dn != NULL)
1785
        {
1786
          log_info ("Found dhcpHWAddress LDAP entry %s", dn);
1787
          ldap_memfree(dn);
1788
        }
1789
#endif
1790
1791
      host = (struct host_decl *)0;
1792
      status = host_allocate (&host, MDL);
1793
      if (status != ISC_R_SUCCESS)
1794
        {
1795
          log_fatal ("can't allocate host decl struct: %s", 
1796
                     isc_result_totext (status)); 
1797
          ldap_msgfree (res);
1798
          return (0);
1799
        }
1800
1801
      host->name = ldap_get_host_name (ent);
1802
      if (host->name == NULL)
1803
        {
1804
          host_dereference (&host, MDL);
1805
          ldap_msgfree (res);
1806
          return (0);
1807
        }
1808
1809
      if (!clone_group (&host->group, root_group, MDL))
1810
        {
1811
          log_fatal ("can't clone group for host %s", host->name);
1812
          host_dereference (&host, MDL);
1813
          ldap_msgfree (res);
1814
          return (0);
1815
        }
1816
1817
      ldap_parse_options (ent, host->group, HOST_DECL, host, NULL);
1818
1819
      *hp = host;
1820
      ldap_msgfree (res);
1821
      return (1);
1822
    }
1823
1824
1825
  if(res) ldap_msgfree (res);
1826
  return (0);
1827
}
1828
1829
1830
int
1831
find_subclass_in_ldap (struct class *class, struct class **newclass, 
1832
                       struct data_string *data)
1833
{
1834
  LDAPMessage * res, * ent;
1835
  int i, ret, lease_limit;
1836
  isc_result_t status;
1837
  ldap_dn_node *curr;
1838
  char buf[1024];
1839
1840
  if (ldap_method == LDAP_METHOD_STATIC)
1841
    return (0);
1842
1843
  if (ld == NULL)
1844
    ldap_start ();
1845
  if (ld == NULL)
1846
    return (0);
1847
1848
  snprintf (buf, sizeof (buf),
1849
            "(&(objectClass=dhcpSubClass)(cn=%s)(dhcpClassData=%s))",
1850
            print_hex_1 (data->len, data->data, 60),
1851
            print_hex_2 (strlen (class->name), class->name, 60));
1852
#if defined (DEBUG_LDAP)
1853
  log_info ("Searching LDAP for %s", buf);
1854
#endif
1855
1856
  res = ent = NULL;
1857
  for (curr = ldap_service_dn_head;
1858
       curr != NULL && *curr->dn != '\0';
1859
       curr = curr->next)
1860
    {
1861
#if defined (DEBUG_LDAP)
1862
      log_info ("Searching for %s in LDAP tree %s", buf, curr->dn);
1863
#endif
1864
      ret = ldap_search_s (ld, curr->dn, LDAP_SCOPE_SUBTREE,
1865
                           buf, NULL, 0, &res);
1866
1867
      if(ret == LDAP_SERVER_DOWN)
1868
        {
1869
          log_info ("LDAP server was down, trying to reconnect...");
1870
1871
          ldap_stop();
1872
          ldap_start();
1873
1874
          if(ld == NULL)
1875
            {
1876
              log_info ("LDAP reconnect failed - try again later...");
1877
              return (0);
1878
            }
1879
1880
          ret = ldap_search_s (ld, curr->dn, LDAP_SCOPE_SUBTREE,
1881
                               buf, NULL, 0, &res);
1882
        }
1883
1884
      if (ret == LDAP_SUCCESS)
1885
        {
1886
          if( (ent = ldap_first_entry (ld, res)) != NULL)
1887
            break; /* search OK and have entry */
1888
1889
#if defined (DEBUG_LDAP)
1890
          log_info ("No subclass entry for %s in LDAP tree %s",
1891
                    buf, curr->dn);
1892
#endif
1893
          if(res)
1894
            {
1895
              ldap_msgfree (res);
1896
              res = NULL;
1897
            }
1898
        }
1899
      else
1900
        {
1901
          if(res)
1902
            {
1903
              ldap_msgfree (res);
1904
              res = NULL;
1905
            }
1906
1907
          if (ret != LDAP_NO_SUCH_OBJECT && ret != LDAP_SUCCESS)
1908
            {
1909
              log_error ("Cannot search for %s in LDAP tree %s: %s", buf, 
1910
                         curr->dn, ldap_err2string (ret));
1911
              ldap_stop();
1912
              return (0);
1913
            }
1914
#if defined (DEBUG_LDAP)
1915
          else
1916
            {
1917
              log_info ("ldap_search_s returned %s when searching for %s in %s",
1918
                        ldap_err2string (ret), buf, curr->dn);
1919
            }
1920
#endif
1921
        }
1922
    }
1923
1924
  if (res && ent)
1925
    {
1926
#if defined (DEBUG_LDAP)
1927
      char *dn = ldap_get_dn (ld, ent);
1928
      if (dn != NULL)
1929
        {
1930
          log_info ("Found subclass LDAP entry %s", dn);
1931
          ldap_memfree(dn);
1932
        }
1933
#endif
1934
1935
      status = class_allocate (newclass, MDL);
1936
      if (status != ISC_R_SUCCESS)
1937
        {
1938
          log_error ("Cannot allocate memory for a new class");
1939
          ldap_msgfree (res);
1940
          return (0);
1941
        }
1942
1943
      group_reference (&(*newclass)->group, class->group, MDL);
1944
      class_reference (&(*newclass)->superclass, class, MDL);
1945
      lease_limit = ldap_parse_options (ent, (*newclass)->group, 
1946
                                        CLASS_DECL, NULL, newclass);
1947
      if (lease_limit == 0)
1948
        (*newclass)->lease_limit = class->lease_limit; 
1949
      else
1950
        class->lease_limit = lease_limit;
1951
1952
      if ((*newclass)->lease_limit) 
1953
        {
1954
          (*newclass)->billed_leases = 
1955
              dmalloc ((*newclass)->lease_limit * sizeof (struct lease *), MDL);
1956
          if (!(*newclass)->billed_leases) 
1957
            {
1958
              log_error ("no memory for billing");
1959
              class_dereference (newclass, MDL);
1960
              ldap_msgfree (res);
1961
              return (0);
1962
            }
1963
          memset ((*newclass)->billed_leases, 0, 
1964
                ((*newclass)->lease_limit * sizeof (*newclass)->billed_leases));
1965
        }
1966
1967
      data_string_copy (&(*newclass)->hash_string, data, MDL);
1968
1969
      ldap_msgfree (res);
1970
      return (1);
1971
    }
1972
1973
  if(res) ldap_msgfree (res);
1974
  return (0);
1975
}
1976
1977
#endif
(-)dhcp-3.0.5/server/ldap_casa.c (+138 lines)
Line 0 Link Here
1
/* ldap_casa.c
2
   
3
   CASA routines for DHCPD... */
4
5
/* Copyright (c) 2004 Internet Systems Consorium, Inc. ("ISC")
6
 * Copyright (c) 1995-2003 Internet Software Consortium.
7
 * Copyright (c) 2006 Novell, Inc.
8
9
 * All rights reserved.
10
 * Redistribution and use in source and binary forms, with or without 
11
 * modification, are permitted provided that the following conditions are met: 
12
 * 1.Redistributions of source code must retain the above copyright notice, 
13
 *   this list of conditions and the following disclaimer. 
14
 * 2.Redistributions in binary form must reproduce the above copyright notice, 
15
 *   this list of conditions and the following disclaimer in the documentation 
16
 *   and/or other materials provided with the distribution. 
17
 * 3.Neither the name of ISC, ISC DHCP, nor the names of its contributors 
18
 *   may be used to endorse or promote products derived from this software 
19
 *   without specific prior written permission. 
20
21
 * THIS SOFTWARE IS PROVIDED BY INTERNET SYSTEMS CONSORTIUM AND CONTRIBUTORS 
22
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
24
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ISC OR CONTRIBUTORS BE LIABLE 
25
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
26
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
27
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
28
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
29
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
30
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
31
 * POSSIBILITY OF SUCH DAMAGE.
32
33
 * This file was written by S Kalyanasundaram <skalyanasundaram@novell.com>
34
 */
35
36
#if defined(LDAP_CASA_AUTH)
37
#include "ldap_casa.h"
38
#include "dhcpd.h"
39
40
int
41
load_casa (void)
42
{
43
       if( !(casaIDK = dlopen(MICASA_LIB,RTLD_LAZY)))
44
       	  return 0;
45
       p_miCASAGetCredential = (CASA_GetCredential_T) dlsym(casaIDK, "miCASAGetCredential");
46
       p_miCASASetCredential = (CASA_SetCredential_T) dlsym(casaIDK, "miCASASetCredential");
47
       p_miCASARemoveCredential = (CASA_RemoveCredential_T) dlsym(casaIDK, "miCASARemoveCredential");
48
49
       if((p_miCASAGetCredential == NULL) ||
50
         (p_miCASASetCredential == NULL) ||
51
         (p_miCASARemoveCredential == NULL))
52
       {
53
          if(casaIDK)
54
            dlclose(casaIDK);
55
          casaIDK = NULL;
56
          p_miCASAGetCredential = NULL;
57
          p_miCASASetCredential = NULL;
58
          p_miCASARemoveCredential = NULL;
59
          return 0;
60
       }
61
       else
62
          return 1;
63
}
64
65
static void
66
release_casa(void)
67
{
68
   if(casaIDK)
69
   {
70
      dlclose(casaIDK);
71
      casaIDK = NULL;
72
   }
73
74
   p_miCASAGetCredential = NULL;
75
   p_miCASASetCredential = NULL;
76
   p_miCASARemoveCredential = NULL;
77
78
}
79
80
int
81
load_uname_pwd_from_miCASA (char **ldap_username, char **ldap_password)
82
 {
83
   int                     result = 0;
84
   uint32_t                credentialtype = SSCS_CRED_TYPE_SERVER_F;
85
   SSCS_BASIC_CREDENTIAL   credential;
86
   SSCS_SECRET_ID_T        applicationSecretId;
87
   char                    *tempVar = NULL;
88
89
   const char applicationName[10] = "dhcp-ldap";
90
91
   if ( load_casa() )
92
   {
93
      memset(&credential, 0, sizeof(SSCS_BASIC_CREDENTIAL));
94
      memset(&applicationSecretId, 0, sizeof(SSCS_SECRET_ID_T));
95
96
      applicationSecretId.len = strlen(applicationName) + 1;
97
      memcpy (applicationSecretId.id, applicationName, applicationSecretId.len);
98
99
      credential.unFlags = USERNAME_TYPE_CN_F;
100
101
      result = p_miCASAGetCredential (0,
102
                 &applicationSecretId,NULL,&credentialtype,
103
                 &credential,NULL);
104
105
      if(credential.unLen)
106
      {
107
         tempVar = dmalloc (credential.unLen + 1, MDL);
108
         if (!tempVar)
109
             log_fatal ("no memory for ldap_username");
110
         memcpy(tempVar , credential.username, credential.unLen);
111
         *ldap_username = tempVar;
112
113
         tempVar = dmalloc (credential.pwordLen + 1, MDL);
114
         if (!tempVar)
115
             log_fatal ("no memory for ldap_password");
116
         memcpy(tempVar, credential.password, credential.pwordLen);
117
         *ldap_password = tempVar;
118
119
#if defined (DEBUG_LDAP)
120
         log_info ("Authentication credential taken from CASA");
121
#endif
122
123
         release_casa();
124
         return 1;
125
126
        }
127
        else
128
        {
129
            release_casa();
130
            return 0;
131
        }
132
      }
133
      else
134
          return 0; //casa libraries not loaded
135
 }
136
137
#endif /* LDAP_CASA_AUTH */
138
(-)dhcp-3.0.5/server/mdb.c (+6 lines)
Lines 375-380 Link Here
375
{
375
{
376
	struct host_decl *foo;
376
	struct host_decl *foo;
377
	struct hardware h;
377
	struct hardware h;
378
	int ret;
379
380
#if defined(LDAP_CONFIGURATION)
381
	if ((ret = find_haddr_in_ldap (hp, htype, hlen, haddr, file, line)))
382
		return ret;
383
#endif
378
384
379
	h.hlen = hlen + 1;
385
	h.hlen = hlen + 1;
380
	h.hbuf [0] = htype;
386
	h.hbuf [0] = htype;
(-)dhcp-3.0.5/server/stables.c (+88 lines)
Lines 483-488 Link Here
483
	{ "log-facility", "Nsyslog-facilities.",	&server_universe, 44 },
483
	{ "log-facility", "Nsyslog-facilities.",	&server_universe, 44 },
484
	{ "do-forward-updates", "f",			&server_universe, 45 },
484
	{ "do-forward-updates", "f",			&server_universe, 45 },
485
	{ "ping-timeout", "T",				&server_universe, 46 },
485
	{ "ping-timeout", "T",				&server_universe, 46 },
486
#if defined(LDAP_CONFIGURATION)
487
	{ "ldap-server", "t",				&server_universe, 47 },
488
	{ "ldap-port", "d",				&server_universe, 48 },
489
	{ "ldap-username", "t",				&server_universe, 49 },
490
	{ "ldap-password", "t",				&server_universe, 50 },
491
	{ "ldap-base-dn", "t",				&server_universe, 51 },
492
	{ "ldap-method", "Nldap-methods.",		&server_universe, 52 },
493
	{ "ldap-debug-file", "t",			&server_universe, 53 },
494
	{ "ldap-dhcp-server-cn", "t",			&server_universe, 54 },
495
	{ "ldap-referrals", "f",			&server_universe, 55 },
496
#if defined(USE_SSL)
497
	{ "ldap-ssl", "Nldap-ssl-usage.",		&server_universe, 56 },
498
	{ "ldap-tls-reqcert", "Nldap-tls-reqcert.",	&server_universe, 57 },
499
	{ "ldap-tls-ca-file", "t",			&server_universe, 58 },
500
	{ "ldap-tls-ca-dir", "t",			&server_universe, 59 },
501
	{ "ldap-tls-cert", "t",				&server_universe, 60 },
502
	{ "ldap-tls-key", "t",				&server_universe, 61 },
503
	{ "ldap-tls-crlcheck", "Nldap-tls-crlcheck.",	&server_universe, 62 },
504
	{ "ldap-tls-ciphers", "t",			&server_universe, 63 },
505
	{ "ldap-tls-randfile", "t",			&server_universe, 64 },
506
#else
507
	{ "unknown-56", "X",				&server_universe, 56 },
508
	{ "unknown-57", "X",				&server_universe, 57 },
509
	{ "unknown-58", "X",				&server_universe, 58 },
510
	{ "unknown-59", "X",				&server_universe, 59 },
511
	{ "unknown-60", "X",				&server_universe, 60 },
512
	{ "unknown-61", "X",				&server_universe, 61 },
513
	{ "unknown-62", "X",				&server_universe, 62 },
514
	{ "unknown-63", "X",				&server_universe, 63 },
515
	{ "unknown-64", "X",				&server_universe, 64 },
516
#endif
517
#else
486
	{ "unknown-47", "X",				&server_universe, 47 },
518
	{ "unknown-47", "X",				&server_universe, 47 },
487
	{ "unknown-48", "X",				&server_universe, 48 },
519
	{ "unknown-48", "X",				&server_universe, 48 },
488
	{ "unknown-49", "X",				&server_universe, 49 },
520
	{ "unknown-49", "X",				&server_universe, 49 },
Lines 501-506 Link Here
501
	{ "unknown-62", "X",				&server_universe, 62 },
533
	{ "unknown-62", "X",				&server_universe, 62 },
502
	{ "unknown-63", "X",				&server_universe, 63 },
534
	{ "unknown-63", "X",				&server_universe, 63 },
503
	{ "unknown-64", "X",				&server_universe, 64 },
535
	{ "unknown-64", "X",				&server_universe, 64 },
536
#endif
504
	{ "unknown-65", "X",				&server_universe, 65 },
537
	{ "unknown-65", "X",				&server_universe, 65 },
505
	{ "unknown-66", "X",				&server_universe, 66 },
538
	{ "unknown-66", "X",				&server_universe, 66 },
506
	{ "unknown-67", "X",				&server_universe, 67 },
539
	{ "unknown-67", "X",				&server_universe, 67 },
Lines 694-699 Link Here
694
	{ "option-end", "e",				&server_universe, 255 },
727
	{ "option-end", "e",				&server_universe, 255 },
695
};
728
};
696
729
730
#if defined(LDAP_CONFIGURATION)
731
struct enumeration_value ldap_values [] = {
732
	{ "static", LDAP_METHOD_STATIC },
733
	{ "dynamic", LDAP_METHOD_DYNAMIC },
734
	{ (char *) 0, 0 }
735
};
736
737
struct enumeration ldap_methods = {
738
	(struct enumeration *)0,
739
	"ldap-methods",
740
	ldap_values
741
};
742
743
#if defined(USE_SSL)
744
struct enumeration_value ldap_ssl_usage_values [] = {
745
	{ "off",       LDAP_SSL_OFF  },
746
	{ "on",        LDAP_SSL_ON   },
747
	{ "ldaps",     LDAP_SSL_LDAPS},
748
	{ "start_tls", LDAP_SSL_TLS  },
749
	{ (char *) 0, 0 }
750
};
751
struct enumeration ldap_ssl_usage_enum = {
752
	(struct enumeration *)0,
753
	"ldap-ssl-usage",
754
	ldap_ssl_usage_values
755
};
756
757
struct enumeration_value ldap_tls_reqcert_values [] = {
758
	{ "never",  LDAP_OPT_X_TLS_NEVER },
759
	{ "hard",   LDAP_OPT_X_TLS_HARD  },
760
	{ "demand", LDAP_OPT_X_TLS_DEMAND},
761
	{ "allow",  LDAP_OPT_X_TLS_ALLOW },
762
	{ "try",    LDAP_OPT_X_TLS_TRY   },
763
	{ (char *) 0, 0 }
764
};
765
struct enumeration ldap_tls_reqcert_enum = {
766
	(struct enumeration *)0,
767
	"ldap-tls-reqcert",
768
	ldap_tls_reqcert_values
769
};
770
771
struct enumeration_value ldap_tls_crlcheck_values [] = {
772
	{ "none", LDAP_OPT_X_TLS_CRL_NONE},
773
	{ "peer", LDAP_OPT_X_TLS_CRL_PEER},
774
	{ "all",  LDAP_OPT_X_TLS_CRL_ALL },
775
	{ (char *) 0, 0 }
776
};
777
struct enumeration ldap_tls_crlcheck_enum = {
778
	(struct enumeration *)0,
779
	"ldap-tls-crlcheck",
780
	ldap_tls_crlcheck_values
781
};
782
#endif
783
#endif
784
697
struct enumeration_value ddns_styles_values [] = {
785
struct enumeration_value ddns_styles_values [] = {
698
	{ "none", 0 },
786
	{ "none", 0 },
699
	{ "ad-hoc", 1 },
787
	{ "ad-hoc", 1 },
(-)dhcp-3.0.5/site.conf (+1 lines)
Lines 1-2 Link Here
1
# Put local site configuration stuff here to override the default
1
# Put local site configuration stuff here to override the default
2
# settings in Makefile.conf
2
# settings in Makefile.conf
3
#COPTS = -DDEBUG_LDAP -DLDAP_CASA_AUTH -DDEBUG_CLASS_MATCHING -Wall -O -Wno-unused

Return to bug 160979