~ubuntu-branches/debian/stretch/nfs-utils/stretch

« back to all changes in this revision

Viewing changes to support/export/hostname.c

  • Committer: Bazaar Package Importer
  • Author(s): Luk Claes
  • Date: 2011-07-09 16:28:32 UTC
  • mfrom: (1.2.20 upstream)
  • Revision ID: james.westby@ubuntu.com-20110709162832-ovaehe77pm3hyy35
Tags: 1:1.2.4-1
* New upstream version
  - Fix host_reliable_addrinfo (Closes: #633155)
  - Allow multiple RPC listeners to share listener port number
  (Closes: #619877)
  - Add --enable-libmount-mount (Closes: #626478)
  - 12-svcgssd-document-n-option.patch applied upstream
  - Refresh 19-exports.man-Fix-comment-syntax.patch
  - 21-anticipate-RLIMIT_FSIZE.patch applied upstream
  - Add nfsidmap binary and manpage
  - Use autoreconf to avoid build failure

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "sockaddr.h"
31
31
#include "exportfs.h"
32
32
 
33
 
#ifndef HAVE_DECL_AI_ADDRCONFIG
34
 
#define AI_ADDRCONFIG   0
35
 
#endif
36
 
 
37
33
/**
38
34
 * host_ntop - generate presentation address given a sockaddr
39
35
 * @sap: pointer to socket address
170
166
#endif
171
167
                /* don't return duplicates */
172
168
                .ai_protocol    = (int)IPPROTO_UDP,
173
 
                .ai_flags       = AI_ADDRCONFIG | AI_CANONNAME,
 
169
                .ai_flags       = AI_CANONNAME,
174
170
        };
175
171
        int error;
176
172
 
262
258
 * @sap: pointer to socket address to look up
263
259
 *
264
260
 * Reverse and forward lookups are performed to ensure the address has
265
 
 * proper forward and reverse mappings.
266
 
 *
267
 
 * Returns address info structure with ai_canonname filled in, or NULL
268
 
 * if no information is available for @sap.  Caller must free the returned
269
 
 * structure with freeaddrinfo(3).
 
261
 * matching forward and reverse mappings.
 
262
 *
 
263
 * Returns addrinfo structure with just the provided address with
 
264
 * ai_canonname filled in. If there is a problem with resolution or
 
265
 * the resolved records don't match up properly then it returns NULL
 
266
 *
 
267
 * Caller must free the returned structure with freeaddrinfo(3).
270
268
 */
271
269
__attribute_malloc__
272
270
struct addrinfo *
273
271
host_reliable_addrinfo(const struct sockaddr *sap)
274
272
{
275
 
        struct addrinfo *ai;
 
273
        struct addrinfo *ai, *a;
276
274
        char *hostname;
277
275
 
278
276
        hostname = host_canonname(sap);
280
278
                return NULL;
281
279
 
282
280
        ai = host_addrinfo(hostname);
283
 
 
 
281
        if (!ai)
 
282
                goto out_free_hostname;
 
283
 
 
284
        /* make sure there's a matching address in the list */
 
285
        for (a = ai; a; a = a->ai_next)
 
286
                if (nfs_compare_sockaddr(a->ai_addr, sap))
 
287
                        break;
 
288
 
 
289
        freeaddrinfo(ai);
 
290
        if (!a)
 
291
                goto out_free_hostname;
 
292
 
 
293
        /* get addrinfo with just the original address */
 
294
        ai = host_numeric_addrinfo(sap);
 
295
        if (!ai)
 
296
                goto out_free_hostname;
 
297
 
 
298
        /* and populate its ai_canonname field */
 
299
        free(ai->ai_canonname);
 
300
        ai->ai_canonname = hostname;
 
301
        return ai;
 
302
 
 
303
out_free_hostname:
284
304
        free(hostname);
285
 
        return ai;
 
305
        return NULL;
286
306
}
287
307
 
288
308
/**