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.3.1.orig/client/dhc6.c (-1 / +2 lines)
Lines 4902-4908 Link Here
4902
	 */
4902
	 */
4903
	if ((oc = lookup_option(&dhcpv6_universe, *op,
4903
	if ((oc = lookup_option(&dhcpv6_universe, *op,
4904
				D6O_CLIENTID)) == NULL) {
4904
				D6O_CLIENTID)) == NULL) {
4905
		if (!option_cache(&oc, &default_duid, NULL, clientid_option,
4905
		if (default_duid.len == 0 ||
4906
		    !option_cache(&oc, &default_duid, NULL, clientid_option,
4906
				  MDL))
4907
				  MDL))
4907
			log_fatal("Failure assembling a DUID.");
4908
			log_fatal("Failure assembling a DUID.");
4908
4909
(-)dhcp-4.3.1.orig/client/dhclient.c (-3 / +44 lines)
Lines 602-609 Link Here
602
			if (default_duid.buffer != NULL)
602
			if (default_duid.buffer != NULL)
603
				data_string_forget(&default_duid, MDL);
603
				data_string_forget(&default_duid, MDL);
604
604
605
			form_duid(&default_duid, MDL);
605
			if (form_duid(&default_duid, MDL) == ISC_R_SUCCESS)
606
			write_duid(&default_duid);
606
				write_duid(&default_duid);
607
		}
607
		}
608
	}
608
	}
609
609
Lines 2901-2919 Link Here
2901
 * is not how it is intended.  Upcoming rearchitecting the client should
2901
 * is not how it is intended.  Upcoming rearchitecting the client should
2902
 * address this "one daemon model."
2902
 * address this "one daemon model."
2903
 */
2903
 */
2904
void
2904
isc_result_t
2905
form_duid(struct data_string *duid, const char *file, int line)
2905
form_duid(struct data_string *duid, const char *file, int line)
2906
{
2906
{
2907
	struct interface_info *ip;
2907
	struct interface_info *ip;
2908
	int len;
2908
	int len;
2909
	char *str;
2909
	char *str;
2910
	int fd;
2911
	int flag;
2910
2912
2911
	/* For now, just use the first interface on the list. */
2913
	/* For now, just use the first interface on the list. */
2912
	ip = interfaces;
2914
	ip = interfaces;
2915
	flag = 0;
2913
2916
2914
	if (ip == NULL)
2917
	if (ip == NULL)
2915
		log_fatal("Impossible condition at %s:%d.", MDL);
2918
		log_fatal("Impossible condition at %s:%d.", MDL);
2916
2919
2920
	while (ip && ip->hw_address.hbuf[0] == HTYPE_RESERVED) {
2921
		fd = open("/dev/urandom", O_RDONLY);
2922
		if (fd != -1) {
2923
			if(read(fd, ip->hw_address.hbuf + 1, 6) == 6) {
2924
				ip->hw_address.hbuf[0] = HTYPE_ETHER;
2925
				ip->hw_address.hlen = 7;
2926
				close(fd);
2927
				flag = 1;
2928
				break;
2929
			}
2930
			close(fd);
2931
		}
2932
		if (!ip->hw_address.hlen && ip->v6address_count) {
2933
			ip->hw_address.hbuf[0] = HTYPE_ETHER;
2934
			ip->hw_address.hlen = 7;
2935
			memcpy(ip->hw_address.hbuf + 1,
2936
				ip->v6addresses[0].s6_addr, 6);
2937
			for(len = 0 ; len < 10 ; len ++) {
2938
				fd = len % 6;
2939
				ip->hw_address.hbuf[fd + 1] ^=
2940
					ip->v6addresses[0].s6_addr[len + 6];
2941
			}
2942
			flag = 1;
2943
			break;
2944
		}
2945
		/* Try the other interfaces */
2946
		log_debug("Cannot form default DUID from interface %s.", ip->name);
2947
		ip = ip->next;
2948
	}
2949
	if (ip == NULL) {
2950
		return ISC_R_UNEXPECTED;
2951
	}
2952
2917
	if ((ip->hw_address.hlen == 0) ||
2953
	if ((ip->hw_address.hlen == 0) ||
2918
	    (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
2954
	    (ip->hw_address.hlen > sizeof(ip->hw_address.hbuf)))
2919
		log_fatal("Impossible hardware address length at %s:%d.", MDL);
2955
		log_fatal("Impossible hardware address length at %s:%d.", MDL);
Lines 2950-2955 Link Here
2950
		       ip->hw_address.hlen - 1);
2986
		       ip->hw_address.hlen - 1);
2951
	}
2987
	}
2952
2988
2989
	if (flag)
2990
		memset(ip->hw_address.hbuf, 0, 7);
2991
2953
	str = quotify_buf(duid->data, duid->len, MDL);
2992
	str = quotify_buf(duid->data, duid->len, MDL);
2954
	if (str == NULL)
2993
	if (str == NULL)
2955
		log_info("Created duid.");
2994
		log_info("Created duid.");
Lines 2957-2962 Link Here
2957
		log_info("Created duid %s.", str);
2996
		log_info("Created duid %s.", str);
2958
		dfree(str, MDL);
2997
		dfree(str, MDL);
2959
	}
2998
	}
2999
3000
	return ISC_R_SUCCESS;
2960
}
3001
}
2961
3002
2962
/* Write the default DUID to the lease store. */
3003
/* Write the default DUID to the lease store. */
(-)dhcp-4.3.1.orig/common/bpf.c (+16 lines)
Lines 600-605 Link Here
600
                        memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
600
                        memcpy(&hw->hbuf[1], LLADDR(sa), sa->sdl_alen);
601
                        break;
601
                        break;
602
#endif /* IFT_FDDI */
602
#endif /* IFT_FDDI */
603
#if defined(IFT_PPP)
604
		case IFT_PPP:
605
			if (local_family != AF_INET6)
606
				log_fatal("Unsupported device type %d for \"%s\"",
607
					sa->sdl_type, name);
608
			hw->hlen = 0;
609
			hw->hbuf[0] = HTYPE_RESERVED;
610
			/* 0xdeadbeef should never occur on the wire, and is a signature that
611
			 * something went wrong.
612
			 */
613
			hw->hbuf[1] = 0xde;
614
			hw->hbuf[2] = 0xad;
615
			hw->hbuf[3] = 0xbe;
616
			hw->hbuf[4] = 0xef;
617
			break;
618
#endif
603
                default:
619
                default:
604
                        log_fatal("Unsupported device type %d for \"%s\"",
620
                        log_fatal("Unsupported device type %d for \"%s\"",
605
                                  sa->sdl_type, name);
621
                                  sa->sdl_type, name);
(-)dhcp-4.3.1.orig/common/lpf.c (+16 lines)
Lines 468-473 Link Here
468
			hw->hbuf[0] = HTYPE_FDDI;
468
			hw->hbuf[0] = HTYPE_FDDI;
469
			memcpy(&hw->hbuf[1], sa->sa_data, 6);
469
			memcpy(&hw->hbuf[1], sa->sa_data, 6);
470
			break;
470
			break;
471
#if defined(ARPHRD_PPP)
472
		case ARPHRD_PPP:
473
			if (local_family != AF_INET6)
474
				log_fatal("Unsupported device type %d for \"%s\"",
475
					sa->sa_family, name);
476
			hw->hlen = 0;
477
			hw->hbuf[0] = HTYPE_RESERVED;
478
			/* 0xdeadbeef should never occur on the wire, and is a signature that
479
			 * something went wrong.
480
			 */
481
			hw->hbuf[1] = 0xde;
482
			hw->hbuf[2] = 0xad;
483
			hw->hbuf[3] = 0xbe;
484
			hw->hbuf[4] = 0xef;
485
			break;
486
#endif
471
		default:
487
		default:
472
			log_fatal("Unsupported device type %ld for \"%s\"",
488
			log_fatal("Unsupported device type %ld for \"%s\"",
473
				  (long int)sa->sa_family, name);
489
				  (long int)sa->sa_family, name);
(-)dhcp-4.3.1.orig/includes/dhcp.h (+2 lines)
Lines 81-86 Link Here
81
					 * is no standard for this so we
81
					 * is no standard for this so we
82
					 * just steal a type            */
82
					 * just steal a type            */
83
83
84
#define HTYPE_RESERVED	0		/* RFC 5494 */
85
84
/* Magic cookie validating dhcp options field (and bootp vendor
86
/* Magic cookie validating dhcp options field (and bootp vendor
85
   extensions field). */
87
   extensions field). */
86
#define DHCP_OPTIONS_COOKIE	"\143\202\123\143"
88
#define DHCP_OPTIONS_COOKIE	"\143\202\123\143"
(-)dhcp-4.3.1.orig/includes/dhcpd.h (-1 / +1 lines)
Lines 2834-2840 Link Here
2834
2834
2835
void dhcpv4_client_assignments(void);
2835
void dhcpv4_client_assignments(void);
2836
void dhcpv6_client_assignments(void);
2836
void dhcpv6_client_assignments(void);
2837
void form_duid(struct data_string *duid, const char *file, int line);
2837
isc_result_t form_duid(struct data_string *duid, const char *file, int line);
2838
2838
2839
/* dhc6.c */
2839
/* dhc6.c */
2840
void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line);
2840
void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line);
(-)dhcp-4.3.1.orig/server/dhcpv6.c (+3 lines)
Lines 330-335 Link Here
330
		if (p->hw_address.hlen > 0) {
330
		if (p->hw_address.hlen > 0) {
331
			break;
331
			break;
332
		}
332
		}
333
		if (p->next == NULL && p->hw_address.hbuf[0] == HTYPE_RESERVED) {
334
			log_error("Can not generate DUID from interfaces which do not have hardware addresses, please configure server-duid!");
335
		}
333
	}
336
	}
334
	if (p == NULL) {
337
	if (p == NULL) {
335
		return ISC_R_UNEXPECTED;
338
		return ISC_R_UNEXPECTED;

Return to bug 432652