diff options
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/net/ethers.3 | 16 | ||||
| -rw-r--r-- | src/lib/libc/net/ethers.c | 62 |
2 files changed, 8 insertions, 70 deletions
diff --git a/src/lib/libc/net/ethers.3 b/src/lib/libc/net/ethers.3 index 63304ffe48..021e1ced73 100644 --- a/src/lib/libc/net/ethers.3 +++ b/src/lib/libc/net/ethers.3 | |||
| @@ -1,8 +1,8 @@ | |||
| 1 | .\" $OpenBSD: ethers.3,v 1.24 2015/11/10 23:48:18 jmc Exp $ | 1 | .\" $OpenBSD: ethers.3,v 1.25 2018/11/09 17:49:32 brynet Exp $ |
| 2 | .\" | 2 | .\" |
| 3 | .\" Written by roland@frob.com. Public domain. | 3 | .\" Written by roland@frob.com. Public domain. |
| 4 | .\" | 4 | .\" |
| 5 | .Dd $Mdocdate: November 10 2015 $ | 5 | .Dd $Mdocdate: November 9 2018 $ |
| 6 | .Dt ETHER_ATON 3 | 6 | .Dt ETHER_ATON 3 |
| 7 | .Os | 7 | .Os |
| 8 | .Sh NAME | 8 | .Sh NAME |
| @@ -79,17 +79,7 @@ zero if they find the requested host name or address, and \-1 if not. | |||
| 79 | .Pp | 79 | .Pp |
| 80 | Each call reads | 80 | Each call reads |
| 81 | .Pa /etc/ethers | 81 | .Pa /etc/ethers |
| 82 | from the beginning; if a | 82 | from the beginning. |
| 83 | .Ql + | ||
| 84 | appears alone on a line in the file, then | ||
| 85 | .Fn ether_hostton | ||
| 86 | will consult the | ||
| 87 | .Pa ethers.byname | ||
| 88 | YP map, and | ||
| 89 | .Fn ether_ntohost | ||
| 90 | will consult the | ||
| 91 | .Pa ethers.byaddr | ||
| 92 | YP map. | ||
| 93 | .Pp | 83 | .Pp |
| 94 | The | 84 | The |
| 95 | .Fn ether_line | 85 | .Fn ether_line |
diff --git a/src/lib/libc/net/ethers.c b/src/lib/libc/net/ethers.c index de68c092f8..490622df9a 100644 --- a/src/lib/libc/net/ethers.c +++ b/src/lib/libc/net/ethers.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ethers.c,v 1.25 2016/09/21 04:38:56 guenther Exp $ */ | 1 | /* $OpenBSD: ethers.c,v 1.26 2018/11/09 17:49:32 brynet Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | 4 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
| @@ -34,9 +34,6 @@ | |||
| 34 | #include <string.h> | 34 | #include <string.h> |
| 35 | #include <ctype.h> | 35 | #include <ctype.h> |
| 36 | #include <limits.h> | 36 | #include <limits.h> |
| 37 | #ifdef YP | ||
| 38 | #include <rpcsvc/ypclnt.h> | ||
| 39 | #endif | ||
| 40 | 37 | ||
| 41 | #ifndef _PATH_ETHERS | 38 | #ifndef _PATH_ETHERS |
| 42 | #define _PATH_ETHERS "/etc/ethers" | 39 | #define _PATH_ETHERS "/etc/ethers" |
| @@ -99,18 +96,6 @@ ether_ntohost(char *hostname, struct ether_addr *e) | |||
| 99 | char buf[BUFSIZ+1], *p; | 96 | char buf[BUFSIZ+1], *p; |
| 100 | size_t len; | 97 | size_t len; |
| 101 | struct ether_addr try; | 98 | struct ether_addr try; |
| 102 | #ifdef YP | ||
| 103 | char trybuf[sizeof("xx:xx:xx:xx:xx:xx")]; | ||
| 104 | int trylen; | ||
| 105 | #endif | ||
| 106 | |||
| 107 | #ifdef YP | ||
| 108 | snprintf(trybuf, sizeof trybuf, "%x:%x:%x:%x:%x:%x", | ||
| 109 | e->ether_addr_octet[0], e->ether_addr_octet[1], | ||
| 110 | e->ether_addr_octet[2], e->ether_addr_octet[3], | ||
| 111 | e->ether_addr_octet[4], e->ether_addr_octet[5]); | ||
| 112 | trylen = strlen(trybuf); | ||
| 113 | #endif | ||
| 114 | 99 | ||
| 115 | f = fopen(_PATH_ETHERS, "re"); | 100 | f = fopen(_PATH_ETHERS, "re"); |
| 116 | if (f == NULL) | 101 | if (f == NULL) |
| @@ -123,26 +108,9 @@ ether_ntohost(char *hostname, struct ether_addr *e) | |||
| 123 | (void)memcpy(buf, p, len); | 108 | (void)memcpy(buf, p, len); |
| 124 | buf[len] = '\n'; /* code assumes newlines later on */ | 109 | buf[len] = '\n'; /* code assumes newlines later on */ |
| 125 | buf[len+1] = '\0'; | 110 | buf[len+1] = '\0'; |
| 126 | #ifdef YP | 111 | /* A + in the file meant try YP, ignore it. */ |
| 127 | /* A + in the file means try YP now. */ | 112 | if (!strncmp(buf, "+\n", sizeof(buf))) |
| 128 | if (!strncmp(buf, "+\n", sizeof(buf))) { | ||
| 129 | char *ypbuf, *ypdom; | ||
| 130 | int ypbuflen; | ||
| 131 | |||
| 132 | if (yp_get_default_domain(&ypdom)) | ||
| 133 | continue; | ||
| 134 | if (yp_match(ypdom, "ethers.byaddr", trybuf, | ||
| 135 | trylen, &ypbuf, &ypbuflen)) | ||
| 136 | continue; | ||
| 137 | if (ether_line(ypbuf, &try, hostname) == 0) { | ||
| 138 | free(ypbuf); | ||
| 139 | (void)fclose(f); | ||
| 140 | return (0); | ||
| 141 | } | ||
| 142 | free(ypbuf); | ||
| 143 | continue; | 113 | continue; |
| 144 | } | ||
| 145 | #endif | ||
| 146 | if (ether_line(buf, &try, hostname) == 0 && | 114 | if (ether_line(buf, &try, hostname) == 0 && |
| 147 | memcmp(&try, e, sizeof(try)) == 0) { | 115 | memcmp(&try, e, sizeof(try)) == 0) { |
| 148 | (void)fclose(f); | 116 | (void)fclose(f); |
| @@ -161,9 +129,6 @@ ether_hostton(const char *hostname, struct ether_addr *e) | |||
| 161 | char buf[BUFSIZ+1], *p; | 129 | char buf[BUFSIZ+1], *p; |
| 162 | char try[HOST_NAME_MAX+1]; | 130 | char try[HOST_NAME_MAX+1]; |
| 163 | size_t len; | 131 | size_t len; |
| 164 | #ifdef YP | ||
| 165 | int hostlen = strlen(hostname); | ||
| 166 | #endif | ||
| 167 | 132 | ||
| 168 | f = fopen(_PATH_ETHERS, "re"); | 133 | f = fopen(_PATH_ETHERS, "re"); |
| 169 | if (f==NULL) | 134 | if (f==NULL) |
| @@ -177,26 +142,9 @@ ether_hostton(const char *hostname, struct ether_addr *e) | |||
| 177 | memcpy(buf, p, len); | 142 | memcpy(buf, p, len); |
| 178 | buf[len] = '\n'; /* code assumes newlines later on */ | 143 | buf[len] = '\n'; /* code assumes newlines later on */ |
| 179 | buf[len+1] = '\0'; | 144 | buf[len+1] = '\0'; |
| 180 | #ifdef YP | 145 | /* A + in the file meant try YP, ignore it. */ |
| 181 | /* A + in the file means try YP now. */ | 146 | if (!strncmp(buf, "+\n", sizeof(buf))) |
| 182 | if (!strncmp(buf, "+\n", sizeof(buf))) { | ||
| 183 | char *ypbuf, *ypdom; | ||
| 184 | int ypbuflen; | ||
| 185 | |||
| 186 | if (yp_get_default_domain(&ypdom)) | ||
| 187 | continue; | ||
| 188 | if (yp_match(ypdom, "ethers.byname", hostname, hostlen, | ||
| 189 | &ypbuf, &ypbuflen)) | ||
| 190 | continue; | ||
| 191 | if (ether_line(ypbuf, e, try) == 0) { | ||
| 192 | free(ypbuf); | ||
| 193 | (void)fclose(f); | ||
| 194 | return (0); | ||
| 195 | } | ||
| 196 | free(ypbuf); | ||
| 197 | continue; | 147 | continue; |
| 198 | } | ||
| 199 | #endif | ||
| 200 | if (ether_line(buf, e, try) == 0 && strcmp(hostname, try) == 0) { | 148 | if (ether_line(buf, e, try) == 0 && strcmp(hostname, try) == 0) { |
| 201 | (void)fclose(f); | 149 | (void)fclose(f); |
| 202 | return (0); | 150 | return (0); |
