Multi-user testing and bugfixing
authorJohn Hodge <tpg@prelude.(none)>
Tue, 19 Jan 2010 06:36:15 +0000 (14:36 +0800)
committerJohn Hodge <tpg@prelude.(none)>
Tue, 19 Jan 2010 06:36:15 +0000 (14:36 +0800)
- Actually changes the UID now
- Added stub normal user 'tpg', no password

Kernel/Makefile.BuildNum
Kernel/include/acess.h
Kernel/syscalls.c
Kernel/threads.c
Modules/IPStack/main.c
Usermode/Applications/Makefile.cfg
Usermode/Applications/Makefile.tpl
Usermode/Applications/init_src/Makefile
Usermode/Applications/login_src/Makefile
Usermode/Applications/login_src/database_tpl.c

index 83ad29a..52c5b78 100644 (file)
@@ -1 +1 @@
-BUILD_NUM = 1370
+BUILD_NUM = 1375
index 24621b9..a87aaec 100644 (file)
 
 #include <arch.h>
 #include <stdarg.h>
+#include "errno.h"
+
+// --- Types ---
+typedef Uint   tUID;
+typedef Uint   tGID;
+typedef Sint64 tTimestamp;
 
 // --- Helper Macros ---
 /**
@@ -358,8 +364,8 @@ extern int  Proc_Spawn(char *Path);
 extern void    Threads_Exit();
 extern void    Threads_Yield();
 extern void    Threads_Sleep();
-extern int     Threads_GetUID();
-extern int     Threads_GetGID();
+extern tUID    Threads_GetUID();
+extern tGID    Threads_GetGID();
 extern int     SpawnTask(tThreadFunction Function, void *Arg);
 extern Uint    *Threads_GetCfgPtr(int Id);
 /**
index ba9051a..a555720 100644 (file)
@@ -28,8 +28,10 @@ extern Uint  Binary_Load(char *file, Uint *entryPoint);
 extern int     Threads_SetName(char *NewName);
 extern int     Threads_GetPID();
 extern int     Threads_GetTID();
-extern int     Threads_GetUID();
-extern int     Threads_GetGID();
+extern tUID    Threads_GetUID();
+extern int     Threads_SetUID(Uint *errno, tUID ID);
+extern tGID    Threads_GetGID();
+extern int     Threads_SetGID(Uint *errno, tGID ID);
 
 // === PROTOTYPES ===
  int   Syscall_ValidString(Uint Addr);
@@ -40,7 +42,7 @@ extern int    Threads_GetGID();
 void SyscallHandler(tSyscallRegs *Regs)
 {
        Uint64  ret = 0;
-       Uint    err = 0;
+       Uint    err = -EOK;
        
        ENTER("iThread iNum", Threads_GetTID(), Regs->Num);
        if(Regs->Num < NUM_SYSCALLS)
@@ -104,8 +106,8 @@ void SyscallHandler(tSyscallRegs *Regs)
        case SYS_GETGID:        ret = Threads_GetGID(); break;
        
        // -- Set User/Group IDs
-       case SYS_SETUID:        Log("Setting User ID to %i", Regs->Arg1);       break;
-       case SYS_SETGID:        Log("Setting Group ID to %i", Regs->Arg1);      break;
+       case SYS_SETUID:        ret = Threads_SetUID(&err, Regs->Arg1); break;
+       case SYS_SETGID:        ret = Threads_SetGID(&err, Regs->Arg1); break;
        
        // -- Send Message
        case SYS_SENDMSG:
index 90eb740..890f32d 100644 (file)
@@ -41,8 +41,10 @@ void Threads_Wake(tThread *Thread);
 void   Threads_AddActive(tThread *Thread);
  int   Threads_GetPID();
  int   Threads_GetTID();
- int   Threads_GetUID();
- int   Threads_GetGID();
+tUID   Threads_GetUID();
+ int   Threads_SetUID(Uint *Errno, tUID ID);
+tGID   Threads_GetGID();
+ int   Threads_SetGID(Uint *Errno, tUID ID);
 void   Threads_Dump();
 
 // === GLOBALS ===
@@ -616,14 +618,40 @@ int Threads_GetTID()
 {
        return Proc_GetCurThread()->TID;
 }
-int Threads_GetUID()
+tUID Threads_GetUID()
 {
-       return Proc_GetCurThread()->UID;
+       tThread *t = Proc_GetCurThread();
+       int ret = t->UID;
+       Log("Threads_GetUID: TID %i, return %i", t->TID, ret);
+       return ret;
+}
+int Threads_SetUID(Uint *Errno, tUID ID)
+{
+       tThread *t = Proc_GetCurThread();
+       if( t->UID != 0 ) {
+               *Errno = -EACCES;
+               return -1;
+       }
+       Log("Threads_SetUID - Setting User ID to %i", ID);
+       t->UID = ID;
+       return 0;
 }
-int Threads_GetGID()
+
+tGID Threads_GetGID()
 {
        return Proc_GetCurThread()->GID;
 }
+int Threads_SetGID(Uint *Errno, tGID ID)
+{
+       tThread *t = Proc_GetCurThread();
+       if( t->UID != 0 ) {
+               *Errno = -EACCES;
+               return -1;
+       }
+       Log("Threads_SetGID - Setting Group ID to %i", ID);
+       t->GID = ID;
+       return 0;
+}
 
 /**
  * \fn void Threads_Dump()
index 76a18f0..831000a 100644 (file)
@@ -3,7 +3,7 @@
  * - Stack Initialisation
  */
 #define DEBUG  0
-#define VERSION        ((0<<8)|10)
+#define VERSION        VER3(0,10,0)
 #include "ipstack.h"
 #include "link.h"
 #include <modules.h>
index 0418fb7..bc33f90 100644 (file)
@@ -12,3 +12,4 @@ ASFLAGS = -felf
 CPPFLAGS = -I$(ACESSUSERDIR)/include/
 CFLAGS   = -fno-stack-protector $(CPPFLAGS)
 LDFLAGS  = -T $(ACESSUSERDIR)/Libraries/acess.ld -L $(ACESSUSERDIR)/Libraries -I /Acess/Libs/ld-acess.so -lc
+DIR = Bin
index d358270..d18e52e 100644 (file)
@@ -13,7 +13,7 @@ clean:
        @$(RM) $(OBJ) $(BIN) $(BIN).dsm Map.txt
 
 install: $(BIN)
-       $(xCP) $(BIN) $(DISTROOT)/Bin/
+       $(xCP) $(BIN) $(DISTROOT)/$(DIR)/
 
 $(BIN): $(OBJ)
        @echo --- $(LD) -o $@
index 23d7c27..f60ea49 100644 (file)
@@ -8,5 +8,6 @@ LDFLAGS  +=
 
 BIN = ../init
 OBJ = main.o
+DIR = SBin
 
 -include ../Makefile.tpl
index 239f6ff..63909f6 100644 (file)
@@ -6,5 +6,6 @@ DBTYPE = tpl
 
 OBJ = main.o database_$(DBTYPE).o
 BIN = ../login
+DIR = SBin
 
 -include ../Makefile.tpl
index de903d5..0f79469 100644 (file)
@@ -22,9 +22,11 @@ tUserInfo    gUserInfo;
  */
 int ValidateUser(char *Username, char *Password)
 {
+       printf("Username: %s\n", Username);
        if(Username == NULL)    return -1;
        if(Password == NULL)    return -1;
        if(strcmp(Username, "root") == 0)       return 0;
+       if(strcmp(Username, "tpg") == 0)        return 1;
        return -1;
 }
 
@@ -33,13 +35,22 @@ int ValidateUser(char *Username, char *Password)
  * \brief Gets a users information
  */
 tUserInfo *GetUserInfo(int UID)
-{
-       if(UID != 0)    return NULL;
-       
-       gUserInfo.UID = 0;
-       gUserInfo.GID = 0;
+{      
+       gUserInfo.UID = UID;
+       gUserInfo.GID = UID;
        gUserInfo.Shell = "/Acess/Bin/CLIShell";
-       gUserInfo.Home = "/Acess/Root";
+       switch(UID)
+       {
+       case 0:
+               gUserInfo.Home = "/Acess/Root";
+               break;
+       case 1:
+               gUserInfo.Home = "/Acess/Users/tpg";
+               break;
+       default:
+               gUserInfo.Home = "/Acess/Users/Guest";
+               break;
+       }
        return &gUserInfo;
 }
 

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