Bug #951
closedmount_nfs(8) rejects certain hostnames
0%
Description
It is currently not possible to mount a NFS file system if the first
character in the remote server's hostname is a digit. For example,
mount -t nfs 6pack:/ /mnt
will fail and issue a warning about bad net address 6pack. There is a
patch below which might be helpful for fixing this.
Regards,
Frank Josellis
--- patch begins here ---
--- sbin/mount_nfs/mount_nfs.c.orig 2006-03-27 18:18:13.000000000 0200
++ sbin/mount_nfs/mount_nfs.c 2008-02-16 18:29:13.000000000 +0100@ -559,6 +559,7
@
{
struct hostent *hp;
struct sockaddr_in saddr;
+ struct in_addr iaddr;
enum tryret ret;
int speclen, remoteerr;
char *hostp, *delimp, *errstr;@ -630,12 +631,16
@
_res.retrans = 3;
break;
}
- if (isdigit(*hostp)) {
- saddr.sin_addr.s_addr = inet_addr(hostp);
- if (saddr.sin_addr.s_addr == INADDR_NONE) {
- warnx("bad net address %s", hostp);
- haserror = EAI_FAIL;
- }
+ if (inet_aton(hostp, &iaddr)) {
+ if ((hp = gethostbyaddr((char *) &iaddr,
+ sizeof(iaddr),
+ AF_INET)) != NULL) {
+ memmove(&saddr.sin_addr, hp->h_addr,
+ MINsizeof(saddr.sin_addr)));
+ } else {
+ warnx("bad net address %s", hostp);
+ haserror = EAI_FAIL;
+ }
} else if ((hp = gethostbyname(hostp)) != NULL) {
memmove(&saddr.sin_addr, hp->h_addr,
MINsizeof(saddr.sin_addr)));
--- patch ends here ---