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

Collapse All | Expand All

(-)dhcp-4.2.4-P1.orig/client/dhc6.c (-2 / +42 lines)
Lines 131-148 Link Here
131
 * is not how it is intended.  Upcoming rearchitecting the client should
131
 * is not how it is intended.  Upcoming rearchitecting the client should
132
 * address this "one daemon model."
132
 * address this "one daemon model."
133
 */
133
 */
134
void
134
isc_result_t
135
form_duid(struct data_string *duid, const char *file, int line)
135
form_duid(struct data_string *duid, const char *file, int line)
136
{
136
{
137
	struct interface_info *ip;
137
	struct interface_info *ip;
138
	int len;
138
	int len;
139
	int fd;
140
	int flag;
139
141
140
	/* For now, just use the first interface on the list. */
142
	/* For now, just use the first interface on the list. */
141
	ip = interfaces;
143
	ip = interfaces;
144
	flag = 0;
142
145
143
	if (ip == NULL)
146
	if (ip == NULL)
144
		log_fatal("Impossible condition at %s:%d.", MDL);
147
		log_fatal("Impossible condition at %s:%d.", MDL);
145
148
149
	while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
150
		fd = open("/dev/urandom", O_RDONLY);
151
		if (fd != -1) {
152
			if(read(fd, ip->hw_address.hbuf + 1, 6) == 6) {
153
				ip->hw_address.hbuf[0] = HTYPE_ETHER;
154
				ip->hw_address.hlen = 7;
155
				close(fd);
156
				flag = 1;
157
				break;
158
			}
159
			close(fd);
160
		}
161
		if (!ip->hw_address.hlen && ip->v6address_count) {
162
			ip->hw_address.hbuf[0] = HTYPE_ETHER;
163
			ip->hw_address.hlen = 7;
164
			memcpy(ip->hw_address.hbuf + 1,
165
				ip->v6addresses[0].s6_addr, 6);
166
			for(len = 0 ; len < 10 ; len ++) {
167
				fd = len % 6;
168
				ip->hw_address.hbuf[fd + 1] ^=
169
					ip->v6addresses[0].s6_addr[len + 6];
170
			}
171
			flag = 1;
172
			break;
173
		}
174
		/* Try the other interfaces */
175
		log_debug("Cannot form default DUID from interface %s.", ip->name);
176
		ip = ip->next;
177
	}
178
	if (ip == NULL) {
179
		return ISC_R_UNEXPECTED;
180
	}
181
146
	if ((ip->hw_address.hlen == 0) ||
182
	if ((ip->hw_address.hlen == 0) ||
147
	    (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
183
	    (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
148
		log_fatal("Impossible hardware address length at %s:%d.", MDL);
184
		log_fatal("Impossible hardware address length at %s:%d.", MDL);
Lines 178-183 Link Here
178
		memcpy(duid->buffer->data + 4, ip->hw_address.hbuf + 1,
214
		memcpy(duid->buffer->data + 4, ip->hw_address.hbuf + 1,
179
		       ip->hw_address.hlen - 1);
215
		       ip->hw_address.hlen - 1);
180
	}
216
	}
217
	if (flag)
218
		memset(ip->hw_address.hbuf, 0, 7);
219
	return ISC_R_SUCCESS;
181
}
220
}
182
221
183
/*
222
/*
Lines 4945-4951 Link Here
4945
	 */
4984
	 */
4946
	if ((oc = lookup_option(&dhcpv6_universe, *op,
4985
	if ((oc = lookup_option(&dhcpv6_universe, *op,
4947
				D6O_CLIENTID)) == NULL) {
4986
				D6O_CLIENTID)) == NULL) {
4948
		if (!option_cache(&oc, &default_duid, NULL, clientid_option,
4987
		if (default_duid.len == 0 ||
4988
		    !option_cache(&oc, &default_duid, NULL, clientid_option,
4949
				  MDL))
4989
				  MDL))
4950
			log_fatal("Failure assembling a DUID.");
4990
			log_fatal("Failure assembling a DUID.");
4951
4991
(-)dhcp-4.2.4-P1.orig/client/dhclient.c (-2 / +2 lines)
Lines 573-580 Link Here
573
			if (default_duid.buffer != NULL)
573
			if (default_duid.buffer != NULL)
574
				data_string_forget(&default_duid, MDL);
574
				data_string_forget(&default_duid, MDL);
575
575
576
			form_duid(&default_duid, MDL);
576
			if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
577
			write_duid(&default_duid);
577
				write_duid(&default_duid);
578
		}
578
		}
579
579
580
		for (ip = interfaces ; ip != NULL ; ip = ip->next) {
580
		for (ip = interfaces ; ip != NULL ; ip = ip->next) {
(-)dhcp-4.2.4-P1.orig/common/bpf.c (+16 lines)
Lines 599-604 Link Here
599
                        memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
599
                        memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
600
                        break;
600
                        break;
601
#endif /* IFT_FDDI */
601
#endif /* IFT_FDDI */
602
#if defined(IFT_PPP)
603
                case IFT_PPP:
604
			if (local_family != AF_INET6)
605
				log_fatal("Unsupported device type %d for \"%s\"",
606
				           sa->sdl_type, name);
607
			hw->hlen = 0;
608
			hw->hbuf[0] = HTYPE_RESERVED;
609
			/* 0xdeadbeef should never occur on the wire, and is a signature that
610
			 * something went wrong.
611
			 */
612
			hw->hbuf[1] = 0xde;
613
			hw->hbuf[2] = 0xad;
614
			hw->hbuf[3] = 0xbe;
615
			hw->hbuf[4] = 0xef;
616
			break;
617
#endif
602
                default:
618
                default:
603
                        log_fatal("Unsupported device type %d for \"%s\"",
619
                        log_fatal("Unsupported device type %d for \"%s\"",
604
                                  sa->sdl_type, name);
620
                                  sa->sdl_type, name);
(-)dhcp-4.2.4-P1.orig/common/lpf.c (+16 lines)
Lines 460-465 Link Here
460
			hw->hbuf[0] = HTYPE_FDDI;
460
			hw->hbuf[0] = HTYPE_FDDI;
461
			memcpy(&hw->hbuf[1], sa->sa_data, 16);
461
			memcpy(&hw->hbuf[1], sa->sa_data, 16);
462
			break;
462
			break;
463
#if defined(ARPHRD_PPP)
464
                case ARPHRD_PPP:
465
			if (local_family != AF_INET6)
466
				log_fatal("Unsupported device type %d for \"%s\"",
467
				           sa->sa_family, name);
468
			hw->hlen = 0;
469
			hw->hbuf[0] = HTYPE_RESERVED;
470
			/* 0xdeadbeef should never occur on the wire, and is a signature that
471
			 * something went wrong.
472
			 */
473
			hw->hbuf[1] = 0xde;
474
			hw->hbuf[2] = 0xad;
475
			hw->hbuf[3] = 0xbe;
476
			hw->hbuf[4] = 0xef;
477
			break;
478
#endif
463
		default:
479
		default:
464
			log_fatal("Unsupported device type %ld for \"%s\"",
480
			log_fatal("Unsupported device type %ld for \"%s\"",
465
				  (long int)sa->sa_family, name);
481
				  (long int)sa->sa_family, name);
(-)dhcp-4.2.4-P1.orig/includes/dhcp.h (+2 lines)
Lines 85-90 Link Here
85
					 * is no standard for this so we
85
					 * is no standard for this so we
86
					 * just steal a type            */
86
					 * just steal a type            */
87
87
88
#define HTYPE_RESERVED  0               /* RFC 5494 */
89
88
/* Magic cookie validating dhcp options field (and bootp vendor
90
/* Magic cookie validating dhcp options field (and bootp vendor
89
   extensions field). */
91
   extensions field). */
90
#define DHCP_OPTIONS_COOKIE	"\143\202\123\143"
92
#define DHCP_OPTIONS_COOKIE	"\143\202\123\143"
(-)dhcp-4.2.4-P1.orig/includes/dhcpd.h (-1 / +1 lines)
Lines 2763-2769 Link Here
2763
void dhcpv6_client_assignments(void);
2763
void dhcpv6_client_assignments(void);
2764
2764
2765
/* dhc6.c */
2765
/* dhc6.c */
2766
void form_duid(struct data_string *duid, const char *file, int line);
2766
isc_result_t form_duid(struct data_string *duid, const char *file, int line);
2767
void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line);
2767
void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line);
2768
void start_init6(struct client_state *client);
2768
void start_init6(struct client_state *client);
2769
void start_info_request6(struct client_state *client);
2769
void start_info_request6(struct client_state *client);
(-)dhcp-4.2.4-P1.orig/server/dhcpv6.c (+3 lines)
Lines 300-305 Link Here
300
		if (p->hw_address.hlen > 0) {
300
		if (p->hw_address.hlen > 0) {
301
			break;
301
			break;
302
		}
302
		}
303
		if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
304
			log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
305
		}
303
	}
306
	}
304
	if (p == NULL) {
307
	if (p == NULL) {
305
		return ISC_R_UNEXPECTED;
308
		return ISC_R_UNEXPECTED;

Return to bug 432652