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_group_info(cr));
51 /* Return a duplicate of the cred. */
55 cred_t *tmp = crget();
57 set_cr_uid(tmp, cr_uid(cr));
58 set_cr_ruid(tmp, cr_ruid(cr));
59 set_cr_gid(tmp, cr_gid(cr));
60 set_cr_rgid(tmp, cr_rgid(cr));
62 get_group_info(cr_group_info(cr));
63 set_cr_group_info(tmp, cr_group_info(cr));
73 set_cr_uid(cr, current_fsuid());
74 set_cr_ruid(cr, current_uid());
75 set_cr_gid(cr, current_fsgid());
76 set_cr_rgid(cr, current_gid());
79 get_group_info(current_group_info());
80 set_cr_group_info(cr, 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_uid(cr);
102 new_creds->uid = cr_ruid(cr);
103 new_creds->fsgid = cr_gid(cr);
104 new_creds->gid = cr_rgid(cr);
106 current->fsuid = cr_uid(cr);
107 current->uid = cr_ruid(cr);
108 current->fsgid = cr_gid(cr);
109 current->gid = cr_rgid(cr);
112 /* using set_current_groups() will sort the groups */
113 get_group_info(cr_group_info(cr));
116 #if defined(STRUCT_TASK_HAS_CRED)
117 old_info = current->cred->group_info;
118 new_creds->group_info = cr_group_info(cr);
119 commit_creds(new_creds);
121 old_info = current->group_info;
122 current->group_info = cr_group_info(cr);
124 task_unlock(current);
126 put_group_info(old_info);