kommentar kanske, minns ej
This commit is contained in:
parent
383abfc185
commit
51880f5428
@ -93,7 +93,7 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// using termios instead of the outdated getpass
|
// using termios instead of the outdated getpass for a more secure program
|
||||||
// user_pass = getpass(prompt);
|
// user_pass = getpass(prompt);
|
||||||
|
|
||||||
struct termios old_term_flags, new_term_flags;
|
struct termios old_term_flags, new_term_flags;
|
||||||
@ -151,30 +151,30 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (!strcmp(user_pass_encrypted, passwddata->passwd)) {
|
if (!strcmp(user_pass_encrypted, passwddata->passwd)) {
|
||||||
// successfull login
|
// successfull login
|
||||||
|
printf("\n%d failed attemts to login \n",passwddata->pwfailed);
|
||||||
passwddata->pwfailed = 0;
|
passwddata->pwfailed = 0;
|
||||||
passwddata->pwage = passwddata->pwage + 1;
|
passwddata->pwage = passwddata->pwage + 1;
|
||||||
|
|
||||||
if (mysetpwent(user, passwddata) < 0) {
|
if (mysetpwent(user, passwddata) < 0) {
|
||||||
perror("Error");exit(EXIT_FAILURE);
|
perror("Error");exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (passwddata->pwage > 100) {
|
if (passwddata->pwage > 10) {
|
||||||
printf(" Your password is OLD!!!!\n");
|
printf("You need to change your password !\n");
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* check UID, see setuid(2) */
|
/* check UID, see setuid(2) */
|
||||||
|
|
||||||
if (setuid(passwddata->uid) < 0) {
|
if (setuid(passwddata->uid) < 0) {
|
||||||
printf(" always here !\n");
|
|
||||||
perror("Error");exit(EXIT_FAILURE);
|
perror("Error");exit(EXIT_FAILURE);
|
||||||
|
// TODO kommer alltid bara hit
|
||||||
}
|
}
|
||||||
printf(" cant get here !\n");
|
|
||||||
/* start a shell, use execve(2) */
|
/* start a shell, use execve(2) */
|
||||||
if (execve("/bin/bash",NULL,NULL) < 0) {
|
if (execve("/bin/bash",NULL,NULL) < 0) {
|
||||||
perror("Error");exit(EXIT_FAILURE);
|
perror("Error");exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
printf("\nWelcome to this system !\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// user name exists but password does not match
|
// user name exists but password does not match
|
||||||
|
Reference in New Issue
Block a user