extern int Proc_Execve(char *File, char **ArgV, char **EnvP);
extern Uint Binary_Load(char *file, Uint *entryPoint);
extern int VFS_FInfo(int FD, void *Dest, int MaxACLs);
+extern int VFS_GetACL(int FD, void *Dest);
extern int Threads_SetName(char *NewName);
extern int Threads_GetPID();
extern int Threads_GetTID();
extern int Threads_GetGID();
// === CODE ===
+// TODO: Do sanity checking on arguments, ATM the user can really fuck with the kernel
void SyscallHandler(tSyscallRegs *Regs)
{
Uint64 ret = 0;
ret = VFS_FInfo( Regs->Arg1, (void*)Regs->Arg2, Regs->Arg3 );
break;
+ case SYS_GETACL:
+ ret = VFS_GetACL( Regs->Arg1, (void*)Regs->Arg2 );
+ break;
+
case SYS_READDIR:
ret = VFS_ReadDir( Regs->Arg1, (void*)Regs->Arg2 );
break;
#include "vfs_int.h"
// === GLOBALS ===
-tVFS_ACL gVFS_ACL_EveryoneRWX = { {0,-1}, {0,VFS_PERM_ALL} };
-tVFS_ACL gVFS_ACL_EveryoneRW = { {0,-1}, {0,VFS_PERM_ALL^VFS_PERM_EXECUTE} };
-tVFS_ACL gVFS_ACL_EveryoneRX = { {0,-1}, {0,VFS_PERM_READ|VFS_PERM_EXECUTE} };
-tVFS_ACL gVFS_ACL_EveryoneRO = { {0,-1}, {0,VFS_PERM_READ} };
+tVFS_ACL gVFS_ACL_EveryoneRWX = { {1,-1}, {0,VFS_PERM_ALL} };
+tVFS_ACL gVFS_ACL_EveryoneRW = { {1,-1}, {0,VFS_PERM_ALL^VFS_PERM_EXECUTE} };
+tVFS_ACL gVFS_ACL_EveryoneRX = { {1,-1}, {0,VFS_PERM_READ|VFS_PERM_EXECUTE} };
+tVFS_ACL gVFS_ACL_EveryoneRO = { {1,-1}, {0,VFS_PERM_READ} };
// === CODE ===
/**
return 0;
}
+/**
+ * \fn int VFS_GetACL(int FD, tVFS_ACL *Dest)
+ */
+int VFS_GetACL(int FD, tVFS_ACL *Dest)
+{
+ int i;
+ tVFS_Handle *h = VFS_GetHandle(FD);
+
+ // Error check
+ if(!h) return -1;
+
+ // Root can do anything
+ if(Dest->Group == 0 && Dest->ID == 0) {
+ Dest->Inv = 0;
+ Dest->Perms = -1;
+ return 1;
+ }
+
+ // Root only file?, fast return
+ if( h->Node->NumACLs == 0 ) {
+ Dest->Inv = 0;
+ Dest->Perms = 0;
+ return 0;
+ }
+
+ // Check Deny Permissions
+ for(i=0;i<h->Node->NumACLs;i++)
+ {
+ if(h->Node->ACLs[i].Group != Dest->Group) continue;
+ if(h->Node->ACLs[i].ID != Dest->ID) continue;
+
+ Dest->Inv = h->Node->ACLs[i].Inv;
+ Dest->Perms = h->Node->ACLs[i].Perms;
+ return 1;
+ }
+
+
+ Dest->Inv = 0;
+ Dest->Perms = 0;
+ return 0;
+}
char tmpPath[1024];\r
char *fileName;\r
t_sysFInfo info;\r
+ t_sysACL acl;\r
\r
// Generate Directory Path\r
if(argc > 1)\r
finfo(fp, &info, 0);\r
close(fp);\r
\r
+ //Print Mode\r
+ //#if 0\r
+ acl.group = 0; acl.id = info.uid;\r
+ _SysGetACL(fp, &acl);\r
+ if(acl.perms & 1) modeStr[0] = 'r'; else modeStr[0] = '-';\r
+ if(acl.perms & 2) modeStr[1] = 'w'; else modeStr[1] = '-';\r
+ if(acl.perms & 8) modeStr[2] = 'x'; else modeStr[2] = '-';\r
+ acl.group = 1; acl.id = info.gid;\r
+ _SysGetACL(fp, &acl);\r
+ if(acl.perms & 1) modeStr[3] = 'r'; else modeStr[3] = '-';\r
+ if(acl.perms & 1) modeStr[4] = 'w'; else modeStr[4] = '-';\r
+ if(acl.perms & 1) modeStr[5] = 'x'; else modeStr[5] = '-';\r
+ acl.group = 1; acl.id = -1;\r
+ _SysGetACL(fp, &acl);\r
+ if(acl.perms & 1) modeStr[6] = 'r'; else modeStr[6] = '-';\r
+ if(acl.perms & 1) modeStr[7] = 'w'; else modeStr[7] = '-';\r
+ if(acl.perms & 1) modeStr[8] = 'x'; else modeStr[8] = '-';\r
+ write(_stdout, 10, modeStr);\r
+ //#endif\r
+ \r
// Colour Code\r
if(info.flags & FILEFLAG_DIRECTORY) // Directory: Green\r
write(_stdout, 6, "\x1B[32m");\r
else\r
write(_stdout, 6, "\x1B[37m"); // Default: White\r
- \r
- //Print Mode\r
- #if 0\r
- if(stats.st_mode & 0400) modeStr[0] = 'R'; else modeStr[0] = '-';\r
- if(stats.st_mode & 0200) modeStr[1] = 'W'; else modeStr[1] = '-';\r
- if(stats.st_mode & 0100) modeStr[2] = 'X'; else modeStr[2] = '-';\r
- if(stats.st_mode & 0040) modeStr[3] = 'R'; else modeStr[3] = '-';\r
- if(stats.st_mode & 0020) modeStr[4] = 'W'; else modeStr[4] = '-';\r
- if(stats.st_mode & 0010) modeStr[5] = 'X'; else modeStr[5] = '-';\r
- if(stats.st_mode & 0004) modeStr[6] = 'R'; else modeStr[6] = '-';\r
- if(stats.st_mode & 0002) modeStr[7] = 'W'; else modeStr[7] = '-';\r
- if(stats.st_mode & 0001) modeStr[8] = 'X'; else modeStr[8] = '-';\r
- write(_stdout, 10, modeStr);\r
- #endif\r
- \r
// Print Name\r
write(_stdout, strlen(fileName), fileName);\r
// Print slash if applicable\r
write(_stdout, 6, "\x1B[37m");\r
\r
// Put Size\r
- printf(" Size: %i", info.size);\r
+ printf("\n", info.size);\r
\r
- write(_stdout, 1, "\n");\r
+ //write(_stdout, 1, "\n");\r
}\r
// Close Directory\r
close(dp);\r
SYSCALL4 write, SYS_WRITE ; int, int64_t, void*
SYSCALL4 seek, SYS_SEEK ; int, int64_t, int
SYSCALL3 finfo, SYS_FINFO ; int, void*, int
-SYSCALL2 readdir, SYS_READDIR
+SYSCALL2 readdir, SYS_READDIR ; int, char*
+SYSCALL2 _SysGetACL, SYS_GETACL ; int, void*
// === TYPES ===
struct s_sysACL {
- uint32_t object;
- uint32_t perms;
+ union {
+ struct {
+ unsigned group: 1;
+ unsigned id: 31;
+ };
+ uint32_t object;
+ }
+ union {
+ struct {
+ unsigned invert: 1;
+ unsigned perms: 31;
+ };
+ uint32_t rawperms;
+ }
};
struct s_sysFInfo {
uint uid, gid;
struct s_sysACL acls[];
};
typedef struct s_sysFInfo t_sysFInfo;
+typedef struct s_sysACL t_sysACL;
// === FUNCTIONS ===
void _SysDebug(char *str, ...);
int ioctl(int fd, int id, void *data);
int finfo(int fd, t_sysFInfo *info, int maxacls);
int readdir(int fd, char *dest);
+ int _SysGetACL(int fd, t_sysACL *dest);
// --- MEMORY ---
uint64_t _SysGetPhys(uint vaddr);