| 27 | std::map<std::string, User> users; |
| 28 | |
| 29 | void OnOKPress(__attribute__((unused)) Lemon::GUI::Button* b){ |
| 30 | if(users.find(usernameBox->contents.front()) != users.end()){ |
| 31 | User& user = users.at(usernameBox->contents.front()); |
| 32 | |
| 33 | SHA256 passwordHash; |
| 34 | passwordHash.Update(passwordBox->contents.front().data(), passwordBox->contents.front().length()); |
| 35 | |
| 36 | if(user.hash.compare(passwordHash.GetHash())){ |
| 37 | char buf[128]; |
| 38 | printf("Actual hash: %s, inserted hash: %s\n", user.hash.c_str(), passwordHash.GetHash().c_str()); |
| 39 | snprintf(buf, 128, "Incorrect password for '%s'!", usernameBox->contents.front().c_str()); |
| 40 | Lemon::GUI::DisplayMessageBox("Incorrect Password", buf); |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | setuid(user.uid); |
| 45 | setgid(user.gid); |
| 46 | |
| 47 | char* const args[] = {const_cast<char*>("/system/bin/shell.lef")}; |
| 48 | lemon_spawn(*args, 1, args, 0); |
| 49 | |
| 50 | delete window; |
| 51 | |
| 52 | exit(0); |
| 53 | } else { |
| 54 | char buf[128]; |
| 55 | snprintf(buf, 128, "Unknown user '%s'", usernameBox->contents.front().c_str()); |
| 56 | Lemon::GUI::DisplayMessageBox("Invalid Username", buf); |
| 57 | return; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | int main(int argc, char** argv){ |
| 62 | Lemon::JSONParser cfgParser = Lemon::JSONParser("/system/lemon/users.json"); |
nothing calls this directly
no test coverage detected