X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Flogin_src%2Fmain.c;h=59b4a784d5bab9d047f3864a267d2ad20efc7aa6;hb=a41c4af4ae30e963f6bc370efad60dacc39b0275;hp=8774298a7612e28a348b46b701653439bb3fd55a;hpb=599466207eaeee9cb2bf397a7a62d0455599d05c;p=tpg%2Facess2.git diff --git a/Usermode/Applications/login_src/main.c b/Usermode/Applications/login_src/main.c index 8774298a..59b4a784 100644 --- a/Usermode/Applications/login_src/main.c +++ b/Usermode/Applications/login_src/main.c @@ -17,8 +17,9 @@ int main(int argc, char *argv[]) int pid, uid = 0; int status = 0; tUserInfo *uinfo; - - printf("\x1B[2J"); // Clear Screen + + printf("\x1B[?25h"); // Re-enable the cursor +// printf("\x1B[2J"); // Clear Screen for(;;) { @@ -37,38 +38,24 @@ int main(int argc, char *argv[]) break; } printf("\n"); - - // Create child process - pid = clone(CLONE_VM, 0); + + uinfo = GetUserInfo(uid); + struct s_sys_spawninfo spawninfo; + spawninfo.flags = 0; + spawninfo.gid = uinfo->GID; + spawninfo.uid = uinfo->UID; + const char *child_argv[2] = {"-", 0}; + const char **child_envp = NULL; + int fds[] = {0, 1, 2}; + pid = _SysSpawn(uinfo->Shell, child_argv, child_envp, 3, fds, &spawninfo); // Error check if(pid == -1) { fprintf(stderr, "Unable to fork the login process!\n"); return -1; } - printf("pid = %i\n", pid); - - // Spawn shell in a child process - if(pid == 0) - { - char *child_argv[2] = {NULL, 0}; - char **child_envp = NULL; - - // Get user information - uinfo = GetUserInfo(uid); - - child_argv[0] = uinfo->Shell; - // Set Environment - setgid(uinfo->GID); - //setuid(uid); - setuid(uinfo->UID); - - execve(uinfo->Shell, child_argv, child_envp); - exit(-1); - } - // Wait for child to terminate - waittid(pid, &status); + _SysWaitTID(pid, &status); } return 0;