diff options
| author | brynet <> | 2018-11-09 17:49:32 +0000 |
|---|---|---|
| committer | brynet <> | 2018-11-09 17:49:32 +0000 |
| commit | 6372cdd7190c2285e7d31b38164710116267291e (patch) | |
| tree | 3e9c96b4f5c381a0129a18b9e48b91455a47548c /src/lib/libc/net/ethers.c | |
| parent | 5de2fb943674362ea7e491eb2b9af43a949a7cf1 (diff) | |
| download | openbsd-6372cdd7190c2285e7d31b38164710116267291e.tar.gz openbsd-6372cdd7190c2285e7d31b38164710116267291e.tar.bz2 openbsd-6372cdd7190c2285e7d31b38164710116267291e.zip | |
Remove ethers(5) YP support bits from libc as it makes it difficult to
effectively use pledge(2) in some programs.
approval from many, thanks!
idea by & ok deraadt@
Diffstat (limited to 'src/lib/libc/net/ethers.c')
| -rw-r--r-- | src/lib/libc/net/ethers.c | 62 |
1 files changed, 5 insertions, 57 deletions
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); |
