1 # |
|
2 # This patch was devleloped in house. The changes have been fed |
|
3 # upstream and were merged into the-tcpdump-group/libpcap. This |
|
4 # was committed under 2f9790bd3cfe56c0f78d10953571dc4b34060e4f. |
|
5 # |
|
6 # libpcap-1.7.0 is the projected release which will include this |
|
7 # change. |
|
8 # |
|
9 --- libpcap-1.5.1/pcap-bpf.c 2014-08-14 16:14:46.837979600 +0100 |
|
10 +++ libpcap-1.5.1/pcap-bpf.c 2014-08-18 15:13:20.805460460 +0100 |
|
11 @@ -1539,22 +1539,43 @@ |
|
12 |
|
13 #if defined(LIFNAMSIZ) && defined(ZONENAME_MAX) && defined(lifr_zoneid) |
|
14 /* |
|
15 + * Retrieve the zoneid of the zone we are currently executing in. |
|
16 + */ |
|
17 + if ((ifr.lifr_zoneid = getzoneid()) == -1) { |
|
18 + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "getzoneid(): %s", |
|
19 + pcap_strerror(errno)); |
|
20 + status = PCAP_ERROR; |
|
21 + goto bad; |
|
22 + } |
|
23 + /* |
|
24 * Check if the given source network device has a '/' separated |
|
25 - * zonename prefix string. The zonename prefixed source device |
|
26 - * can be used by libpcap consumers to capture network traffic |
|
27 - * in non-global zones from the global zone on Solaris 11 and |
|
28 - * above. If the zonename prefix is present then we strip the |
|
29 - * prefix and pass the zone ID as part of lifr_zoneid. |
|
30 + * zonename prefix string. The zonename prefixed source device can |
|
31 + * be used by pcap consumers in the Solaris global zone to capture |
|
32 + * traffic on datalinks in non-global zones. Non-global zones |
|
33 + * do not have access to datalinks outside of their own namespace. |
|
34 */ |
|
35 if ((zonesep = strchr(p->opt.source, '/')) != NULL) { |
|
36 - char zonename[ZONENAME_MAX]; |
|
37 + char path_zname[ZONENAME_MAX]; |
|
38 int znamelen; |
|
39 char *lnamep; |
|
40 |
|
41 + if (ifr.lifr_zoneid != GLOBAL_ZONEID) { |
|
42 + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, |
|
43 + "zonename/linkname only valid in global zone."); |
|
44 + status = PCAP_ERROR; |
|
45 + goto bad; |
|
46 + } |
|
47 znamelen = zonesep - p->opt.source; |
|
48 - (void) strlcpy(zonename, p->opt.source, znamelen + 1); |
|
49 + (void) strlcpy(path_zname, p->opt.source, znamelen + 1); |
|
50 + ifr.lifr_zoneid = getzoneidbyname(path_zname); |
|
51 + if (ifr.lifr_zoneid == -1) { |
|
52 + snprintf(p->errbuf, PCAP_ERRBUF_SIZE, |
|
53 + "getzoneidbyname(%s): %s", path_zname, |
|
54 + pcap_strerror(errno)); |
|
55 + status = PCAP_ERROR; |
|
56 + goto bad; |
|
57 + } |
|
58 lnamep = strdup(zonesep + 1); |
|
59 - ifr.lifr_zoneid = getzoneidbyname(zonename); |
|
60 free(p->opt.source); |
|
61 p->opt.source = lnamep; |
|
62 } |
|