From 693f0e8bbaee38060018e8bc2b30e42fa75315b7 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 14 Jul 2008 22:23:45 +0000 Subject: [PATCH] MFC 1.14: Fix bug where mount_nfs w/ IP address could still fail if name resolution is down. --- sbin/mount_nfs/mount_nfs.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c index eeac72c98b..0e2d8af1fd 100644 --- a/sbin/mount_nfs/mount_nfs.c +++ b/sbin/mount_nfs/mount_nfs.c @@ -36,7 +36,7 @@ * @(#) Copyright (c) 1992, 1993, 1994 The Regents of the University of California. All rights reserved. * @(#)mount_nfs.c 8.11 (Berkeley) 5/4/95 * $FreeBSD: src/sbin/mount_nfs/mount_nfs.c,v 1.36.2.6 2003/05/13 14:45:40 trhodes Exp $ - * $DragonFly: src/sbin/mount_nfs/mount_nfs.c,v 1.13 2008/02/16 20:48:29 dillon Exp $ + * $DragonFly: src/sbin/mount_nfs/mount_nfs.c,v 1.13.2.1 2008/07/14 22:23:45 dillon Exp $ */ #include @@ -631,16 +631,8 @@ getnfsargs(char *spec, struct nfs_args *nfsargsp) _res.retrans = 3; break; } - 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; - } + if (inet_pton(AF_INET, hostp, &iaddr) == 1) { + saddr.sin_addr = iaddr; } else if ((hp = gethostbyname(hostp)) != NULL) { memmove(&saddr.sin_addr, hp->h_addr, MIN(hp->h_length, (int)sizeof(saddr.sin_addr))); -- 2.11.4.GIT