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");
49 /* Return a duplicate of the cred. */
53 cred_t *tmp = crget();
55 set_cr_uid(tmp, cr_uid(cr));
56 set_cr_ruid(tmp, cr_ruid(cr));
57 set_cr_gid(tmp, cr_gid(cr));
58 set_cr_rgid(tmp, cr_rgid(cr));
60 memcpy(tmp->cr_groups, cr->cr_groups, NGROUPS * sizeof(gid_t));
61 tmp->cr_ngroups = cr->cr_ngroups;
71 set_cr_uid(cr, current_fsuid());
72 set_cr_ruid(cr, current_uid());
73 set_cr_gid(cr, current_fsgid());
74 set_cr_rgid(cr, current_gid());
76 memcpy(cr->cr_groups, current->groups, NGROUPS * sizeof(gid_t));
77 cr->cr_ngroups = current->ngroups;
83 /* Set the cred info into the current task */
87 #if defined(STRUCT_TASK_HAS_CRED)
88 struct cred *new_creds;
90 /* If our current task doesn't have identical real and effective
91 * credentials, commit_cred won't let us change them, so we just
94 if (current->cred != current->real_cred)
96 new_creds = prepare_creds();
97 new_creds->fsuid = cr_uid(cr);
98 new_creds->uid = cr_ruid(cr);
99 new_creds->fsgid = cr_gid(cr);
100 new_creds->gid = cr_rgid(cr);
102 current->fsuid = cr_uid(cr);
103 current->uid = cr_ruid(cr);
104 current->fsgid = cr_gid(cr);
105 current->gid = cr_rgid(cr);
107 memcpy(current->groups, cr->cr_groups, NGROUPS * sizeof(gid_t));
108 current->ngroups = cr->cr_ngroups;