summaryrefslogtreecommitdiffhomepage
path: root/Kernel/KernelKit
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-29 08:28:15 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-29 08:28:15 +0200
commit83a3ac27ddd9a02ad698407515b0e708197b2aac (patch)
tree5937d6b70ba935b419eed3b309abd2ced464ffe6 /Kernel/KernelKit
parent4db57a2d646b1538783a0675b38bada7a0f903ae (diff)
[MHR-36] Last commit on ticket.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/KernelKit')
-rw-r--r--Kernel/KernelKit/DriveManager.hxx2
-rw-r--r--Kernel/KernelKit/FileManager.hpp2
-rw-r--r--Kernel/KernelKit/LPC.hxx (renamed from Kernel/KernelKit/HError.hpp)3
-rw-r--r--Kernel/KernelKit/Timer.hpp2
-rw-r--r--Kernel/KernelKit/User.hxx69
5 files changed, 25 insertions, 53 deletions
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 <CompilerKit/CompilerKit.hxx>
#include <KernelKit/DebugOutput.hpp>
#include <KernelKit/DeviceManager.hpp>
-#include <KernelKit/HError.hpp>
+#include <KernelKit/LPC.hxx>
#include <NewKit/Defines.hpp>
#include <NewKit/String.hpp>
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 <CompilerKit/CompilerKit.hxx>
#include <HintKit/CompilerHint.hxx>
-#include <KernelKit/HError.hpp>
+#include <KernelKit/LPC.hxx>
#include <KernelKit/DebugOutput.hpp>
#include <NewKit/Stream.hpp>
#include <NewKit/ErrorOr.hpp>
diff --git a/Kernel/KernelKit/HError.hpp b/Kernel/KernelKit/LPC.hxx
index df12641e..fc322475 100644
--- a/Kernel/KernelKit/HError.hpp
+++ b/Kernel/KernelKit/LPC.hxx
@@ -8,7 +8,7 @@
#include <NewKit/Defines.hpp>
-/// @file HError.hpp
+/// @file LPC.hxx
/// @brief Local Process Codes.
#define ErrLocalIsOk() (Kernel::ProcessScheduler::The().Leak().TheCurrent().Leak().GetLocalCode() == Kernel::kErrorSuccess)
@@ -48,6 +48,7 @@ namespace Kernel
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;
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 <ArchKit/ArchKit.hpp>
#include <CompilerKit/CompilerKit.hxx>
-#include <KernelKit/HError.hpp>
+#include <KernelKit/LPC.hxx>
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 <CompilerKit/CompilerKit.hxx>
+#include <KernelKit/LPC.hxx>
#include <NewKit/String.hpp>
#include <NewKit/Defines.hpp>
// 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