*: gethostname-related fixes
function old new delta hostname_main 218 231 +13 nfsmount 3541 3474 -67 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
ca228fb16d
commit
99069330a1
@ -96,28 +96,6 @@ unsigned FAST_FUNC bb_lookup_port(const char *port, const char *protocol, unsign
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* "Old" networking API - only IPv4 */
|
|
||||||
|
|
||||||
/*
|
|
||||||
void FAST_FUNC bb_lookup_host(struct sockaddr_in *s_in, const char *host)
|
|
||||||
{
|
|
||||||
struct hostent *he;
|
|
||||||
|
|
||||||
memset(s_in, 0, sizeof(struct sockaddr_in));
|
|
||||||
s_in->sin_family = AF_INET;
|
|
||||||
he = xgethostbyname(host);
|
|
||||||
memcpy(&(s_in->sin_addr), he->h_addr_list[0], he->h_length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int FAST_FUNC xconnect_tcp_v4(struct sockaddr_in *s_addr)
|
|
||||||
{
|
|
||||||
int s = xsocket(AF_INET, SOCK_STREAM, 0);
|
|
||||||
xconnect(s, (struct sockaddr*) s_addr, sizeof(*s_addr));
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* "New" networking API */
|
/* "New" networking API */
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,11 +132,15 @@ int hostname_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (*p)
|
if (*p)
|
||||||
puts(p + 1);
|
puts(p + 1);
|
||||||
} else /*if (opts & OPT_i)*/ {
|
} else /*if (opts & OPT_i)*/ {
|
||||||
while (hp->h_addr_list[0]) {
|
if (hp->h_length == sizeof(struct in_addr)) {
|
||||||
printf("%s ", inet_ntoa(*(struct in_addr *) (*hp->h_addr_list++)));
|
struct in_addr **h_addr_list = (struct in_addr **)hp->h_addr_list;
|
||||||
|
while (*h_addr_list) {
|
||||||
|
printf("%s ", inet_ntoa(**h_addr_list));
|
||||||
|
h_addr_list++;
|
||||||
}
|
}
|
||||||
bb_putchar('\n');
|
bb_putchar('\n');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (opts & OPT_F) {
|
} else if (opts & OPT_F) {
|
||||||
/* Set the hostname */
|
/* Set the hostname */
|
||||||
do_sethostname(hostname_str, 1);
|
do_sethostname(hostname_str, 1);
|
||||||
|
@ -1043,12 +1043,10 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
|
|||||||
bb_herror_msg("%s", hostname);
|
bb_herror_msg("%s", hostname);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if ((size_t)hp->h_length > sizeof(struct in_addr)) {
|
if (hp->h_length != (int)sizeof(struct in_addr)) {
|
||||||
bb_error_msg("got bad hp->h_length");
|
bb_error_msg_and_die("only IPv4 is supported");
|
||||||
hp->h_length = sizeof(struct in_addr);
|
|
||||||
}
|
}
|
||||||
memcpy(&server_addr.sin_addr,
|
memcpy(&server_addr.sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
|
||||||
hp->h_addr, hp->h_length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&mount_server_addr, &server_addr, sizeof(mount_server_addr));
|
memcpy(&mount_server_addr, &server_addr, sizeof(mount_server_addr));
|
||||||
@ -1331,13 +1329,11 @@ static NOINLINE int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
|
|||||||
bb_herror_msg("%s", mounthost);
|
bb_herror_msg("%s", mounthost);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if ((size_t)hp->h_length > sizeof(struct in_addr)) {
|
if (hp->h_length != (int)sizeof(struct in_addr)) {
|
||||||
bb_error_msg("got bad hp->h_length");
|
bb_error_msg_and_die("only IPv4 is supported");
|
||||||
hp->h_length = sizeof(struct in_addr);
|
|
||||||
}
|
}
|
||||||
mount_server_addr.sin_family = AF_INET;
|
mount_server_addr.sin_family = AF_INET;
|
||||||
memcpy(&mount_server_addr.sin_addr,
|
memcpy(&mount_server_addr.sin_addr, hp->h_addr_list[0], sizeof(struct in_addr));
|
||||||
hp->h_addr, hp->h_length);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user