diff --git a/bin/login/main.c b/bin/login/main.c index 576dc01..b18fdd5 100644 --- a/bin/login/main.c +++ b/bin/login/main.c @@ -63,6 +63,20 @@ static char *argv_shell[2] = { "shell", NULL, }; // ARGV For Initial Proccess static char *envp_shell[6] = { "HOME=/", "PWD=/", "PATH=/bin:/sbin:/usr/bin:/usr/sbin", "USER=root", "GROUP=admin", NULL, }; //ENVP For Initial Proccess + +static char *envp_init[11] = { + "HOST=Dev.uBixOS.com", + "TERM=xterm", + "SHELL=/bin/sh", + "HOME=/", + "PWD=/", + "PATH=/bin:/sbin:/usr/bin:/usr/sbin", + "USER=root", + "LOGNAME=root", + "GROUP=admin", + "LD_LIBRARY_PATH=/lib:/usr/lib", + NULL, }; //ENVP For Initial Proccess + int main(int argc, char **argv, char **env) { FILE *fd; @@ -140,7 +154,7 @@ fclose(fd); //chdir(data[i].path); chdir("sys:/bin/"); - execve(data[i].shell,argv_shell,envp_shell); + execve(data[i].shell,argv_shell,envp_init); printf("Error: Problem Starting Shell\n"); exit(-1); } diff --git a/debug/getrlimit.c b/debug/getrlimit.c new file mode 100644 index 0000000..620975e --- /dev/null +++ b/debug/getrlimit.c @@ -0,0 +1,13 @@ +#include +#include +#include + + + +int main(int argc, char **argv) { + struct rlimit rl; + if (getrlimit(RLIMIT_NOFILE, &rl) != -1) + printf("cur: %i, max: %i\n", rl.rlim_cur, rl.rlim_max); + + return(0); +} diff --git a/etc/userdb b/etc/userdb index ed464e7..def853f 100644 --- a/etc/userdb +++ b/etc/userdb Binary files differ diff --git a/sys/include/sys/resource.h b/sys/include/sys/resource.h new file mode 100644 index 0000000..b831da5 --- /dev/null +++ b/sys/include/sys/resource.h @@ -0,0 +1,85 @@ +/*- + * Copyright (c) 2002-2018 The UbixOS Project. + * All rights reserved. + * + * This was developed by Christopher W. Olsen for the UbixOS Project. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors. + * 2) Redistributions in binary form must reproduce the above copyright notice, this list of + * conditions, the following disclaimer and the list of authors in the documentation and/or + * other materials provided with the distribution. + * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to + * endorse or promote products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_RESOURCE_H_ +#define _SYS_RESOURCE_H_ + +#include + +/* + * Resource limits + */ +#define RLIMIT_CPU 0 /* maximum cpu time in seconds */ +#define RLIMIT_FSIZE 1 /* maximum file size */ +#define RLIMIT_DATA 2 /* data size */ +#define RLIMIT_STACK 3 /* stack size */ +#define RLIMIT_CORE 4 /* core file size */ +#define RLIMIT_RSS 5 /* resident set size */ +#define RLIMIT_MEMLOCK 6 /* locked-in-memory address space */ +#define RLIMIT_NPROC 7 /* number of processes */ +#define RLIMIT_NOFILE 8 /* number of open files */ +#define RLIMIT_SBSIZE 9 /* maximum size of all socket buffers */ +#define RLIMIT_VMEM 10 /* virtual process size (incl. mmap) */ +#define RLIMIT_AS RLIMIT_VMEM /* standard name for RLIMIT_VMEM */ +#define RLIMIT_NPTS 11 /* pseudo-terminals */ +#define RLIMIT_SWAP 12 /* swap used */ +#define RLIMIT_KQUEUES 13 /* kqueues allocated */ +#define RLIMIT_UMTXP 14 /* process-shared umtx */ + +#define RLIM_NLIMITS 15 /* number of resource limits */ + + +/* + * Resource limit string identifiers + */ + +static const char *rlimit_ident[RLIM_NLIMITS] = { + "cpu", + "fsize", + "data", + "stack", + "core", + "rss", + "memlock", + "nproc", + "nofile", + "sbsize", + "vmem", + "npts", + "swap", + "kqueues", + "umtx", +}; + + +struct rlimit { + rlim_t rlim_cur; /* current (soft) limit */ + rlim_t rlim_max; /* maximum value for rlim_cur */ +}; + +#endif /* !_SYS_RESOURCE_H_ */ diff --git a/sys/include/sys/thread.h b/sys/include/sys/thread.h index 23b5d1f..13d720d 100644 --- a/sys/include/sys/thread.h +++ b/sys/include/sys/thread.h @@ -32,6 +32,7 @@ #include #include #include +#include #define O_FILES 64 @@ -46,6 +47,7 @@ int abi; sigset_t sigmask; struct sigaction sigact[128]; + struct rlimit rlim[RLIM_NLIMITS]; }; #endif /* END _SYS_THREAD_H */ diff --git a/sys/kernel/access.c b/sys/kernel/access.c index 8d36fd3..2e5df39 100644 --- a/sys/kernel/access.c +++ b/sys/kernel/access.c @@ -42,7 +42,6 @@ ************************************************************************/ int sys_setUID(struct thread *td, struct sys_setUID_args *args) { - kprintf("Here?\n"); if (_current->uid == 0x0) { _current->uid = args->uid; return (0); diff --git a/sys/kernel/gen_calls.c b/sys/kernel/gen_calls.c index 5d3f329..f3d950c 100644 --- a/sys/kernel/gen_calls.c +++ b/sys/kernel/gen_calls.c @@ -189,7 +189,7 @@ if (args->op == 10) { //kprintf("SETGSBASE: 0x%X:0x%X", args->parms, args->parms[0]); segbase = args->parms; - kprintf("SGS: [0x%X:0x%X]", segbase[0], segbase[1]); + //kprintf("SGS: [0x%X:0x%X]", segbase[0], segbase[1]); base_addr = (uint32_t) segbase[0]; struct gdtDescriptor *tmpDesc = 0x0; @@ -372,3 +372,18 @@ return (error); } + +int sys_getrlimit(struct thread *thr, struct sys_getrlimit *args) { + int error = 0; + + switch(args->resource) { + } + + return(error); +} + +int sys_setrlimit(struct thread *thr, struct sys_setrlimit *args) { + int error = 0; + + return(error); +} diff --git a/sys/kernel/syscall_posix.c b/sys/kernel/syscall_posix.c index 15cbb17..f7d8e0e 100644 --- a/sys/kernel/syscall_posix.c +++ b/sys/kernel/syscall_posix.c @@ -77,7 +77,7 @@ } else if ((int) systemCalls_posix[code].sc_status == SYSCALL_NOTIMP) { kprintf("Not Implemented Call: [%i][%s]\n", code, systemCalls_posix[code].sc_name); - frame->tf_eax = -1; + frame->tf_eax = 22;//-1; frame->tf_edx = 0x0; frame->tf_eflags |= PSL_C; } @@ -115,6 +115,7 @@ frame->tf_eax = td->td_retval[0]; frame->tf_edx = td->td_retval[1]; frame->tf_eflags |= PSL_C; + kprintf("SC[%i][%s][%i][%i]\n", code, systemCalls_posix[code].sc_name, frame->tf_eax, frame->tf_edx); break; } } diff --git a/sys/kernel/vfs_calls.c b/sys/kernel/vfs_calls.c index 9c4ed05..067390f 100644 --- a/sys/kernel/vfs_calls.c +++ b/sys/kernel/vfs_calls.c @@ -60,7 +60,7 @@ td->td_retval[0] = fd; } - //kprintf("sO: 0x%X:%s:%i", args->mode, args->path, td->td_retval[0]); + //kprintf("sO: 0x%X:%s:", args->mode, args->path, td->td_retval[0]); return (error); } @@ -94,7 +94,7 @@ error = -1; /* - kprintf("[sOA: 0x%X:%s:%s:%i]", args->flag, args->mode, args->path, td->td_retval[0]); + kprintf("[sOA: 0x%X:%s:%s:]", args->flag, args->mode, args->path, td->td_retval[0]); if ((args->flag & O_RDONLY) == O_RDONLY) kprintf("O_RDONLY"); @@ -114,7 +114,7 @@ td->td_retval[0] = fd; } - //kprintf("[sOA: 0x%X:%s:%s:%i]", args->flag, args->mode, args->path, td->td_retval[0]); + //kprintf("[sOA: 0x%X:%s:%s:]", args->flag, args->mode, args->path, td->td_retval[0]); return (error); } @@ -126,11 +126,11 @@ getfd(td, &fd, args->fd); #ifdef DEBUG_VFS_CALLS - kprintf("[sC:%i:0x%X:0x%X]", args->fd, fd, fd->fd); + kprintf("[sC::0x%X:0x%X]", args->fd, fd, fd->fd); #endif if (fd == 0x0) { - kprintf("COULDN'T FIND FD: %i", args->fd); + kprintf("COULDN'T FIND FD: ", args->fd); td->td_retval[0] = -1; } else { @@ -157,7 +157,7 @@ if (!fclose(fd->fd)) td->td_retval[0] = -1; else { - kprintf("DESTROY: %i!!!!!!!!!!!!!!!!!!!!!!!!!!!!", args->fd); + kprintf("DESTROY: !!!!!!!!!!!!!!!!!!!!!!!!!!!!", args->fd); fdestroy(td, fd, args->fd); td->td_retval[0] = 0; } @@ -198,8 +198,8 @@ } else { nbytes = (args->nbyte - (pFD->headPB->nbytes - pFD->headPB->offset) <= 0) ? args->nbyte : (pFD->headPB->nbytes - pFD->headPB->offset); - //kprintf("[unb: %i, nbs: %i, bf: 0x%X]", args->nbyte, nbytes, fd->fd->buffer); - //kprintf("PR: [%i]", nbytes); + //kprintf("[unb: , nbs: %i, bf: 0x%X]", args->nbyte, nbytes, fd->fd->buffer); + //kprintf("PR: []", nbytes); memcpy(args->buf, pFD->headPB->buffer + pFD->headPB->offset, nbytes); pFD->headPB->offset += nbytes; @@ -215,7 +215,7 @@ } break; default: - //kprintf("[r:0x%X:%i:%i:%s]",fd->fd, args->fd, fd->fd_type, fd->fd->fileName); + //kprintf("[r:0x%X::%i:%s]",fd->fd, args->fd, fd->fd_type, fd->fd->fileName); td->td_retval[0] = fread(args->buf, args->nbyte, 1, fd->fd); } } @@ -338,7 +338,7 @@ else { getfd(td, &fd, uap->fd); - kprintf("[fd: %i:0x%X, fd_type: %i]", uap->fd, fd, fd->fd_type); + kprintf("[fd: :0x%X, fd_type: %i]", uap->fd, fd, fd->fd_type); switch (fd->fd_type) { case 3: /* XXX - Temp Pipe Stuff */ @@ -346,7 +346,7 @@ pBuf = (struct pipeBuf *) kmalloc(sizeof(struct pipeBuf)); pBuf->buffer = kmalloc(uap->nbyte); - //kprintf("[unb: %i, nbs: %i, bf: 0x%X]", uap->nbyte, nbytes, fd->fd->buffer); + //kprintf("[unb: , nbs: %i, bf: 0x%X]", uap->nbyte, nbytes, fd->fd->buffer); memcpy(pBuf->buffer, uap->buf, uap->nbyte); pBuf->nbytes = uap->nbyte; @@ -362,13 +362,13 @@ pFD->bCNT++; td->td_retval[0] = nbytes; - //kprintf("[PW: %i:%i]", nbytes, fd->fd->offset); + //kprintf("[PW: :%i]", nbytes, fd->fd->offset); break; default: - kprintf("[%i]", uap->nbyte); + kprintf("[]", uap->nbyte); buffer = kmalloc(uap->nbyte); memcpy(buffer, uap->buf, uap->nbyte); - kprintf("(%i) %s", uap->fd, uap->buf); + kprintf("() %s", uap->fd, uap->buf); kfree(buffer); td->td_retval[0] = uap->nbyte; } @@ -378,13 +378,14 @@ } int sys_access(struct thread *td, struct sys_access_args *args) { - kprintf("%s:%i", args->path, args->amode); + /* XXX - Need to impliment */ + //kprintf("SA:%s:", args->path, args->amode); td->td_retval[0] = 0; return (0); } int sys_getdirentries(struct thread *td, struct sys_getdirentries_args *args) { - //kprintf("GDE: [%i:%i:0x%X]", args->fd, args->count, args->basep); + //kprintf("GDE: [:%i:0x%X]", args->fd, args->count, args->basep); struct file *fd = 0x0; getfd(td, &fd, args->fd); @@ -414,7 +415,7 @@ } int sys_readlink(struct thread *thr, struct sys_readlink_args *args) { - kprintf("RL: %s:%i\n", args->path, args->count); + kprintf("RL: %s:\n", args->path, args->count); //Return Error thr->td_retval[0] = 2; diff --git a/tools/makeuser.c b/tools/makeuser.c index 5041dd7..d06d36f 100644 --- a/tools/makeuser.c +++ b/tools/makeuser.c @@ -61,11 +61,11 @@ password[1].gid = 1; sprintf(password[2].username, "reddawg"); sprintf(password[2].passwd, "temp123"); - sprintf(password[2].shell, "sys:/bin/shell"); - sprintf(password[2].realname, "Christopher"); + sprintf(password[2].shell, "sys:/bin/sh"); + sprintf(password[2].realname, "Christopher W. Olsen"); sprintf(password[2].path, "reddawg"); password[2].uid = 1000; - password[2].gid = 1000; + password[2].gid = 0; fwrite(password, 4096, 1, out); fclose(out); for (i = 0; i < 3; i++) { diff --git a/tools/userdb b/tools/userdb index ed464e7..def853f 100644 --- a/tools/userdb +++ b/tools/userdb Binary files differ