14 int main(int argc, char *argv[])
16 char *sUsername, *sPassword;
23 printf("\x1B[2J"); // Clear Screen
27 sUsername = GetUsername();
28 sPassword = GetPassword();
29 if( (uid = ValidateUser(sUsername, sPassword)) == -1 )
31 printf("\nInvalid username or password for '%s'\n", sUsername);
40 // Create child process
41 pid = clone(CLONE_VM, 0);
44 fprintf(stderr, "Unable to fork the login process!\n");
48 // Spawn shell in a child process
51 char *child_argv[2] = {NULL, 0};
52 char **child_envp = NULL;
54 // Get user information
55 uinfo = GetUserInfo(uid);
57 child_argv[0] = uinfo->Shell;
62 execve(uinfo->Shell, child_argv, child_envp);
66 // Wait for child to terminate
67 waittid(pid, &status);
74 * \fn char *GetUsername()
78 char ret[BUFLEN] = {0};
86 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
95 // Echo out to the screen
98 if(pos == BUFLEN-1) break;
109 * \fn char *GetPassword()
118 printf("Password: ");
121 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
130 // Don't echo out to the screen
133 if(pos == BUFLEN-1) break;