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"
18 #include "afs/sysincludes.h"
19 #include "afsincludes.h"
26 #if !defined(GFP_NOFS)
27 #define GFP_NOFS GFP_KERNEL
29 tmp = kmalloc(sizeof(cred_t), GFP_NOFS);
31 osi_Panic("crget: No more memory for creds!\n");
45 put_group_info(cr->cr_group_info);
51 /* Return a duplicate of the cred. */
55 cred_t *tmp = crget();
57 tmp->cr_uid = cr->cr_uid;
58 tmp->cr_ruid = cr->cr_ruid;
59 tmp->cr_gid = cr->cr_gid;
60 tmp->cr_rgid = cr->cr_rgid;
62 get_group_info(cr->cr_group_info);
63 tmp->cr_group_info = cr->cr_group_info;
73 cr->cr_uid = current_fsuid();
74 cr->cr_ruid = current_uid();
75 cr->cr_gid = current_fsgid();
76 cr->cr_rgid = current_gid();
79 get_group_info(current_group_info());
80 cr->cr_group_info = current_group_info();
86 /* Set the cred info into the current task */
90 struct group_info *old_info;
91 #if defined(STRUCT_TASK_HAS_CRED)
92 struct cred *new_creds;
94 /* If our current task doesn't have identical real and effective
95 * credentials, commit_cred won't let us change them, so we just
98 if (current->cred != current->real_cred)
100 new_creds = prepare_creds();
101 new_creds->fsuid = cr->cr_uid;
102 new_creds->uid = cr->cr_ruid;
103 new_creds->fsgid = cr->cr_gid;
104 new_creds->gid = cr->cr_rgid;
106 current->fsuid = cr->cr_uid;
107 current->uid = cr->cr_ruid;
108 current->fsgid = cr->cr_gid;
109 current->gid = cr->cr_rgid;
112 /* using set_current_groups() will sort the groups */
113 get_group_info(cr->cr_group_info);
116 #if defined(STRUCT_TASK_HAS_CRED)
117 old_info = current->cred->group_info;
118 new_creds->group_info = cr->cr_group_info;
119 commit_creds(new_creds);
121 old_info = current->group_info;
122 current->group_info = cr->cr_group_info;
124 task_unlock(current);
126 put_group_info(old_info);