From 83a3ac27ddd9a02ad698407515b0e708197b2aac Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Mon, 29 Jul 2024 08:28:15 +0200 Subject: [MHR-36] Last commit on ticket. Signed-off-by: Amlal EL Mahrouss --- Kernel/KernelKit/DriveManager.hxx | 2 +- Kernel/KernelKit/FileManager.hpp | 2 +- Kernel/KernelKit/HError.hpp | 55 ------------------------------- Kernel/KernelKit/LPC.hxx | 56 +++++++++++++++++++++++++++++++ Kernel/KernelKit/Timer.hpp | 2 +- Kernel/KernelKit/User.hxx | 69 ++++++++++++--------------------------- 6 files changed, 79 insertions(+), 107 deletions(-) delete mode 100644 Kernel/KernelKit/HError.hpp create mode 100644 Kernel/KernelKit/LPC.hxx (limited to 'Kernel/KernelKit') diff --git a/Kernel/KernelKit/DriveManager.hxx b/Kernel/KernelKit/DriveManager.hxx index 5dec36f7..3614f475 100644 --- a/Kernel/KernelKit/DriveManager.hxx +++ b/Kernel/KernelKit/DriveManager.hxx @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include diff --git a/Kernel/KernelKit/FileManager.hpp b/Kernel/KernelKit/FileManager.hpp index 0d721ec0..a37360c7 100644 --- a/Kernel/KernelKit/FileManager.hpp +++ b/Kernel/KernelKit/FileManager.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/Kernel/KernelKit/HError.hpp b/Kernel/KernelKit/HError.hpp deleted file mode 100644 index df12641e..00000000 --- a/Kernel/KernelKit/HError.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#pragma once - -#include - -/// @file HError.hpp -/// @brief Local Process Codes. - -#define ErrLocalIsOk() (Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetLocalCode() == Kernel::kErrorSuccess) -#define ErrLocalFailed() (Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetLocalCode() != Kernel::kErrorSuccess) -#define ErrLocal() Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetLocalCode() - -namespace Kernel -{ - typedef Int32 HError; - - inline constexpr HError kErrorSuccess = 0; - inline constexpr HError kErrorExecutable = 33; - inline constexpr HError kErrorExecutableLib = 34; - inline constexpr HError kErrorFileNotFound = 35; - inline constexpr HError kErrorDirectoryNotFound = 36; - inline constexpr HError kErrorDiskReadOnly = 37; - inline constexpr HError kErrorDiskIsFull = 38; - inline constexpr HError kErrorProcessFault = 39; - inline constexpr HError kErrorSocketHangUp = 40; - inline constexpr HError kErrorThreadLocalStorage = 41; - inline constexpr HError kErrorMath = 42; - inline constexpr HError kErrorNoNetwork = 43; - inline constexpr HError kErrorHeapOutOfMemory = 44; - inline constexpr HError kErrorNoSuchDisk = 45; - inline constexpr HError kErrorFileExists = 46; - inline constexpr HError kErrorFormatFailed = 47; - inline constexpr HError kErrorNetworkTimeout = 48; - inline constexpr HError kErrorInternal = 49; - inline constexpr HError kErrorForkAlreadyExists = 50; - inline constexpr HError kErrorOutOfTeamSlot = 51; - inline constexpr HError kErrorHeapNotPresent = 52; - inline constexpr HError kErrorNoEntrypoint = 53; - inline constexpr HError kErrorDiskIsCorrupted = 54; - inline constexpr HError kErrorDisk = 55; - inline constexpr HError kErrorInvalidData = 56; - inline constexpr HError kErrorAsync = 57; - inline constexpr HError kErrorNonBlocking = 58; - inline constexpr HError kErrorIPC = 59; - inline constexpr HError kErrorSign = 60; - inline constexpr HError kErrorUnimplemented = 0; - - Void err_bug_check_raise(void) noexcept; - Boolean err_bug_check(void) noexcept; -} // namespace Kernel diff --git a/Kernel/KernelKit/LPC.hxx b/Kernel/KernelKit/LPC.hxx new file mode 100644 index 00000000..fc322475 --- /dev/null +++ b/Kernel/KernelKit/LPC.hxx @@ -0,0 +1,56 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + +#pragma once + +#include + +/// @file LPC.hxx +/// @brief Local Process Codes. + +#define ErrLocalIsOk() (Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetLocalCode() == Kernel::kErrorSuccess) +#define ErrLocalFailed() (Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetLocalCode() != Kernel::kErrorSuccess) +#define ErrLocal() Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetLocalCode() + +namespace Kernel +{ + typedef Int32 HError; + + inline constexpr HError kErrorSuccess = 0; + inline constexpr HError kErrorExecutable = 33; + inline constexpr HError kErrorExecutableLib = 34; + inline constexpr HError kErrorFileNotFound = 35; + inline constexpr HError kErrorDirectoryNotFound = 36; + inline constexpr HError kErrorDiskReadOnly = 37; + inline constexpr HError kErrorDiskIsFull = 38; + inline constexpr HError kErrorProcessFault = 39; + inline constexpr HError kErrorSocketHangUp = 40; + inline constexpr HError kErrorThreadLocalStorage = 41; + inline constexpr HError kErrorMath = 42; + inline constexpr HError kErrorNoNetwork = 43; + inline constexpr HError kErrorHeapOutOfMemory = 44; + inline constexpr HError kErrorNoSuchDisk = 45; + inline constexpr HError kErrorFileExists = 46; + inline constexpr HError kErrorFormatFailed = 47; + inline constexpr HError kErrorNetworkTimeout = 48; + inline constexpr HError kErrorInternal = 49; + inline constexpr HError kErrorForkAlreadyExists = 50; + inline constexpr HError kErrorOutOfTeamSlot = 51; + inline constexpr HError kErrorHeapNotPresent = 52; + inline constexpr HError kErrorNoEntrypoint = 53; + inline constexpr HError kErrorDiskIsCorrupted = 54; + inline constexpr HError kErrorDisk = 55; + inline constexpr HError kErrorInvalidData = 56; + inline constexpr HError kErrorAsync = 57; + inline constexpr HError kErrorNonBlocking = 58; + inline constexpr HError kErrorIPC = 59; + inline constexpr HError kErrorSign = 60; + inline constexpr HError kErrorInvalidCreds = 61; + inline constexpr HError kErrorUnimplemented = 0; + + Void err_bug_check_raise(void) noexcept; + Boolean err_bug_check(void) noexcept; +} // namespace Kernel diff --git a/Kernel/KernelKit/Timer.hpp b/Kernel/KernelKit/Timer.hpp index 11ed0c81..eff075cc 100644 --- a/Kernel/KernelKit/Timer.hpp +++ b/Kernel/KernelKit/Timer.hpp @@ -8,7 +8,7 @@ #include #include -#include +#include namespace Kernel { diff --git a/Kernel/KernelKit/User.hxx b/Kernel/KernelKit/User.hxx index 02ba475d..d9d9bb1e 100644 --- a/Kernel/KernelKit/User.hxx +++ b/Kernel/KernelKit/User.hxx @@ -8,22 +8,27 @@ #define _INC_PERMISSION_SEL_HXX_ #include +#include #include #include // user mode users. -#define kSuperUser "Admin" +#define kSuperUser "Super" #define kGuestUser "Guest" -#define kUsersDir "\\Users\\Store\\" +#define kUsersFile "\\Users\\$Stores$" -#define kMaxUserNameLen (255) +#define kMaxUserNameLen (255) +#define kMaxUserTokenLen (4096) // hash 'password' -> base64+md5 encoded data // use this data to then fetch specific data of the user.. namespace Kernel { + class User; + class UserView; + enum class RingKind { kRingStdUser = 1, @@ -50,16 +55,23 @@ namespace Kernel bool operator!=(const User& lhs); public: - /// @brief Getters. - const RingKind& Ring() noexcept; + /// @brief Get software ring + const RingKind& Ring() noexcept; + /// @brief Get user name const StringView Name() noexcept; + /// @brief Is he a standard user? Bool IsStdUser() noexcept; + + /// @brief Is she a super user? Bool IsSuperUser() noexcept; private: RingKind fRing{RingKind::kRingStdUser}; StringView fUserName{kMaxUserNameLen}; + VoidPtr fUserToken{nullptr}; + + friend UserView; }; class UserView final @@ -76,50 +88,9 @@ namespace Kernel public: NEWOS_COPY_DELETE(UserView); - STATIC UserView* The() noexcept - { - UserView* view = nullptr; - - if (!view) - view = new UserView(); - - return view; - } - - Void LogIn(User* user) noexcept - { - if (fCurrentUser) - { - if (!fLastLoggedOffUser) - { - fLastLoggedOffUser = fCurrentUser; - } - else - { - this->LogOff(); - } - } - - fCurrentUser = user; - } - - Void LogOff() noexcept - { - if (!fCurrentUser) - return; - - // an illegal operation just occured, we can't risk more. - if (fCurrentUser == fRootUser) - { - ke_stop(RUNTIME_CHECK_BOOTSTRAP); - } - - if (fLastLoggedOffUser) - delete fLastLoggedOffUser; - - fLastLoggedOffUser = nullptr; - fLastLoggedOffUser = fCurrentUser; - } + STATIC UserView* The() noexcept; + Void LogIn(User* user, const Char* password) noexcept; + Void LogOff() noexcept; }; } // namespace Kernel -- cgit v1.2.3