Skip to content

Commit 7de4fb6

Browse files
committed
Simplified failed login counter logic.
1 parent 52d8d28 commit 7de4fb6

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

LinuxPBA/LinuxPBA.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,22 @@ int main(int argc, char** argv) {
4040

4141
std::shared_ptr<SecureString> p;
4242
uint8_t n_unlocks = 0, n_counter = 0;
43-
while (n_unlocks == 0 && n_counter++ <= 4) {
43+
while (n_unlocks == 0 && n_counter < 3) {
4444
p = GetPassPhrase(" Password: ");
4545
n_unlocks += UnlockSEDs((char *)p->c_str());
46+
if (n_unlocks == 0) n_counter++;
4647
}
47-
if (strcmp(p->c_str(), "debug") && n_counter <= 2) {
48-
printf("\n Access granted. Starting the system... \n");
49-
sync();
50-
reboot(RB_AUTOBOOT);
51-
}
52-
else if (n_counter > 2) {
48+
49+
if (n_counter >= 3) {
5350
printf("\n Authorization failed. Shutting down... \n");
5451
sync();
5552
reboot(RB_POWER_OFF);
5653
}
54+
else if (strcmp(p->c_str(), "debug")) {
55+
printf("\n Access granted. Starting the system... \n");
56+
sync();
57+
reboot(RB_AUTOBOOT);
58+
}
59+
5760
return 0;
5861
}

0 commit comments

Comments
 (0)