summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2020-10-03 18:31:29 +0000
committerchristos <christos@NetBSD.org>2020-10-03 18:31:29 +0000
commit52f03043fb644df8a59a800042e614cc2b3839ff (patch)
tree93f6c14b92ea3ac4d44be86260cd424b8a16a6bf /lib/libc
parentfffb132121f23426621d1beff096aba2c2118545 (diff)
Add set_rpc_maxgrouplist
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/rpc/Makefile.inc3
-rw-r--r--lib/libc/rpc/auth_unix.c20
-rw-r--r--lib/libc/rpc/rpc_clnt_auth.317
3 files changed, 34 insertions, 6 deletions
diff --git a/lib/libc/rpc/Makefile.inc b/lib/libc/rpc/Makefile.inc
index 65e62c62ce7..f1eacb975e2 100644
--- a/lib/libc/rpc/Makefile.inc
+++ b/lib/libc/rpc/Makefile.inc
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.26 2019/10/13 07:28:10 mrg Exp $
+# $NetBSD: Makefile.inc,v 1.27 2020/10/03 18:31:29 christos Exp $
# librpc sources
.PATH: ${.CURDIR}/rpc
@@ -38,6 +38,7 @@ MLINKS+= bindresvport.3 bindresvport_sa.3 \
rpc_clnt_auth.3 authnone_create.3 \
rpc_clnt_auth.3 authsys_create.3 \
rpc_clnt_auth.3 authsys_create_default.3 \
+ rpc_clnt_auth.3 set_rpc_maxgrouplist.3 \
rpc_clnt_calls.3 clnt_call.3 \
rpc_clnt_calls.3 clnt_perrno.3 \
rpc_clnt_calls.3 clnt_perror.3 \
diff --git a/lib/libc/rpc/auth_unix.c b/lib/libc/rpc/auth_unix.c
index e0b980b12e2..2f5c0088241 100644
--- a/lib/libc/rpc/auth_unix.c
+++ b/lib/libc/rpc/auth_unix.c
@@ -1,4 +1,4 @@
-/* $NetBSD: auth_unix.c,v 1.26 2014/10/18 08:33:23 snj Exp $ */
+/* $NetBSD: auth_unix.c,v 1.27 2020/10/03 18:31:29 christos Exp $ */
/*
* Copyright (c) 2010, Oracle America, Inc.
@@ -37,7 +37,7 @@
static char *sccsid = "@(#)auth_unix.c 1.19 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC";
#else
-__RCSID("$NetBSD: auth_unix.c,v 1.26 2014/10/18 08:33:23 snj Exp $");
+__RCSID("$NetBSD: auth_unix.c,v 1.27 2020/10/03 18:31:29 christos Exp $");
#endif
#endif
@@ -183,6 +183,20 @@ authunix_create(char *machname, int uid, int gid, int len, int *aup_gids)
}
/*
+ * Some servers will refuse mounts if the group list is larger
+ * than it expects (like 8). This allows the application to set
+ * the maximum size of the group list that will be sent.
+ */
+static int maxgrplist = NGROUPS;
+
+void
+set_rpc_maxgrouplist(int num)
+{
+ if (num < NGROUPS)
+ maxgrplist = num;
+}
+
+/*
* Returns an auth handle with parameters determined by doing lots of
* syscalls.
*/
@@ -202,6 +216,8 @@ authunix_create_default(void)
gid = getegid();
if ((len = getgroups(NGRPS, gids)) < 0)
abort();
+ if (len > maxgrplist)
+ len = maxgrplist;
/* XXX: interface problem; those should all have been unsigned */
return (authunix_create(machname, (int)uid, (int)gid, len,
(int *)gids));
diff --git a/lib/libc/rpc/rpc_clnt_auth.3 b/lib/libc/rpc/rpc_clnt_auth.3
index 242958b8add..0d43cd14a10 100644
--- a/lib/libc/rpc/rpc_clnt_auth.3
+++ b/lib/libc/rpc/rpc_clnt_auth.3
@@ -2,15 +2,16 @@
.\" Copyright 1989 AT&T
.\" @(#)rpc_clnt_auth 1.4 89/07/20 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
-.\" $NetBSD: rpc_clnt_auth.3,v 1.6 2003/04/16 13:34:43 wiz Exp $
-.Dd May 7, 1993
+.\" $NetBSD: rpc_clnt_auth.3,v 1.7 2020/10/03 18:31:29 christos Exp $
+.Dd October 3, 2020
.Dt RPC_CLNT_AUTH 3
.Os
.Sh NAME
.Nm auth_destroy ,
.Nm authnone_create ,
.Nm authsys_create ,
-.Nm authsys_create_default
+.Nm authsys_create_default ,
+.Nm set_rpc_maxgrouplist
.Nd library routines for client side remote procedure call authentication
.Sh LIBRARY
.Lb libc
@@ -24,6 +25,8 @@
.Fn authsys_create "const char *host" "const uid_t uid" "const gid_t gid" "const int len" "const gid_t *aup_gids"
.Ft "AUTH *"
.Fn authsys_create_default "void"
+.Ft "void"
+.Fn set_rpc_maxgrouplist "int num"
.Sh DESCRIPTION
These routines are part of the
RPC library that allows C language programs to make procedure
@@ -90,6 +93,14 @@ refer to a counted array of groups to which the user belongs.
Call
.Fn authsys_create
with the appropriate parameters.
+.Pp
+.It Fn set_rpc_maxgrouplist
+Allow the application to set the maximum size of the group list
+that will be used in
+.Fn authunix_create_default to
+.Fa num .
+Some servers will refuse mounts if the group list is larger than it expects
+(like 8).
.El
.Sh SEE ALSO
.Xr rpc 3 ,