2 #include <minix/vfsif.h>
3 #include <minix/type.h>
4 #include <minix/syslib.h>
10 int fs_lookup_credentials(vfs_ucred_t
*credentials
,
11 uid_t
*caller_uid
, gid_t
*caller_gid
, cp_grant_id_t grant2
, size_t cred_size
)
13 vfs_ucred_old_t old_cred
;
16 memset(credentials
, 0, sizeof(*credentials
));
18 if(cred_size
== sizeof(*credentials
)) {
19 r
= sys_safecopyfrom(VFS_PROC_NR
, grant2
, (vir_bytes
) 0,
20 (vir_bytes
) credentials
, cred_size
);
22 printf("FS: cred copy (regular) failed.\n");
25 } else if(cred_size
== sizeof(old_cred
)) {
27 r
= sys_safecopyfrom(VFS_PROC_NR
, grant2
, (vir_bytes
) 0,
28 (vir_bytes
) &old_cred
, sizeof(old_cred
));
30 printf("FS: cred copy (fallback) failed.\n");
33 credentials
->vu_ngroups
= old_cred
.vu_ngroups
;
34 credentials
->vu_uid
= old_cred
.vu_uid
;
35 credentials
->vu_gid
= old_cred
.vu_gid
;
36 for(g
= 0; g
< NGROUPS_MAX_OLD
; g
++) {
37 assert(g
< NGROUPS_MAX
);
38 credentials
->vu_sgroups
[g
] = old_cred
.vu_sgroups
[g
];
42 if(!w
) { printf("FS: cred size incompatible with VFS.\n"); w
= 1; }
43 return(EINVAL
); /* Wrong size. */
46 assert(credentials
->vu_ngroups
<= NGROUPS_MAX
);
48 *caller_uid
= credentials
->vu_uid
;
49 *caller_gid
= credentials
->vu_gid
;