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
And, adding a rather important header that I fogot in the heap rewrite
[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
2e4906d
..
353c90a
100644
(file)
--- a/
Usermode/Applications/login_src/main.c
+++ b/
Usermode/Applications/login_src/main.c
@@
-18,16
+18,24
@@
int main(int argc, char *argv[])
int status = 0;
tUserInfo *uinfo;
int status = 0;
tUserInfo *uinfo;
+ printf("\x1B[2J"); // Clear Screen
+
for(;;)
{
for(;;)
{
- printf("\x1B[2J"); // Clear Screen
// Validate User
// Validate User
- do {
- if(uid == -1) printf("\n");
+ for(;;)
+ {
sUsername = GetUsername();
sPassword = GetPassword();
sUsername = GetUsername();
sPassword = GetPassword();
- printf("\n");
- } while( (uid = ValidateUser(sUsername, sPassword)) == -1 );
+ if( (uid = ValidateUser(sUsername, sPassword)) == -1 )
+ {
+ printf("\nInvalid username or password for '%s'\n", sUsername);
+ free(sUsername);
+ free(sPassword);
+ }
+ else
+ break;
+ }
printf("\n");
// Create child process
printf("\n");
// Create child process
@@
-50,7
+58,8
@@
int main(int argc, char *argv[])
child_argv[0] = uinfo->Shell;
// Set Environment
setgid(uinfo->GID);
child_argv[0] = uinfo->Shell;
// Set Environment
setgid(uinfo->GID);
- setuid(uid);
+ //setuid(uid);
+ setuid(uinfo->UID);
execve(uinfo->Shell, child_argv, child_envp);
exit(-1);
execve(uinfo->Shell, child_argv, child_envp);
exit(-1);
@@
-68,7
+77,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;
@@
-79,6
+88,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';
}
@@
-114,6
+124,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