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 printf("pid = %i\n", pid);
52 // Spawn shell in a child process
55 char *child_argv[2] = {NULL, 0};
56 char **child_envp = NULL;
58 // Get user information
59 uinfo = GetUserInfo(uid);
61 child_argv[0] = uinfo->Shell;
67 execve(uinfo->Shell, child_argv, child_envp);
71 // Wait for child to terminate
72 waittid(pid, &status);
79 * \fn char *GetUsername()
83 char ret[BUFLEN] = {0};
91 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
94 if( pos <= 0 ) continue;
101 // Echo out to the screen
104 if(pos == BUFLEN-1) break;
115 * \fn char *GetPassword()
124 printf("Password: ");
127 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
130 if( pos <= 0 ) continue;
137 // Don't echo out to the screen
140 if(pos == BUFLEN-1) break;