mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-30 22:05:23 +00:00
Pass flag to cons_options indicating whether this is BOOTP or DHCP. Change handling of dynamic BOOTP packets. Allow or deny booting based on vendor class if enabled.
This commit is contained in:
@@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
static char copyright[] =
|
||||||
"$Id: dhcp.c,v 1.50 1997/06/08 04:10:41 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
"$Id: dhcp.c,v 1.51 1997/09/16 18:20:30 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@@ -406,7 +406,7 @@ void nak_lease (packet, cip)
|
|||||||
|
|
||||||
/* Set up the option buffer... */
|
/* Set up the option buffer... */
|
||||||
outgoing.packet_length =
|
outgoing.packet_length =
|
||||||
cons_options (packet, outgoing.raw, options, 0, 0);
|
cons_options (packet, outgoing.raw, options, 0, 0, 0);
|
||||||
|
|
||||||
/* memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/
|
/* memset (&raw.ciaddr, 0, sizeof raw.ciaddr);*/
|
||||||
raw.siaddr = packet -> interface -> primary_address;
|
raw.siaddr = packet -> interface -> primary_address;
|
||||||
@@ -504,12 +504,6 @@ void ack_lease (packet, lease, offer, when)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate a lease state structure... */
|
|
||||||
state = new_lease_state ("ack_lease");
|
|
||||||
if (!state)
|
|
||||||
error ("unable to allocate lease state!");
|
|
||||||
memset (state, 0, sizeof *state);
|
|
||||||
|
|
||||||
if (packet -> options [DHO_DHCP_CLASS_IDENTIFIER].len) {
|
if (packet -> options [DHO_DHCP_CLASS_IDENTIFIER].len) {
|
||||||
vendor_class =
|
vendor_class =
|
||||||
find_class (0,
|
find_class (0,
|
||||||
@@ -532,6 +526,29 @@ void ack_lease (packet, lease, offer, when)
|
|||||||
user_class = (struct class *)0;
|
user_class = (struct class *)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there is not a specific host entry, and either the
|
||||||
|
* vendor class or user class (if they exist) deny booting,
|
||||||
|
* then bug out.
|
||||||
|
*/
|
||||||
|
if (!lease -> host) {
|
||||||
|
if (vendor_class && !vendor_class -> group -> allow_booting) {
|
||||||
|
debug ("Booting denied by vendor class");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_class && !user_class -> group -> allow_booting) {
|
||||||
|
debug ("Booting denied by user class");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate a lease state structure... */
|
||||||
|
state = new_lease_state ("ack_lease");
|
||||||
|
if (!state)
|
||||||
|
error ("unable to allocate lease state!");
|
||||||
|
memset (state, 0, sizeof *state);
|
||||||
|
|
||||||
/* Replace the old lease hostname with the new one, if it's changed. */
|
/* Replace the old lease hostname with the new one, if it's changed. */
|
||||||
if (packet -> options [DHO_HOST_NAME].len &&
|
if (packet -> options [DHO_HOST_NAME].len &&
|
||||||
lease -> client_hostname &&
|
lease -> client_hostname &&
|
||||||
@@ -917,6 +934,7 @@ void dhcp_reply (lease)
|
|||||||
int result;
|
int result;
|
||||||
int i;
|
int i;
|
||||||
struct lease_state *state = lease -> state;
|
struct lease_state *state = lease -> state;
|
||||||
|
int nulltp, bootpp;
|
||||||
|
|
||||||
if (!state)
|
if (!state)
|
||||||
error ("dhcp_reply was supplied lease with no state!");
|
error ("dhcp_reply was supplied lease with no state!");
|
||||||
@@ -946,11 +964,19 @@ void dhcp_reply (lease)
|
|||||||
/* See if this is a Microsoft client that NUL-terminates its
|
/* See if this is a Microsoft client that NUL-terminates its
|
||||||
strings and expects us to do likewise... */
|
strings and expects us to do likewise... */
|
||||||
if (lease -> flags & MS_NULL_TERMINATION)
|
if (lease -> flags & MS_NULL_TERMINATION)
|
||||||
packet_length = cons_options ((struct packet *)0,
|
nulltp = 1;
|
||||||
&raw, state -> options, bufs, 1);
|
|
||||||
else
|
else
|
||||||
packet_length = cons_options ((struct packet *)0,
|
nulltp = 0;
|
||||||
&raw, state -> options, bufs, 0);
|
|
||||||
|
/* See if this is a bootp client... */
|
||||||
|
if (state -> offer)
|
||||||
|
bootpp = 0;
|
||||||
|
else
|
||||||
|
bootpp = 1;
|
||||||
|
|
||||||
|
/* Insert such options as will fit into the buffer. */
|
||||||
|
packet_length = cons_options ((struct packet *)0, &raw,
|
||||||
|
state -> options, bufs, nulltp, bootpp);
|
||||||
|
|
||||||
/* Having done the cons_options(), we can release the tree_cache
|
/* Having done the cons_options(), we can release the tree_cache
|
||||||
entries. */
|
entries. */
|
||||||
@@ -1184,9 +1210,9 @@ struct lease *find_lease (packet, share, ours)
|
|||||||
a uid) we let the client get away with it. */
|
a uid) we let the client get away with it. */
|
||||||
if (hw_lease &&
|
if (hw_lease &&
|
||||||
hw_lease -> ends >= cur_time &&
|
hw_lease -> ends >= cur_time &&
|
||||||
hw_lease -> uid && hw_lease != uid_lease &&
|
hw_lease -> uid &&
|
||||||
(packet -> packet_type != 0 ||
|
packet -> options [DHO_DHCP_CLIENT_IDENTIFIER].len &&
|
||||||
!(hw_lease -> flags & DYNAMIC_BOOTP_OK)))
|
hw_lease != uid_lease)
|
||||||
hw_lease = (struct lease *)0;
|
hw_lease = (struct lease *)0;
|
||||||
|
|
||||||
/* Toss extra pointers to the same lease... */
|
/* Toss extra pointers to the same lease... */
|
||||||
|
Reference in New Issue
Block a user