14 int main(int argc, char *argv[])
16 char *sUsername, *sPassword;
23 printf("\x1B[2J"); // Clear Screen
26 if(uid == -1) printf("\n");
27 sUsername = GetUsername();
28 sPassword = GetPassword();
30 } while( (uid = ValidateUser(sUsername, sPassword)) == -1 );
33 // Create child process
34 pid = clone(CLONE_VM, 0);
37 fprintf(stderr, "Unable to fork the login process!\n");
41 // Spawn shell in a child process
44 char *child_argv[2] = {NULL, 0};
45 char **child_envp = NULL;
47 // Get user information
48 uinfo = GetUserInfo(uid);
50 child_argv[0] = uinfo->Shell;
55 execve(uinfo->Shell, child_argv, child_envp);
59 // Wait for child to terminate
60 waittid(pid, &status);
67 * \fn char *GetUsername()
79 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
88 // Echo out to the screen
91 if(pos == BUFLEN-1) break;
102 * \fn char *GetPassword()
111 printf("Password: ");
114 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
123 // Don't echo out to the screen
126 if(pos == BUFLEN-1) break;