14 int main(int argc, char *argv[])
16 char *sUsername, *sPassword;
21 printf("\x1B[?25h"); // Re-enable the cursor
22 // printf("\x1B[2J"); // Clear Screen
29 sUsername = GetUsername();
30 sPassword = GetPassword();
31 if( (uid = ValidateUser(sUsername, sPassword)) == -1 )
33 printf("\nInvalid username or password\n");
42 // Create child process
43 pid = clone(CLONE_VM, 0);
46 fprintf(stderr, "Unable to fork the login process!\n");
50 // Spawn shell in a child process
53 char *child_argv[2] = {NULL, 0};
54 char **child_envp = NULL;
56 // Get user information
57 uinfo = GetUserInfo(uid);
59 child_argv[0] = uinfo->Shell;
65 execve(uinfo->Shell, child_argv, child_envp);
69 // Wait for child to terminate
70 waittid(pid, &status);
77 * \fn char *GetUsername()
81 char ret[BUFLEN] = {0};
89 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
92 if( pos <= 0 ) continue;
99 // Echo out to the screen
102 if(pos == BUFLEN-1) break;
113 * \fn char *GetPassword()
122 printf("Password: ");
125 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
128 if( pos <= 0 ) continue;
135 // Don't echo out to the screen
138 if(pos == BUFLEN-1) break;