diff options
Diffstat (limited to 'Kernel/Sources')
| -rw-r--r-- | Kernel/Sources/FS/NewFS.cxx | 2 | ||||
| -rw-r--r-- | Kernel/Sources/KernelCheck.cxx | 10 | ||||
| -rw-r--r-- | Kernel/Sources/User.cxx | 42 |
3 files changed, 37 insertions, 17 deletions
diff --git a/Kernel/Sources/FS/NewFS.cxx b/Kernel/Sources/FS/NewFS.cxx index c5b9c1e3..23d2867f 100644 --- a/Kernel/Sources/FS/NewFS.cxx +++ b/Kernel/Sources/FS/NewFS.cxx @@ -304,7 +304,7 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::CreateCatalog(_Input const char* name, if (flagsList & kNewFSCatalogKindMetaFile) { - if (UserManager::The()->Current() != UserManager::The()->fRootUser) + if (UserManager::The()->GetCurrent() != UserManager::The()->fRootUser) { delete catalogChild; return nullptr; diff --git a/Kernel/Sources/KernelCheck.cxx b/Kernel/Sources/KernelCheck.cxx index defe6841..900bbf6e 100644 --- a/Kernel/Sources/KernelCheck.cxx +++ b/Kernel/Sources/KernelCheck.cxx @@ -15,15 +15,9 @@ #include <Modules/CoreCG/FbRenderer.hxx> #include <Modules/CoreCG/TextRenderer.hxx> -EXTERN_C [[noreturn]] Kernel::Void ke_wait_for_debugger() +EXTERN_C Kernel::Void ke_wait_for_debugger() { - while (Yes) - { -#ifdef __NEWOS_AMD64__ - Kernel::HAL::rt_cli(); - Kernel::HAL::rt_halt(); -#endif - } + } /* Each error code is attributed with an ID, which will prompt a string onto the diff --git a/Kernel/Sources/User.cxx b/Kernel/Sources/User.cxx index 60981551..e0ccaf6b 100644 --- a/Kernel/Sources/User.cxx +++ b/Kernel/Sources/User.cxx @@ -26,9 +26,19 @@ namespace Kernel /// \brief Constructs a token by hashing the password. /// \param password password to hash. /// \return the hashed password - const Char* cred_construct_token(const Char* password) + const Int32 cred_construct_token(Char* password, User* user) { - return nullptr; + if (!password || !user) + return -1; + + for (Size i_pass = 0; i_pass < rt_string_len(password); ++i_pass) + { + Char cur_chr = password[i_pass]; + password[i_pass] = cur_chr + (user->IsStdUser() ? 0xCF : 0xEF); + } + + + return 0; } } @@ -90,7 +100,7 @@ namespace Kernel return view; } - Bool UserManager::LogIn(User* user, const Char* password) noexcept + Bool UserManager::TryLogIn(User* user, const Char* password) noexcept { if (!password || !user) @@ -119,9 +129,25 @@ namespace Kernel } else { - auto tok = Detail::cred_construct_token(password); + Char generated_token[255] = { 0 }; + + // ================================================== // + // Provide password on token variable. + // ================================================== // + + rt_copy_memory((VoidPtr)password, generated_token, rt_string_len(password)); + + // ================================================== // + // Construct token. + // ================================================== // + + Detail::cred_construct_token(generated_token, user); + + // ================================================== // + // Checks if it matches the current token we have. + // ================================================== // - if (rt_string_cmp((Char*)token, tok, rt_string_len(tok))) + if (rt_string_cmp((Char*)token, generated_token, rt_string_len(password))) { kcout << "newoskrnl: Incorrect credentials.\r"; @@ -146,7 +172,7 @@ namespace Kernel } else { - this->LogOff(); + this->TryLogOff(); } } @@ -156,12 +182,12 @@ namespace Kernel return true; } - User* UserManager::Current() noexcept + User* UserManager::GetCurrent() noexcept { return fCurrentUser; } - Void UserManager::LogOff() noexcept + Void UserManager::TryLogOff() noexcept { if (!fCurrentUser) return; |
