Bug #951

mount_nfs(8) rejects certain hostnames

Added by frank over 6 years ago. Updated over 6 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-

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,
+ MIN(hp->h_length, (int)sizeof(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,
MIN(hp->h_length, (int)sizeof(saddr.sin_addr)));
--- patch ends here ---

History

#1 Updated by dillon over 6 years ago

: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

Committed!

-Matt
Matthew Dillon
<>

Also available in: Atom PDF