Merge branch 'master' of git://ted.mutabah.net/acess2
authorJohn Hodge (sonata) <[email protected]>
Tue, 11 Mar 2014 00:05:37 +0000 (08:05 +0800)
committerJohn Hodge (sonata) <[email protected]>
Tue, 11 Mar 2014 00:05:37 +0000 (08:05 +0800)
Conflicts:
Usermode/Libraries/libpsocket.so_src/pton.c

30 files changed:
AcessNative/acesskernel_src/Makefile
AcessNative/acesskernel_src/main.c
AcessNative/acesskernel_src/syscall_getpath.c [new file with mode: 0644]
AcessNative/acesskernel_src/syscalls.c
AcessNative/ld-acess_src/Makefile
AcessNative/ld-acess_src/exports.c
AcessNative/ld-acess_src/exports.h
AcessNative/ld-acess_src/syscalls.c
AcessNative/libacess-native.so_src/Makefile
AcessNative/libacess-native.so_src/common.h [new file with mode: 0644]
AcessNative/libacess-native.so_src/exports.c
AcessNative/libacess-native.so_src/main.c
AcessNative/syscalls_list.h
KernelLand/Kernel/include/vfs_ext.h
KernelLand/Kernel/vfs/acls.c
KernelLand/Kernel/vfs/dir.c
KernelLand/Kernel/vfs/fs/root.c
KernelLand/Kernel/vfs/open.c
Usermode/Applications/insmod_src/main.c
Usermode/Applications/login_src/main.c
Usermode/Applications/telnet_src/main.c
Usermode/Libraries/ld-acess.so_src/elf.c
Usermode/Libraries/libimage_sif.so_src/main.c
Usermode/Libraries/libnet.so_src/address.c
Usermode/Libraries/libnet.so_src/include_exp/net.h
Usermode/Libraries/libposix.so_src/unistd.c
Usermode/Libraries/libposix.so_src/unistd_crypt.c
Usermode/Libraries/libpsocket.so_src/getaddrinfo.c
Usermode/Libraries/libpsocket.so_src/pton.c
Usermode/Libraries/liburi.so_src/main.c

index 00ba775..9e8ce35 100644 (file)
@@ -30,7 +30,7 @@ N_OBJ := main.o net_wrap.o
 # - Local objects (use the kernel includes)\r
 OBJ := helpers.o threads.o threads_glue.o server.o syscalls.o time.o\r
 OBJ += video.o keyboard.o mouse.o nativefs.o vfs_handle.o ui_sdl.o\r
-OBJ += net.o\r
+OBJ += net.o syscall_getpath.o\r
 \r
 BUILDINFO_OBJ := obj-$(PLATFORM)/buildinfo.o\r
 BUILDINFO_SRC := $(BUILDINFO_OBJ:%.o=%.c)\r
index 61ed0fd..ead4f33 100644 (file)
@@ -39,7 +39,7 @@ extern const char     gsGitHash[];
 extern int     giBuildNumber;
 
 // === GLOBALS ===
-const char     *gsAcessDir = "../Usermode/Output/x86_64";
+const char     *gsAcessDir = "../Usermode/Output/native";
 
 // === CODE ===
 #ifndef __WIN32__
diff --git a/AcessNative/acesskernel_src/syscall_getpath.c b/AcessNative/acesskernel_src/syscall_getpath.c
new file mode 100644 (file)
index 0000000..a47e6c9
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * AcessNative Kernel
+ *
+ * syscall_getpath.c
+ * - Implementation of the SYS_AN_GETPATH system call
+ */
+
+#include <acess.h>
+#include <vfs_int.h>
+
+extern char    *getcwd(char *buf, size_t size);
+
+extern tVFS_NodeType   gNativeFS_FileNodeType;
+extern tVFS_NodeType   gNativeFS_DirNodeType;
+
+int Syscall_AN_GetPath_Real(char *Dst, size_t DstLen, const char *Path)
+{
+       tVFS_Node       *node = VFS_ParsePath(Path, NULL, NULL);
+       if(!node)       return -1;
+
+       const char *relpath = NULL;
+
+       if( node->Type == &gNativeFS_FileNodeType || node->Type == &gNativeFS_DirNodeType )
+       {
+               relpath = node->Data;
+       }
+       else
+       {
+               relpath = NULL;
+       }
+       
+       size_t  ret;
+       if( relpath )
+       {
+               if( relpath[0] == '/' ) {
+                       ret = snprintf(Dst, DstLen, "%s", relpath);
+               }
+               else {
+                       getcwd(Dst, DstLen);
+                       ret = strlen(Dst);
+                       ret += snprintf(Dst+ret, DstLen-ret, "/%s", relpath);
+               }
+       }
+       else
+       {
+               ret = 0;
+       }
+       
+       _CloseNode(node);
+       return ret;
+}
index ae2c92c..344745f 100644 (file)
 // === IMPORTS ===
 extern int     Threads_Fork(void);     // AcessNative only function
 extern int     Threads_Spawn(int nFD, int FDs[], const void *info);
+extern int     Syscall_AN_GetPath_Real(char *Dest, size_t DstLen, const char *Path);
 
 // === TYPES ===
 typedef int    (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int *Sizes);
 
 // === MACROS ===
+#define _SYSCALL_CHKFMT(_name,_fmtstr,Fmt) do{ \
+       if(strcmp(Fmt,_fmtstr) != 0) {\
+               *Errno = EINVAL;\
+               Log_Error("Syscalls", "Call %s takes args '%s', given '%s'", #_name, _fmtstr, Fmt);\
+               return -1;\
+       }\
+} while(0)
 #define SYSCALL6(_name, _fmtstr, _t0, _t1, _t2, _t3, _t4, _t5, _call) int _name(Uint*Errno,const char*Fmt,void*Args,int*Sizes){\
        _t0 a0;_t1 a1;_t2 a2;_t3 a3;_t4 a4;_t5 a5;\
-       if(strcmp(Fmt,_fmtstr)!=0)return 0;\
+       _SYSCALL_CHKFMT(_name,_fmtstr,Fmt);\
        a0 = *(_t0*)Args;Args+=sizeof(_t0);\
        a1 = *(_t1*)Args;Args+=sizeof(_t1);\
        a2 = *(_t2*)Args;Args+=sizeof(_t2);\
@@ -35,7 +43,7 @@ typedef int   (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int
 }
 #define SYSCALL5(_name, _fmtstr, _t0, _t1, _t2, _t3, _t4, _call) int _name(Uint*Errno,const char*Fmt,void*Args,int*Sizes){\
        _t0 a0;_t1 a1;_t2 a2;_t3 a3;_t4 a4;\
-       if(strcmp(Fmt,_fmtstr)!=0)return 0;\
+       _SYSCALL_CHKFMT(_name,_fmtstr,Fmt);\
        a0 = *(_t0*)Args;Args+=sizeof(_t0);\
        a1 = *(_t1*)Args;Args+=sizeof(_t1);\
        a2 = *(_t2*)Args;Args+=sizeof(_t2);\
@@ -46,7 +54,7 @@ typedef int   (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int
 }
 #define SYSCALL4(_name, _fmtstr, _t0, _t1, _t2, _t3, _call) int _name(Uint*Errno,const char*Fmt,void*Args,int*Sizes){\
        _t0 a0;_t1 a1;_t2 a2;_t3 a3;\
-       if(strcmp(Fmt,_fmtstr)!=0)return 0;\
+       _SYSCALL_CHKFMT(_name,_fmtstr,Fmt);\
        a0 = *(_t0*)Args;Args+=sizeof(_t0);\
        a1 = *(_t1*)Args;Args+=sizeof(_t1);\
        a2 = *(_t2*)Args;Args+=sizeof(_t2);\
@@ -57,7 +65,7 @@ typedef int   (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int
 
 #define SYSCALL3(_name, _fmtstr, _t0, _t1, _t2, _call) int _name(Uint*Errno,const char*Fmt,void*Args,int*Sizes){\
        _t0 a0;_t1 a1;_t2 a2;\
-       if(strcmp(Fmt,_fmtstr)!=0)return 0;\
+       _SYSCALL_CHKFMT(_name,_fmtstr,Fmt);\
        a0 = *(_t0*)Args;Args+=sizeof(_t0);\
        a1 = *(_t1*)Args;Args+=sizeof(_t1);\
        a2 = *(_t2*)Args;Args+=sizeof(_t2);\
@@ -67,7 +75,7 @@ typedef int   (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int
 
 #define SYSCALL2(_name, _fmtstr, _t0, _t1, _call) int _name(Uint*Errno,const char*Fmt,void*Args,int*Sizes){\
        _t0 a0;_t1 a1;\
-       if(strcmp(Fmt,_fmtstr)!=0)return 0;\
+       _SYSCALL_CHKFMT(_name,_fmtstr,Fmt);\
        a0 = *(_t0*)Args;Args+=sizeof(_t0);\
        a1 = *(_t1*)Args;Args+=sizeof(_t1);\
        LOG("SYSCALL2 '%s' %p %p", Fmt, (intptr_t)a0,(intptr_t)a1);\
@@ -76,14 +84,14 @@ typedef int (*tSyscallHandler)(Uint *Errno, const char *Format, void *Args, int
 
 #define SYSCALL1(_name, _fmtstr, _t0, _call) int _name(Uint*Errno,const char*Fmt, void*Args,int*Sizes){\
        _t0 a0;\
-       if(strcmp(Fmt,_fmtstr)!=0)return 0;\
+       _SYSCALL_CHKFMT(_name,_fmtstr,Fmt);\
        a0 = *(_t0*)Args;Args+=sizeof(_t0);\
        LOG("SYSCALL1 '%s' %p", Fmt,(intptr_t)a0);\
        _call;\
 }
 
 #define SYSCALL0(_name, _call) int _name(Uint*Errno,const char*Fmt, void*Args,int*Sizes){\
-       if(strcmp(Fmt,"")!=0)return 0;\
+       _SYSCALL_CHKFMT(_name,"",Fmt);\
        LOG("SYSCALL0");\
        _call;\
 }
@@ -167,6 +175,11 @@ SYSCALL4(Syscall_Mount, "ssss", const char *, const char *, const char *, const
 SYSCALL1(Syscall_Chdir, "s", const char *,
        return VFS_ChDir(a0);
 );
+
+SYSCALL2(Syscall_AN_Getpath, "ds", char *, const char *,
+       return Syscall_AN_GetPath_Real(a0, Sizes[0], a1);
+);
+
 SYSCALL0(Syscall_Sleep,
        Threads_Sleep();
        return 0;
@@ -254,6 +267,7 @@ const tSyscallHandler       caSyscalls[] = {
        [SYS_MOUNT]     = Syscall_Mount,
        [SYS_REOPEN]    = NULL, // SYS_REOPEN
        [SYS_CHDIR]     = Syscall_Chdir,
+       [SYS_AN_GETPATH] = Syscall_AN_Getpath,
        
        [SYS_WAITTID]   = Syscall_WaitTID,
        [SYS_SETUID]    = Syscall_SetUID,
@@ -265,8 +279,8 @@ const tSyscallHandler       caSyscalls[] = {
        Syscall_GetGID,
 
        Syscall_Sleep,
-       Syscall_AN_Fork,
-       Syscall_AN_Spawn,
+       [SYS_AN_FORK]  = Syscall_AN_Fork,
+       [SYS_AN_SPAWN] = Syscall_AN_Spawn,
 
        Syscall_SendMessage,
        Syscall_GetMessage,
index 78e0785..b118824 100644 (file)
@@ -22,7 +22,7 @@ endif
 
 CFLAGS   += -Wall
 CFLAGS   += -Werror
-CFLAGS   += -g
+CFLAGS   += -g -std=c99
 CPPFLAGS += -DARCHDIR_is_x86_64=1
 LDFLAGS  += -g -Wl,-T,obj-$(PLATFORM)/link.ld
 
index 6ee2538..a898b5a 100644 (file)
@@ -49,7 +49,7 @@ int acess__SysChdir(const char *Path)
        return _Syscall(SYS_CHDIR, ">s", Path);
 }
 
-int acess__SysOpen(const char *Path, int Flags)
+int acess__SysOpen(const char *Path, unsigned int Flags)
 {
        if( strncmp(Path, "$$$$", 4) == 0 )
        {
@@ -342,7 +342,8 @@ int acess__SysSpawn(const char *binary, const char **argv, const char **envp, in
 
         int    kernel_tid;
         int    newID;
-       newID = _Syscall(SYS_AN_SPAWN, "<d >d >d", sizeof(int), &kernel_tid,
+       newID = _Syscall(SYS_AN_SPAWN, "<d >d >d",
+               sizeof(int), &kernel_tid,
                nfd*sizeof(int), fds,
                info ? sizeof(*info) : 0, info);
 
index e9a4b3b..e8f2e4c 100644 (file)
@@ -9,6 +9,7 @@
 #define _EXPORTS_H_
 
 #include <stddef.h>
+#include <stdint.h>
 
 // Syscall request (used by acess_*)
 extern uint64_t        _Syscall(int SyscallID, const char *ArgTypes, ...);
@@ -26,7 +27,7 @@ extern int    native_execve(const char *filename, const char *const argv[], const c
 extern int     native_spawn(const char *filename, const char *const argv[], const char *const envp[]);
 
 // Syscalls used by the linker
-extern int     acess__SysOpen(const char *Path, int Flags);
+extern int     acess__SysOpen(const char *Path, unsigned int Flags);
 extern void    acess__SysClose(int FD);
 extern size_t  acess__SysRead(int FD, void *Dest, size_t Bytes);
 extern int     acess__SysSeek(int FD, int64_t Offset, int Dir);
index 43dfe26..60b7d95 100644 (file)
@@ -342,12 +342,18 @@ int native_execve(const char *filename, const char *const argv[], const char *co
 int native_spawn(const char *filename, const char *const argv[], const char *const envp[])
 {
        int rv;
-       
+
+       fprintf(stderr, "native_spawn('%s')\n", filename);
+
        #if __WIN32__
        rv = _spawnve(_P_NOWAIT, filename, argv, envp);
        #else
        rv = posix_spawn(NULL, filename, NULL, NULL, (void*)argv, (void*)envp);
        #endif
        
+       if( rv == 0 ) {
+               perror("native_spawn");
+       }
+       
        return rv;
 }
index d67f319..9278311 100644 (file)
@@ -15,6 +15,8 @@ endif
 ifeq ($(PLATFORM),lin)
        BIN := ../libacess-native.so
 endif
+BINLINK := ../../Usermode/Output/native/Libs/$(notdir $(BIN))
+$(warning $(BINLINK))
 
 CFLAGS   += -Wall
 CFLAGS   += -Werror
@@ -27,7 +29,7 @@ DEPFILES := $(DEPFILES:%=%.dep)
 
 .PHONY: all clean
 
-all: $(BIN)
+all: $(BIN) $(BINLINK)
 
 clean:
        $(RM) $(BIN) $(OBJ) $(DEPFILES)
@@ -36,6 +38,10 @@ $(BIN): $(OBJ)
        $(CC) -o $@ $(OBJ) $(LDFLAGS)
        objdump -S $@ > [email protected]
 
+$(BINLINK): $(BIN)
+       @mkdir -p $(dir $@)
+       @cd $(dir $@) && ln -sf ../../../../AcessNative/$(notdir $@)
+
 obj-$(PLATFORM)/%.o: %.c
        @mkdir -p $(dir $@)
        @echo [CC] -o $@
diff --git a/AcessNative/libacess-native.so_src/common.h b/AcessNative/libacess-native.so_src/common.h
new file mode 100644 (file)
index 0000000..7e14f24
--- /dev/null
@@ -0,0 +1,14 @@
+
+#ifndef _LIBACESSNATIVE_COMMON_H_
+#define _LIBACESSNATIVE_COMMON_H_
+
+extern int     giSyscall_ClientID;
+extern void    Request_Preinit(void);
+extern int     acess__SysOpen(const char *Path, unsigned int flags);
+extern int     acessnative_spawn(const char *Binary, int SyscallID, const char * const * argv, const char * const * envp);
+
+#define ENV_VAR_PREOPENS       "AN_PREOPEN"
+#define ENV_VAR_KEY    "ACESSNATIVE_KEY"
+
+#endif
+
index 70c7d77..2f960c4 100644 (file)
@@ -1,3 +1,4 @@
+#include "common.h"
 
 #define acess__SysSpawn        _disabled_acess__SysSpawn
 #include "../ld-acess_src/exports.c"
@@ -14,26 +15,38 @@ int *libc_geterrno(void)
 int acess__SysSpawn(const char *binary, const char **argv, const char **envp, int nfd, int fds[], struct s_sys_spawninfo *info)
 {
         int    argc = 0;
-       while( argv[argc++] );
+       while( argv[argc++] )
+               ;
 
        Debug("_SysSpawn('%s', %p (%i), %p, %i, %p, %p)",
                binary, argv, argc, envp, nfd, fds, info);
 
-        int    kernel_tid;
-        int    newID;
-       newID = _Syscall(SYS_AN_SPAWN, "<d >d >d", sizeof(int), &kernel_tid,
+       char realpath[256];
+       realpath[255] = 0;
+
+       if( _Syscall(SYS_AN_GETPATH, "<d >s", sizeof(realpath)-1, realpath, binary) <= 0 ) {
+               Warning("No translation for path '%s'", binary);
+               acess__errno = -11;
+               return -1;
+       }
+
+       Warning("TODO: Spawn '%s' = '%s'", binary, realpath);
+
+        int    emulated_tid;
+       int newID = _Syscall(SYS_AN_SPAWN, "<d >d >d",
+               sizeof(emulated_tid), &emulated_tid,
                nfd*sizeof(int), fds,
-               info ? sizeof(*info) : 0, info);
-       
+               (info ? sizeof(*info) : 0), info
+               );
 
-       Warning("TODO: Spawn '%s'", binary);
-       // TODO: Translate internal path to actual path 
+       if( newID <= 0 ) {
+               return -1;
+       }
 
-       // TODO: set environment variables for libacess-native
-       // > ACESSNATIVE_KEY=`newID`
-       //native_spawn(binary, argv, envp);
+       if( acessnative_spawn(realpath, newID, argv, envp) ) {
+       }
 
-       return 0;
+       return emulated_tid;
 }
 
 void ldacess_DumpLoadedLibraries(void)
index 900a14c..74d9d3c 100644 (file)
@@ -5,10 +5,10 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
-
-extern int     giSyscall_ClientID;
-extern void    Request_Preinit(void);
-extern int     acess__SysOpen(const char *Path, unsigned int flags);
+#include <stdbool.h>
+#include "common.h"
+#include <stdint.h>
+#include "../ld-acess_src/exports.h"
 
 #ifdef __WINDOWS__
 int DllMain(void)
@@ -40,7 +40,7 @@ int libacessnative_init(int argc, char *argv[], char **envp)
 {
        Request_Preinit();
        
-       const char *preopens = getenv_p(envp, "AN_PREOPEN");
+       const char *preopens = getenv_p(envp, ENV_VAR_PREOPENS);
        printf("preopens = %s\n", preopens);
        if( preopens )
        {
@@ -68,12 +68,44 @@ int libacessnative_init(int argc, char *argv[], char **envp)
                }
        }
 
-//     if( !getenv("ACESSNATIVE_ID")
+//     if( !getenv(ENV_VAR_KEY)
        
        return 0;
 }
 #endif
 
+int acessnative_spawn(const char *Binary, int SyscallID, const char * const * argv, const char * const * envp)
+{
+        int    envc = 0;
+       while( envp[envc++] )
+               envc ++;
+
+       // Set environment variables for libacess-native
+       // > ACESSNATIVE_KEY=`newID`
+       size_t keystr_len = snprintf(NULL, 0, "%s=%i", ENV_VAR_KEY, SyscallID);
+       char keystr[keystr_len+1];
+       snprintf(keystr, keystr_len+1, "%s=%i", ENV_VAR_KEY, SyscallID);
+       bool    bKeyHit = false;
+       
+       const char *newenv[envc+2+1];
+        int    i = 0;
+       for( ; envp[i]; i ++ )
+       {
+               const char      *ev = envp[i];
+               if( strncmp(ev, ENV_VAR_KEY"=", sizeof(ENV_VAR_KEY"=")) == 0 ) {
+                       ev = keystr;
+                       bKeyHit = true;
+               }
+               newenv[i] = ev;
+       }
+       if( !bKeyHit )
+               newenv[i++] = keystr;
+       newenv[i++] = "LD_LIBRARY_PATH=Libs/";  // HACK
+       newenv[i] = NULL;
+       
+       // TODO: Detect native_spawn failing
+       return native_spawn(Binary, argv, newenv);
+}
 
 void Debug(const char *format, ...)
 {
@@ -103,3 +135,9 @@ void __libc_csu_init()
 {
 }
 
+void __stack_chk_fail(void)
+{
+       fprintf(stderr, "__stack_chk_fail");
+       exit(1);
+}
+
index 209380b..5698fd4 100644 (file)
@@ -19,6 +19,8 @@ _(SYS_GETACL),
 _(SYS_MOUNT),
 _(SYS_CHDIR),
 
+_(SYS_AN_GETPATH),
+
 _(SYS_WAITTID),
 _(SYS_SETUID),
 _(SYS_SETGID),
index d18009d..65a8162 100644 (file)
@@ -60,31 +60,12 @@ enum eVFS_SeekDirs
  * \name ACL Permissions
  * \{
  */
-/**
- * \brief Readable
- */
-#define VFS_PERM_READ  0x00000001
-/**
- * \brief Writeable
- */
-#define VFS_PERM_WRITE 0x00000002
-/**
- * \brief Append allowed
- */
-#define VFS_PERM_APPEND        0x00000004
-/**
- * \brief Executable
- */
-#define VFS_PERM_EXECUTE       0x00000008
-/**
- * \brief All permissions granted
- */
-#define VFS_PERM_ALL   0x7FFFFFFF      // Mask for permissions
-/**
- * \brief Denies instead of granting permissions
- * \note Denials take precedence
- */
-#define VFS_PERM_DENY  0x80000000      // Inverts permissions
+#define VFS_PERM_READ  0x00000001      //!< Readable
+#define VFS_PERM_WRITE 0x00000002      //!< Writable
+#define VFS_PERM_APPEND        0x00000004      //!< Appendable (/create file)
+#define VFS_PERM_EXEC  0x00000008      //!< Executable (/Traversable)
+#define VFS_PERM_ALL   0x7FFFFFFF      //!< All permission bits
+#define VFS_PERM_DENY  0x80000000      //!< Flag for denying a permission set (higher precedence)
 /**
  * \}
  */
index d5deb16..7ae50c2 100644 (file)
@@ -10,8 +10,8 @@ Uint  VFS_int_CheckACLs(tVFS_ACL *ACLs, int Num, int bDeny, Uint Perms, tUID UID,
 
 // === GLOBALS ===
 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_EveryoneRW = { {1,-1}, {0,VFS_PERM_ALL^VFS_PERM_EXEC} };
+tVFS_ACL       gVFS_ACL_EveryoneRX = { {1,-1}, {0,VFS_PERM_READ|VFS_PERM_EXEC} };
 tVFS_ACL       gVFS_ACL_EveryoneRO = { {1,-1}, {0,VFS_PERM_READ} };
 
 // === CODE ===
@@ -139,21 +139,21 @@ tVFS_ACL *VFS_UnixToAcessACL(Uint Mode, Uint Owner, Uint Group)
        ret[0].Perm.Inv = 0;  ret[0].Perm.Perms = 0;
        if(Mode & 0400) ret[0].Perm.Perms |= VFS_PERM_READ;
        if(Mode & 0200) ret[0].Perm.Perms |= VFS_PERM_WRITE;
-       if(Mode & 0100) ret[0].Perm.Perms |= VFS_PERM_EXECUTE;
+       if(Mode & 0100) ret[0].Perm.Perms |= VFS_PERM_EXEC;
        
        // Group
        ret[1].Ent.Group = 1; ret[1].Ent.ID = Group;
        ret[1].Perm.Inv = 0;  ret[1].Perm.Perms = 0;
        if(Mode & 0040) ret[1].Perm.Perms |= VFS_PERM_READ;
        if(Mode & 0020) ret[1].Perm.Perms |= VFS_PERM_WRITE;
-       if(Mode & 0010) ret[1].Perm.Perms |= VFS_PERM_EXECUTE;
+       if(Mode & 0010) ret[1].Perm.Perms |= VFS_PERM_EXEC;
        
        // Global
        ret[2].Ent.Group = 1; ret[2].Ent.ID = -1;
        ret[2].Perm.Inv = 0;  ret[2].Perm.Perms = 0;
        if(Mode & 0004) ret[2].Perm.Perms |= VFS_PERM_READ;
        if(Mode & 0002) ret[2].Perm.Perms |= VFS_PERM_WRITE;
-       if(Mode & 0001) ret[2].Perm.Perms |= VFS_PERM_EXECUTE;
+       if(Mode & 0001) ret[2].Perm.Perms |= VFS_PERM_EXEC;
        
        // Return buffer
        return ret;
index add48b0..911eff6 100644 (file)
@@ -74,7 +74,7 @@ int VFS_MkNod(const char *Path, Uint Flags)
        }
 
        // Permissions Check
-       if( !VFS_CheckACL(parent, VFS_PERM_EXECUTE|VFS_PERM_WRITE) ) {
+       if( !VFS_CheckACL(parent, VFS_PERM_EXEC|VFS_PERM_WRITE) ) {
                errno = EACCES;
                goto _error;
        }
index fd667b9..b820297 100644 (file)
@@ -39,8 +39,8 @@ tVFS_ACL      RootFS_DirACLs[3] = {
        {{0,-1}, {0,VFS_PERM_ALL^VFS_PERM_WRITE}}       // World (Nobody)
 };
 tVFS_ACL       RootFS_FileACLs[3] = {
-       {{0,0}, {0,VFS_PERM_ALL^VFS_PERM_EXECUTE}},     // Owner (Root)
-       {{1,0}, {0,VFS_PERM_ALL^VFS_PERM_EXECUTE}},     // Group (Root)
+       {{0,0}, {0,VFS_PERM_ALL^VFS_PERM_EXEC}},        // Owner (Root)
+       {{1,0}, {0,VFS_PERM_ALL^VFS_PERM_EXEC}},        // Group (Root)
        {{0,-1}, {0,VFS_PERM_READ}}     // World (Nobody)
 };
 tVFS_NodeType  gRootFS_DirType = {
index f1a16f3..f0b5734 100644 (file)
@@ -296,7 +296,7 @@ restart_parse:
                pathEle[nextSlash] = 0;
        
                // Check permissions on root of filesystem
-               if( !VFS_CheckACL(curNode, VFS_PERM_EXECUTE) ) {
+               if( !VFS_CheckACL(curNode, VFS_PERM_EXEC) ) {
                        LOG("Permissions failure on '%s'", Path);
                        errno = EPERM;
                        goto _error;
@@ -474,7 +474,7 @@ int VFS_int_CreateHandle( tVFS_Node *Node, tVFS_Mount *Mount, int Mode )
        ENTER("pNode pMount xMode", Node, Mount, Mode);
 
        i = 0;
-       i |= (Mode & VFS_OPENFLAG_EXEC) ? VFS_PERM_EXECUTE : 0;
+       i |= (Mode & VFS_OPENFLAG_EXEC) ? VFS_PERM_EXEC : 0;
        i |= (Mode & VFS_OPENFLAG_READ) ? VFS_PERM_READ : 0;
        i |= (Mode & VFS_OPENFLAG_WRITE) ? VFS_PERM_WRITE : 0;
        
@@ -557,7 +557,7 @@ int VFS_OpenEx(const char *Path, Uint Flags, Uint Mode)
                }
 
                // Check ACLs on the parent
-               if( !VFS_CheckACL(pnode, VFS_PERM_EXECUTE|VFS_PERM_WRITE) ) {
+               if( !VFS_CheckACL(pnode, VFS_PERM_EXEC|VFS_PERM_WRITE) ) {
                        errno = EACCES;
                        goto _pnode_err;
                }
index 78ad0a9..b1b0905 100644 (file)
@@ -6,6 +6,7 @@
  * - Core
  */
 #include <stdio.h>
+#include <string.h>
 #include <errno.h>
 #include <acess/sys.h>
 
index 86b1884..23d9329 100644 (file)
@@ -9,8 +9,8 @@
 #define BUFLEN 1024
 
 // === PROTOTYPES ===
-char   *GetUsername();
-char   *GetPassword();
+char   *GetUsername(void);
+char   *GetPassword(void);
 
 // === CODE ===
 int main(int argc, char *argv[])
@@ -130,10 +130,6 @@ char *_GetString(int bEcho)
  */
 char *GetUsername()
 {
-       char    ret[BUFLEN] = {0};
-        int    pos = 0;
-       char    ch;
-       
        // Prompt the user
        printf("Username: ");
        fflush(stdout);
index 2658548..56cffb4 100644 (file)
@@ -54,7 +54,7 @@ int main(int argc, char *argv[], char *envp[])
                FD_SET(server_fd, &fds);        FD_SET(server_fd, &err_fds);\r
                \r
                // Wait for data (no timeout)\r
-               rv = select(server_fd+1, &fds, NULL, &err_fds, NULL);\r
+               rv = _SysSelect(server_fd+1, &fds, NULL, &err_fds, NULL, 0);\r
                if( rv < 0 )    break;\r
                \r
                // Check for remote data avaliable\r
index 676f5c3..27cf96c 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "common.h"
 #include <stdint.h>
+#include <assert.h>
 #include "elf32.h"
 #include "elf64.h"
 
index 61136a1..176db8d 100644 (file)
@@ -6,9 +6,13 @@
 #include <string.h>
 #include <image.h>
 //#include <image_sif.h>
-#include <acess/sys.h> // _SysDebug
+#include <acess/sys.h> // DEBUGS
 
-#define        _SysDebug(...)  do{}while(0)
+#if ENABLE_DEBUG
+# define DEBUGS(v...)  _SysDebug(v)
+#else
+#define        DEBUGS(...)     do{}while(0)
+#endif
 
 // === STRUCTURES ===
 struct sHeader
@@ -63,7 +67,7 @@ tImage *Image_SIF_Parse(void *Buffer, size_t Size)
         int    sampleSize;
        struct sHeader  *hdr = Buffer;
         
-       _SysDebug("Image_SIF_Parse: (Buffer=%p, Size=0x%x)", Buffer, Size);
+       DEBUGS("Image_SIF_Parse: (Buffer=%p, Size=0x%x)", Buffer, Size);
        
        // Get magic word and determine byte ordering
        if(hdr->Magic == 0x51F0)        // Little Endian
@@ -71,11 +75,11 @@ tImage *Image_SIF_Parse(void *Buffer, size_t Size)
        else if(hdr->Magic == 0xF051)   // Big Endian
                bRevOrder = 1;
        else {
-               _SysDebug(" Image_SIF_Parse: Magic invalid (0x%x)", hdr->Magic);
+               DEBUGS(" Image_SIF_Parse: Magic invalid (0x%x)", hdr->Magic);
                return NULL;
        }
        
-       _SysDebug(" Image_SIF_Parse: bRevOrder = %i", bRevOrder);
+       DEBUGS(" Image_SIF_Parse: bRevOrder = %i", bRevOrder);
        
        // Read flags
        comp = hdr->Flags & 7;
@@ -85,7 +89,7 @@ tImage *Image_SIF_Parse(void *Buffer, size_t Size)
        w = hdr->Width;
        h = hdr->Height;
        
-       _SysDebug(" Image_SIF_Parse: Dimensions %ix%i", w, h);
+       DEBUGS(" Image_SIF_Parse: Dimensions %ix%i", w, h);
        
        // Get image format
        switch(fmt)
@@ -102,7 +106,7 @@ tImage *Image_SIF_Parse(void *Buffer, size_t Size)
                return NULL;
        }
        
-       _SysDebug(" Image_SIF_Parse: sampleSize = %i, fmt = %i", sampleSize, fmt);
+       DEBUGS(" Image_SIF_Parse: sampleSize = %i, fmt = %i", sampleSize, fmt);
        
        fileOfs = sizeof(struct sHeader);
        
@@ -164,7 +168,7 @@ tImage *Image_SIF_Parse(void *Buffer, size_t Size)
                }
                if(bRevOrder)
                        flip_buffer_endian(ret->Data, sampleSize, w*h);
-               _SysDebug("Image_SIF_Parse: Complete at %i bytes", fileOfs);
+               DEBUGS("Image_SIF_Parse: Complete at %i bytes", fileOfs);
                return ret;
        
        // Channel 1.7.8 RLE
index 0430c84..66a28b1 100644 (file)
@@ -160,8 +160,8 @@ static int Net_ParseIPv6Addr(const char *String, uint8_t *Addr)
        k = 0;
        for( ; j < 8; j ++, k++)
        {
-               Addr[j*2] = hi[k]>>8;
-               Addr[j*2+1] = hi[k]&0xFF;
+               Addr[j*2] = low[k]>>8;
+               Addr[j*2+1] = low[k]&0xFF;
        }
        
        return 1;
@@ -187,7 +187,7 @@ int Net_ParseAddress(const char *String, void *Addr)
        return 0;
 }
 
-static const char *Net_PrintIPv4Address(uint8_t *Address)
+static const char *Net_PrintIPv4Address(const uint8_t *Address)
 {
        static __thread char    ret[4*3+3+1];   // '255.255.255.255\0'
        
@@ -196,7 +196,7 @@ static const char *Net_PrintIPv4Address(uint8_t *Address)
        return ret;
 }
 
-static const char *Net_PrintIPv6Address(uint16_t *Address)
+static const char *Net_PrintIPv6Address(const uint16_t *Address)
 {
        static __thread char    ret[8*4+7+1];   // 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF\0'
        #if 0
@@ -215,7 +215,7 @@ static const char *Net_PrintIPv6Address(uint16_t *Address)
        return ret;
 }
 
-const char *Net_PrintAddress(int AddressType, void *Address)
+const char *Net_PrintAddress(int AddressType, const void *Address)
 {
        switch( AddressType )
        {
index 43445d1..5fe4ba1 100644 (file)
@@ -25,7 +25,7 @@ extern int    Net_ParseAddress(const char *String, void *Addr);
  * \param AddressType  Address family as returned by Net_ParseAddress
  * \param Address      Address data
  */
-extern const char *Net_PrintAddress(int AddressType, void *Address);
+extern const char *Net_PrintAddress(int AddressType, const void *Address);
 
 /**
  * \brief Get the size in bytes of an address type
index 0f5bb38..3af7bcb 100644 (file)
@@ -208,7 +208,7 @@ int kill(pid_t pid, int signal)
 
 int select(int nfd, fd_set *rfd, fd_set *wfd, fd_set *efd, struct timeval *timeout)
 {
-       long long int   ltimeout = 0, *ltimeoutp = NULL;
+       int64_t ltimeout = 0, *ltimeoutp = NULL;
        if( timeout )
        {
                ltimeout = timeout->tv_sec*1000 + timeout->tv_usec / 1000;
index a5eebfa..ba58a52 100644 (file)
 // === CODE ===
 char *crypt(const char *key, const char *salt)
 {
+       if( *salt == '$' )
+       {
+               // $x$salt$
+               // x=1 : MD5
+               // x=5 : SHA-256
+               // x=6 : SHA-512
+       }
        return "YIH14pBTDJvJ6"; // 'password' with the salt YI
 }
index fd93503..cb361f9 100644 (file)
@@ -113,9 +113,9 @@ int getaddrinfo(const char *node, const char *service, const struct addrinfo *hi
        // Convert `node` into types
        if( service )
        {
-               char *end;
+               const char *end;
                
-               default_port = strtol(service, &end, 0);
+               default_port = strtol(service, (char**)&end, 0);
                if( *end != '\0' && (hints->ai_flags & AI_NUMERICSERV) )
                {
                        return EAI_NONAME;
index 1ae69c4..ded0068 100644 (file)
@@ -23,10 +23,10 @@ const char *inet_ntop(int af, const void *src, char *dest, size_t len)
        switch(af)
        {
        case AF_INET:
-               str = Net_PrintAddress(4, &((struct in_addr*)src)->s_addr);
+               str = Net_PrintAddress(4, &((const struct in_addr*)src)->s_addr);
                break;
        case AF_INET6:
-               str = Net_PrintAddress(6, ((struct in6_addr*)src)->s6_addr);
+               str = Net_PrintAddress(6, &((const struct in6_addr*)src)->s6_addr);
                break;
        default:
                str = NULL;
index ca71940..1bb76f5 100644 (file)
@@ -64,7 +64,7 @@ tURI *URI_Parse(const char *String)
        // true URI
        if(tmp[0] == ':' && tmp[1] == '/' && tmp[2] == '/')
        {
-                int    hostlen, portlen, pathlen;
+                int    hostlen, portlen;
                tmp += 3;       // Eat '://'
                ret = malloc(sizeof(tURI) + protolen + 1 + strlen(tmp) + 1);
                

UCC git Repository :: git.ucc.asn.au