14 int main(int argc, char *argv[])
16 char *sUsername, *sPassword;
21 printf("\x1B[2J"); // Clear Screen
28 sUsername = GetUsername();
29 sPassword = GetPassword();
30 if( (uid = ValidateUser(sUsername, sPassword)) == -1 )
32 printf("\nInvalid username or password for '%s'\n", sUsername);
41 // Create child process
42 pid = clone(CLONE_VM, 0);
45 fprintf(stderr, "Unable to fork the login process!\n");
49 // Spawn shell in a child process
52 char *child_argv[2] = {NULL, 0};
53 char **child_envp = NULL;
55 // Get user information
56 uinfo = GetUserInfo(uid);
58 child_argv[0] = uinfo->Shell;
64 execve(uinfo->Shell, child_argv, child_envp);
68 // Wait for child to terminate
69 waittid(pid, &status);
76 * \fn char *GetUsername()
80 char ret[BUFLEN] = {0};
88 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
91 if( pos <= 0 ) continue;
98 // Echo out to the screen
101 if(pos == BUFLEN-1) break;
112 * \fn char *GetPassword()
121 printf("Password: ");
124 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
127 if( pos <= 0 ) continue;
134 // Don't echo out to the screen
137 if(pos == BUFLEN-1) break;