vos: GetServer search for non-loopback address
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 15 Dec 2013 00:38:50 +0000 (19:38 -0500)
committerD Brashear <shadow@your-file-system.com>
Thu, 20 Mar 2014 21:28:02 +0000 (14:28 -0700)
commitdc2a4fe4e949c250ca25708aa5a6dd575878fd7e
tree50ad4f9629828f62d0b98516f054008ab71093c7
parentb8589f1b59e520aae8d412170b663ff3bc214667
vos: GetServer search for non-loopback address

GetServer() is used to obtain an IP address for the 'aname' parameter.
'aname' can be either a dotted address or a host name.   If it is a dotted
address, it is returned immediately.  If it is a host name, then
gethostbyname() is used to obtain an IP address.

The prior version of this function had two failings:

1. It assumed that a struct hostent only contained a single address.
   It used the former h_addr field.  For all platforms supported by
   OpenAFS h_addr is a macro referencing the first address in the
   h_addr_list array.  If h_addr was a loopback address, it would
   ignore any additional addresses that might be in the list.

2. It assumed that if gethostbyname(aname) returned a loopback
   address as h_addr that 'aname' must be referring to the machine
   that the vos command is being executed on.  It therefore used
   gethostname() to obtain an alternate name to use for a gethostbyname()
   query.  The results of this query were not checked to be a loopback.
   As a result, a loopback address could be returned to the caller which
   in turn could be set into the VLDB.

Change-Id: Ib8d513be9daf650045e9c40718b0187f6b9770a2
Reviewed-on: http://gerrit.openafs.org/10585
Reviewed-by: D Brashear <shadow@your-file-system.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Harald Barth <haba+gerrit@kth.se>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
src/volser/vos.c