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\n");
41 // Create child process
42 pid = clone(CLONE_VM, 0);
45 fprintf(stderr, "Unable to fork the login process!\n");
49 printf("pid = %i\n", pid);
51 // Spawn shell in a child process
54 char *child_argv[2] = {NULL, 0};
55 char **child_envp = NULL;
57 // Get user information
58 uinfo = GetUserInfo(uid);
60 child_argv[0] = uinfo->Shell;
66 execve(uinfo->Shell, child_argv, child_envp);
70 // Wait for child to terminate
71 waittid(pid, &status);
78 * \fn char *GetUsername()
82 char ret[BUFLEN] = {0};
90 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
93 if( pos <= 0 ) continue;
100 // Echo out to the screen
103 if(pos == BUFLEN-1) break;
114 * \fn char *GetPassword()
123 printf("Password: ");
126 while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
129 if( pos <= 0 ) continue;
136 // Don't echo out to the screen
139 if(pos == BUFLEN-1) break;