git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Usermode/login - Made the login process re-enable the cursor
[tpg/acess2.git]
/
Usermode
/
Applications
/
login_src
/
main.c
diff --git
a/Usermode/Applications/login_src/main.c
b/Usermode/Applications/login_src/main.c
index
5453283
..
5ece357
100644
(file)
--- a/
Usermode/Applications/login_src/main.c
+++ b/
Usermode/Applications/login_src/main.c
@@
-14,22
+14,30
@@
char *GetPassword();
int main(int argc, char *argv[])
{
char *sUsername, *sPassword;
int main(int argc, char *argv[])
{
char *sUsername, *sPassword;
- int pid, uid;
+ int pid, uid
= 0
;
int status = 0;
tUserInfo *uinfo;
int status = 0;
tUserInfo *uinfo;
-
- putchar('\n');
+
+ printf("\x1B[?25h"); // Re-enable the cursor
+ printf("\x1B[2J"); // Clear Screen
+
for(;;)
{
// Validate User
for(;;)
{
// Validate User
- do {
+ for(;;)
+ {
sUsername = GetUsername();
sPassword = GetPassword();
sUsername = GetUsername();
sPassword = GetPassword();
- } while( (uid = ValidateUser(sUsername, sPassword)) == -1 );
- putchar('\n');
-
- // Get user information
- uinfo = GetUserInfo(uid);
+ if( (uid = ValidateUser(sUsername, sPassword)) == -1 )
+ {
+ printf("\nInvalid username or password\n");
+ free(sUsername);
+ free(sPassword);
+ }
+ else
+ break;
+ }
+ printf("\n");
// Create child process
pid = clone(CLONE_VM, 0);
// Create child process
pid = clone(CLONE_VM, 0);
@@
-39,15
+47,24
@@
int main(int argc, char *argv[])
return -1;
}
return -1;
}
+ printf("pid = %i\n", pid);
+
// Spawn shell in a child process
if(pid == 0)
{
// Spawn shell in a child process
if(pid == 0)
{
- char *argv[2] = {uinfo->Shell, 0};
- char **envp = NULL;
+ char *child_argv[2] = {NULL, 0};
+ char **child_envp = NULL;
+
+ // Get user information
+ uinfo = GetUserInfo(uid);
+
+ child_argv[0] = uinfo->Shell;
+ // Set Environment
setgid(uinfo->GID);
setgid(uinfo->GID);
- setuid(uid);
+ //setuid(uid);
+ setuid(uinfo->UID);
- execve(uinfo->Shell,
argv,
envp);
+ execve(uinfo->Shell,
child_argv, child_
envp);
exit(-1);
}
exit(-1);
}
@@
-63,7
+80,7
@@
int main(int argc, char *argv[])
*/
char *GetUsername()
{
*/
char *GetUsername()
{
- char ret[BUFLEN];
+ char ret[BUFLEN]
= {0}
;
int pos = 0;
char ch;
int pos = 0;
char ch;
@@
-74,6
+91,7
@@
char *GetUsername()
while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
{
if(ch == '\b') {
while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
{
if(ch == '\b') {
+ if( pos <= 0 ) continue;
pos --;
ret[pos] = '\0';
}
pos --;
ret[pos] = '\0';
}
@@
-109,6
+127,7
@@
char *GetPassword()
while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
{
if(ch == '\b') {
while( (ch = fgetc(stdin)) != -1 && ch != '\n' )
{
if(ch == '\b') {
+ if( pos <= 0 ) continue;
pos --;
ret[pos] = '\0';
}
pos --;
ret[pos] = '\0';
}
UCC
git Repository :: git.ucc.asn.au