Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 488886
Collapse All | Expand All

(-)a/aclocal.m4 (-2 lines)
Lines 428-435 if test "$af_have_libtirpc" = "yes"; then Link Here
428
    TIRPCLIB="-ltirpc"
428
    TIRPCLIB="-ltirpc"
429
fi
429
fi
430
430
431
AC_CHECK_FUNCS([getrpcbyname getservbyname])
432
433
# restore flags
431
# restore flags
434
CFLAGS="$af_check_libtirpc_save_cflags"
432
CFLAGS="$af_check_libtirpc_save_cflags"
435
LDFLAGS="$af_check_libtirpc_save_ldflags"
433
LDFLAGS="$af_check_libtirpc_save_ldflags"
(-)a/configure (-13 lines)
Lines 3228-3246 $as_echo "#define TIRPC_WORKAROUND 1" >>confdefs.h Link Here
3228
    TIRPCLIB="-ltirpc"
3228
    TIRPCLIB="-ltirpc"
3229
fi
3229
fi
3230
3230
3231
for ac_func in getrpcbyname getservbyname
3232
do :
3233
  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
3234
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
3235
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
3236
  cat >>confdefs.h <<_ACEOF
3237
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
3238
_ACEOF
3239
3240
fi
3241
done
3242
3243
3244
# restore flags
3231
# restore flags
3245
CFLAGS="$af_check_libtirpc_save_cflags"
3232
CFLAGS="$af_check_libtirpc_save_cflags"
3246
LDFLAGS="$af_check_libtirpc_save_ldflags"
3233
LDFLAGS="$af_check_libtirpc_save_ldflags"
(-)a/include/config.h.in (-6 lines)
Lines 21-32 Link Here
21
/* define if you have E4FSCK */
21
/* define if you have E4FSCK */
22
#undef HAVE_E4FSCK
22
#undef HAVE_E4FSCK
23
23
24
/* Define to 1 if you have the `getrpcbyname' function. */
25
#undef HAVE_GETRPCBYNAME
26
27
/* Define to 1 if you have the `getservbyname' function. */
28
#undef HAVE_GETSERVBYNAME
29
30
/* Define to 1 if you have the <inttypes.h> header file. */
24
/* Define to 1 if you have the <inttypes.h> header file. */
31
#undef HAVE_INTTYPES_H
25
#undef HAVE_INTTYPES_H
32
26
(-)a/lib/rpc_subs.c (-86 / +6 lines)
Lines 43-56 Link Here
43
                } while (0)
43
                } while (0)
44
#endif
44
#endif
45
45
46
#ifdef WITH_LIBTIRPC
47
const rpcprog_t rpcb_prog = RPCBPROG;
48
const rpcvers_t rpcb_version = RPCBVERS;
49
#else
50
const rpcprog_t rpcb_prog = PMAPPROG;
51
const rpcvers_t rpcb_version = PMAPVERS;
52
#endif
53
54
#include "mount.h"
46
#include "mount.h"
55
#include "rpc_subs.h"
47
#include "rpc_subs.h"
56
#include "automount.h"
48
#include "automount.h"
Lines 267-275 static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i Link Here
267
		laddr = (struct sockaddr *) &in4_laddr;
259
		laddr = (struct sockaddr *) &in4_laddr;
268
		in4_raddr->sin_port = htons(info->port);
260
		in4_raddr->sin_port = htons(info->port);
269
		slen = sizeof(struct sockaddr_in);
261
		slen = sizeof(struct sockaddr_in);
270
		/* Use rpcbind v2 for AF_INET */
271
		if (info->program == rpcb_prog)
272
			info->version = PMAPVERS;
273
	} else if (addr->sa_family == AF_INET6) {
262
	} else if (addr->sa_family == AF_INET6) {
274
		struct sockaddr_in6 *in6_raddr = (struct sockaddr_in6 *) addr;
263
		struct sockaddr_in6 *in6_raddr = (struct sockaddr_in6 *) addr;
275
		in6_laddr.sin6_family = AF_INET6;
264
		in6_laddr.sin6_family = AF_INET6;
Lines 326-388 static int rpc_do_create_client(struct sockaddr *addr, struct conn_info *info, i Link Here
326
}
315
}
327
#endif
316
#endif
328
317
329
#if defined(HAVE_GETRPCBYNAME) || defined(HAVE_GETSERVBYNAME)
330
static pthread_mutex_t rpcb_mutex = PTHREAD_MUTEX_INITIALIZER;
331
#endif
332
333
static rpcprog_t rpc_getrpcbyname(const rpcprog_t program)
334
{
335
#ifdef HAVE_GETRPCBYNAME
336
	static const char *rpcb_pgmtbl[] = {
337
		"rpcbind", "portmap", "portmapper", "sunrpc", NULL,
338
	};
339
	struct rpcent *entry;
340
	rpcprog_t prog_number;
341
	unsigned int i;
342
343
	pthread_mutex_lock(&rpcb_mutex);
344
	for (i = 0; rpcb_pgmtbl[i] != NULL; i++) {
345
		entry = getrpcbyname(rpcb_pgmtbl[i]);
346
		if (entry) {
347
			prog_number = entry->r_number;
348
			pthread_mutex_unlock(&rpcb_mutex);
349
			return prog_number;
350
		}
351
	}
352
	pthread_mutex_unlock(&rpcb_mutex);
353
#endif
354
	return program;
355
}
356
357
static unsigned short rpc_getrpcbport(const int proto)
358
{
359
#ifdef HAVE_GETSERVBYNAME
360
	static const char *rpcb_netnametbl[] = {
361
		"rpcbind", "portmapper", "sunrpc", NULL,
362
	};
363
	struct servent *entry;
364
	struct protoent *p_ent;
365
	unsigned short port;
366
	unsigned int i;
367
368
	pthread_mutex_lock(&rpcb_mutex);
369
	p_ent = getprotobynumber(proto);
370
	if (!p_ent)
371
		goto done;
372
	for (i = 0; rpcb_netnametbl[i] != NULL; i++) {
373
		entry = getservbyname(rpcb_netnametbl[i], p_ent->p_name);
374
		if (entry) {
375
			port = entry->s_port;
376
			pthread_mutex_unlock(&rpcb_mutex);
377
			return port;
378
		}
379
	}
380
done:
381
	pthread_mutex_unlock(&rpcb_mutex);
382
#endif
383
	return (unsigned short) PMAPPORT;
384
}
385
386
/*
318
/*
387
 * Create an RPC client
319
 * Create an RPC client
388
 */
320
 */
Lines 578-592 int rpc_portmap_getclient(struct conn_info *info, Link Here
578
	info->host = host;
510
	info->host = host;
579
	info->addr = addr;
511
	info->addr = addr;
580
	info->addr_len = addr_len;
512
	info->addr_len = addr_len;
581
	info->program = rpc_getrpcbyname(rpcb_prog);
513
	info->program = PMAPPROG;
582
	info->port = ntohs(rpc_getrpcbport(proto));
514
	info->port = PMAPPORT;
583
	/*
515
	info->version = PMAPVERS;
584
	 * When using libtirpc we might need to change the rpcbind version
585
	 * to qurey AF_INET addresses. Since we might not have an address
586
	 * yet set AF_INET rpcbind version in rpc_do_create_client() when
587
	 * we always have an address.
588
	 */
589
	info->version = rpcb_version;
590
	info->proto = proto;
516
	info->proto = proto;
591
	info->send_sz = RPCSMALLMSGSIZE;
517
	info->send_sz = RPCSMALLMSGSIZE;
592
	info->recv_sz = RPCSMALLMSGSIZE;
518
	info->recv_sz = RPCSMALLMSGSIZE;
Lines 629-643 int rpc_portmap_getport(struct conn_info *info, Link Here
629
		pmap_info.host = info->host;
555
		pmap_info.host = info->host;
630
		pmap_info.addr = info->addr;
556
		pmap_info.addr = info->addr;
631
		pmap_info.addr_len = info->addr_len;
557
		pmap_info.addr_len = info->addr_len;
632
		pmap_info.port = ntohs(rpc_getrpcbport(info->proto));
558
		pmap_info.port = PMAPPORT;
633
		pmap_info.program = rpc_getrpcbyname(rpcb_prog);
559
		pmap_info.program = PMAPPROG;
634
		/*
560
		pmap_info.version = PMAPVERS;
635
		 * When using libtirpc we might need to change the rpcbind
636
		 * version to qurey AF_INET addresses. Since we might not
637
		 * have an address yet set AF_INET rpcbind version in
638
		 * rpc_do_create_client() when we always have an address.
639
		 */
640
		pmap_info.version = rpcb_version;
641
		pmap_info.proto = info->proto;
561
		pmap_info.proto = info->proto;
642
		pmap_info.send_sz = RPCSMALLMSGSIZE;
562
		pmap_info.send_sz = RPCSMALLMSGSIZE;
643
		pmap_info.recv_sz = RPCSMALLMSGSIZE;
563
		pmap_info.recv_sz = RPCSMALLMSGSIZE;

Return to bug 488886