- char *pass, *crypt_pass;
- char prompt[100];
-
- if (o_lock_all) {
- printf("All Virtual Consoles locked.\n");
- } else {
- printf("This Virtual Console locked.\n");
- }
- fflush(stdout);
-
- snprintf(prompt, 100, "%s's password: ", pw->pw_name);
-
- if ((pass = getpass(prompt)) == NULL) {
- perror("getpass");
- restore_terminal();
- exit(1);
- }
-
- crypt_pass = pw_encrypt(pass, pw->pw_passwd);
- if (strncmp(crypt_pass, pw->pw_passwd, sizeof(crypt_pass)) == 0) {
- memset(pass, 0, strlen(pass));
- memset(crypt_pass, 0, strlen(crypt_pass));
- restore_terminal();
- return 0;
- }
- memset(pass, 0, strlen(pass));
- memset(crypt_pass, 0, strlen(crypt_pass));
-
- if (isatty(STDIN_FILENO) == 0) {
- perror("isatty");
- restore_terminal();
- exit(1);
- }
-
- sleep(++times);
- printf("Password incorrect.\n");
- if (times >= 3) {
- sleep(15);
- times = 2;
+ printf("Virtual Console%s locked by %s.\n", (o_lock_all) ? "s" : "", pw->pw_name);
+ if (correct_password(pw)) {
+ break;