2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 * afs_xsetgroups (asserts FALSE)
12 * setpag (aliased to use_setpag in sysincludes.h)
14 #include <afsconfig.h>
15 #include "afs/param.h"
18 #include "afs/sysincludes.h"
19 #include "afsincludes.h"
20 #include "afs/afs_stats.h" /* statistics */
21 #include "afs/afs_prototypes.h"
31 afs_getgroups(afs_ucred_t
*cred
, gid_t
* gidset
)
36 AFS_STATCNT(afs_getgroups
);
38 gidset
[0] = gidset
[1] = 0;
39 savengrps
= ngrps
= cred
->cr_ngroups
;
49 afs_setgroups(afs_ucred_t
**cred
, int ngroups
, gid_t
* gidset
,
54 AFS_STATCNT(afs_setgroups
);
56 if (ngroups
> NGROUPS_MAX
)
59 *cred
= (afs_ucred_t
*)crcopy(*cred
);
60 (*cred
)->cr_ngroups
= ngroups
;
61 gp
= (*cred
)->cr_groups
;
68 usr_setpag(struct usr_ucred
**cred
, afs_uint32 pagvalue
, afs_uint32
* newpag
,
77 gidset
= osi_AllocSmallSpace(AFS_SMALLOCSIZ
);
78 ngroups
= afs_getgroups(*cred
, gidset
);
80 if (afs_get_pag_from_groups(gidset
[0], gidset
[1]) == NOPAG
) {
81 /* We will have to shift grouplist to make room for pag */
82 if ((sizeof gidset
[0]) * (ngroups
+ 2) > AFS_SMALLOCSIZ
) {
83 osi_FreeSmallSpace((char *)gidset
);
86 for (j
= ngroups
- 1; j
>= 0; j
--) {
87 gidset
[j
+ 2] = gidset
[j
];
91 *newpag
= (pagvalue
== -1 ? genpag() : pagvalue
);
92 afs_get_groups_from_pag(*newpag
, &gidset
[0], &gidset
[1]);
93 if ((code
= afs_setgroups(cred
, ngroups
, gidset
, change_parent
))) {
94 osi_FreeSmallSpace((char *)gidset
);
97 osi_FreeSmallSpace((char *)gidset
);