From 409b89cc7106154780400c6b2bdce46bc9d5db4b Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Mon, 1 Mar 2010 08:07:34 -0500 Subject: nfs-utils: add and use nfs_authsys_create The current mount, umount and showmount code uses authunix_create_default to get an auth handle. The one provided by glibc returned a truncated list of groups when there were more than 16 groups. libtirpc however currently does an abort() in this case, which causes the program to crash and dump core. nfs-utils just uses these auth handles for the MNT protocol, so the group list doesn't make a lot of difference here. Add a new function that creates an auth handle with a supplemental gids list that consists only of the primary gid. Have nfs-utils use that function anywhere that it currently uses authunix_create_default. Also, have the caller properly check for a NULL return from that function. Signed-off-by: Jeff Layton Signed-off-by: Steve Dickson --- support/nfs/rpc_socket.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'support/nfs/rpc_socket.c') diff --git a/support/nfs/rpc_socket.c b/support/nfs/rpc_socket.c index 0e20824..aa6a205 100644 --- a/support/nfs/rpc_socket.c +++ b/support/nfs/rpc_socket.c @@ -557,3 +557,24 @@ rpcprog_t nfs_getrpcbyname(const rpcprog_t program, const char *table[]) return program; } + +/* + * AUTH_SYS doesn't allow more than 16 gids in the supplemental group list. + * If there are more than that, trying to determine which ones to include + * in the list is problematic. This function creates an auth handle that + * only has the primary gid in the supplemental gids list. It's intended to + * be used for protocols where credentials really don't matter much (the MNT + * protocol, for instance). + */ +AUTH * +nfs_authsys_create(void) +{ + char machname[MAXHOSTNAMELEN + 1]; + uid_t uid = geteuid(); + gid_t gid = getegid(); + + if (gethostname(machname, sizeof(machname)) == -1) + return NULL; + + return authsys_create(machname, uid, gid, 1, &gid); +} -- cgit