Add set_rpc_maxgrouplist

This commit is contained in:
christos 2020-10-03 18:31:29 +00:00
parent c53d404f5e
commit fb8fd3ef27
3 changed files with 34 additions and 6 deletions

@ -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 # librpc sources
.PATH: ${.CURDIR}/rpc .PATH: ${.CURDIR}/rpc
@ -38,6 +38,7 @@ MLINKS+= bindresvport.3 bindresvport_sa.3 \
rpc_clnt_auth.3 authnone_create.3 \ rpc_clnt_auth.3 authnone_create.3 \
rpc_clnt_auth.3 authsys_create.3 \ rpc_clnt_auth.3 authsys_create.3 \
rpc_clnt_auth.3 authsys_create_default.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_call.3 \
rpc_clnt_calls.3 clnt_perrno.3 \ rpc_clnt_calls.3 clnt_perrno.3 \
rpc_clnt_calls.3 clnt_perror.3 \ rpc_clnt_calls.3 clnt_perror.3 \

@ -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. * 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 1.19 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC"; static char *sccsid = "@(#)auth_unix.c 2.2 88/08/01 4.0 RPCSRC";
#else #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
#endif #endif
@ -182,6 +182,20 @@ authunix_create(char *machname, int uid, int gid, int len, int *aup_gids)
#endif #endif
} }
/*
* 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 * Returns an auth handle with parameters determined by doing lots of
* syscalls. * syscalls.
@ -202,6 +216,8 @@ authunix_create_default(void)
gid = getegid(); gid = getegid();
if ((len = getgroups(NGRPS, gids)) < 0) if ((len = getgroups(NGRPS, gids)) < 0)
abort(); abort();
if (len > maxgrplist)
len = maxgrplist;
/* XXX: interface problem; those should all have been unsigned */ /* XXX: interface problem; those should all have been unsigned */
return (authunix_create(machname, (int)uid, (int)gid, len, return (authunix_create(machname, (int)uid, (int)gid, len,
(int *)gids)); (int *)gids));

@ -2,15 +2,16 @@
.\" Copyright 1989 AT&T .\" Copyright 1989 AT&T
.\" @(#)rpc_clnt_auth 1.4 89/07/20 SMI; .\" @(#)rpc_clnt_auth 1.4 89/07/20 SMI;
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved. .\" 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 $ .\" $NetBSD: rpc_clnt_auth.3,v 1.7 2020/10/03 18:31:29 christos Exp $
.Dd May 7, 1993 .Dd October 3, 2020
.Dt RPC_CLNT_AUTH 3 .Dt RPC_CLNT_AUTH 3
.Os .Os
.Sh NAME .Sh NAME
.Nm auth_destroy , .Nm auth_destroy ,
.Nm authnone_create , .Nm authnone_create ,
.Nm authsys_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 .Nd library routines for client side remote procedure call authentication
.Sh LIBRARY .Sh LIBRARY
.Lb libc .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" .Fn authsys_create "const char *host" "const uid_t uid" "const gid_t gid" "const int len" "const gid_t *aup_gids"
.Ft "AUTH *" .Ft "AUTH *"
.Fn authsys_create_default "void" .Fn authsys_create_default "void"
.Ft "void"
.Fn set_rpc_maxgrouplist "int num"
.Sh DESCRIPTION .Sh DESCRIPTION
These routines are part of the These routines are part of the
RPC library that allows C language programs to make procedure 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 Call
.Fn authsys_create .Fn authsys_create
with the appropriate parameters. 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 .El
.Sh SEE ALSO .Sh SEE ALSO
.Xr rpc 3 , .Xr rpc 3 ,