9 tVFS_ACL gVFS_ACL_EveryoneRWX = { {1,-1}, {0,VFS_PERM_ALL} };
10 tVFS_ACL gVFS_ACL_EveryoneRW = { {1,-1}, {0,VFS_PERM_ALL^VFS_PERM_EXECUTE} };
11 tVFS_ACL gVFS_ACL_EveryoneRX = { {1,-1}, {0,VFS_PERM_READ|VFS_PERM_EXECUTE} };
12 tVFS_ACL gVFS_ACL_EveryoneRO = { {1,-1}, {0,VFS_PERM_READ} };
16 * \fn int VFS_CheckACL(tVFS_Node *Node, Uint Permissions)
17 * \brief Checks the permissions on a file
19 int VFS_CheckACL(tVFS_Node *Node, Uint Permissions)
22 int uid = Threads_GetUID();
23 int gid = Threads_GetGID();
25 // Root can do anything
26 if(uid == 0) return 1;
28 // Root only file?, fast return
29 if( Node->NumACLs == 0 ) return 0;
31 // Check Deny Permissions
32 for(i=0;i<Node->NumACLs;i++)
34 if(!Node->ACLs[i].Inv) continue; // Ignore ALLOWs
35 if(Node->ACLs[i].ID != -1)
37 if(!Node->ACLs[i].Group && Node->ACLs[i].ID != uid) continue;
38 if(Node->ACLs[i].Group && Node->ACLs[i].ID != gid) continue;
41 if(Node->ACLs[i].Perms & Permissions) return 0;
44 // Check for allow permissions
45 for(i=0;i<Node->NumACLs;i++)
47 if(Node->ACLs[i].Inv) continue; // Ignore DENYs
48 if(Node->ACLs[i].ID != -1)
50 if(!Node->ACLs[i].Group && Node->ACLs[i].ID != uid) continue;
51 if(Node->ACLs[i].Group && Node->ACLs[i].ID != gid) continue;
54 if((Node->ACLs[i].Perms & Permissions) == Permissions) return 1;
60 * \fn int VFS_GetACL(int FD, tVFS_ACL *Dest)
62 int VFS_GetACL(int FD, tVFS_ACL *Dest)
65 tVFS_Handle *h = VFS_GetHandle(FD);
72 // Root can do anything
73 if(Dest->Group == 0 && Dest->ID == 0) {
79 // Root only file?, fast return
80 if( h->Node->NumACLs == 0 ) {
86 // Check Deny Permissions
87 for(i=0;i<h->Node->NumACLs;i++)
89 if(h->Node->ACLs[i].Group != Dest->Group) continue;
90 if(h->Node->ACLs[i].ID != Dest->ID) continue;
92 Dest->Inv = h->Node->ACLs[i].Inv;
93 Dest->Perms = h->Node->ACLs[i].Perms;