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 tmp->cr_uid = cr->cr_uid;
56 tmp->cr_ruid = cr->cr_ruid;
57 tmp->cr_gid = cr->cr_gid;
58 tmp->cr_rgid = cr->cr_rgid;
60 memcpy(tmp->cr_groups, cr->cr_groups, NGROUPS * sizeof(gid_t));
61 tmp->cr_ngroups = cr->cr_ngroups;
71 cr->cr_uid = current_fsuid();
72 cr->cr_ruid = current_uid();
73 cr->cr_gid = current_fsgid();
74 cr->cr_rgid = 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->cr_uid;
98 new_creds->uid = cr->cr_ruid;
99 new_creds->fsgid = cr->cr_gid;
100 new_creds->gid = cr->cr_rgid;
102 current->fsuid = cr->cr_uid;
103 current->uid = cr->cr_ruid;
104 current->fsgid = cr->cr_gid;
105 current->gid = cr->cr_rgid;
107 memcpy(current->groups, cr->cr_groups, NGROUPS * sizeof(gid_t));
108 current->ngroups = cr->cr_ngroups;