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 * osi_cred.c - Linux cred handling routines.
14 #include <afsconfig.h>
15 #include "afs/param.h"
20 #include "afs/sysincludes.h"
21 #include "afsincludes.h"
28 #if !defined(GFP_NOFS)
29 #define GFP_NOFS GFP_KERNEL
31 tmp = kmalloc(sizeof(cred_t), GFP_NOFS);
33 osi_Panic("crget: No more memory for creds!\n");
47 #if defined(AFS_LINUX26_ENV)
48 put_group_info(cr->cr_group_info);
55 /* Return a duplicate of the cred. */
59 cred_t *tmp = crget();
61 tmp->cr_uid = cr->cr_uid;
62 tmp->cr_ruid = cr->cr_ruid;
63 tmp->cr_gid = cr->cr_gid;
64 tmp->cr_rgid = cr->cr_rgid;
66 #if defined(AFS_LINUX26_ENV)
67 get_group_info(cr->cr_group_info);
68 tmp->cr_group_info = cr->cr_group_info;
70 memcpy(tmp->cr_groups, cr->cr_groups, NGROUPS * sizeof(gid_t));
71 tmp->cr_ngroups = cr->cr_ngroups;
82 cr->cr_uid = current_fsuid();
83 cr->cr_ruid = current_uid();
84 cr->cr_gid = current_fsgid();
85 cr->cr_rgid = current_gid();
87 #if defined(AFS_LINUX26_ENV)
89 get_group_info(current_group_info());
90 cr->cr_group_info = current_group_info();
93 memcpy(cr->cr_groups, current->groups, NGROUPS * sizeof(gid_t));
94 cr->cr_ngroups = current->ngroups;
100 /* Set the cred info into the current task */
104 #if defined(STRUCT_TASK_HAS_CRED)
105 struct cred *new_creds;
107 new_creds = prepare_creds();
108 new_creds->fsuid = cr->cr_uid;
109 new_creds->uid = cr->cr_ruid;
110 new_creds->fsgid = cr->cr_gid;
111 new_creds->gid = cr->cr_rgid;
113 current->fsuid = cr->cr_uid;
114 current->uid = cr->cr_ruid;
115 current->fsgid = cr->cr_gid;
116 current->gid = cr->cr_rgid;
118 #if defined(AFS_LINUX26_ENV)
120 struct group_info *old_info;
122 /* using set_current_groups() will sort the groups */
123 get_group_info(cr->cr_group_info);
126 #if defined(STRUCT_TASK_HAS_CRED)
127 old_info = current->cred->group_info;
128 new_creds->group_info = cr->cr_group_info;
129 commit_creds(new_creds);
131 old_info = current->group_info;
132 current->group_info = cr->cr_group_info;
134 task_unlock(current);
136 put_group_info(old_info);
139 memcpy(current->groups, cr->cr_groups, NGROUPS * sizeof(gid_t));
140 current->ngroups = cr->cr_ngroups;