summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/src/UserMgr.cc
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 03:02:43 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 03:02:43 +0100
commit83d870e58457a1d335a1d9b9966a6a1887cc297b (patch)
tree72888f88c7728c82f3f6df1f4f70591de15eab36 /dev/kernel/src/UserMgr.cc
parentab37adbacf0f33845804c788b39680cd754752a8 (diff)
feat! breaking changes on kernel sources.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/src/UserMgr.cc')
-rw-r--r--dev/kernel/src/UserMgr.cc131
1 files changed, 0 insertions, 131 deletions
diff --git a/dev/kernel/src/UserMgr.cc b/dev/kernel/src/UserMgr.cc
deleted file mode 100644
index 103e8ec9..00000000
--- a/dev/kernel/src/UserMgr.cc
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * ========================================================
- *
- * NeKernel
- * Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.
- *
- * File: UserMgr.cc
- * Purpose: User Manager, used to provide authentication and security.
- *
- * ========================================================
- */
-
-#include <KernelKit/FileMgr.h>
-#include <KernelKit/HeapMgr.h>
-#include <KernelKit/KPC.h>
-#include <KernelKit/ThreadLocalStorage.h>
-#include <KernelKit/UserMgr.h>
-#include <NeKit/KString.h>
-#include <NeKit/KernelPanic.h>
-#include <NeKit/Utils.h>
-
-#define kStdUserType (0xEE)
-#define kSuperUserType (0xEF)
-
-/// @file UserMgr.cc
-/// @brief Multi-user support.
-
-namespace Kernel {
-namespace Detail {
- ////////////////////////////////////////////////////////////
- /// \brief Constructs a password by hashing the password.
- /// \param password password to hash.
- /// \return the hashed password
- ////////////////////////////////////////////////////////////
- STATIC UInt64 user_fnv_generator(const Char* password, User* user) {
- if (!password || !user) return 0;
- if (*password == 0) return 0;
-
- kout << "user_fnv_generator: Hashing user password...\r";
-
- const UInt64 kFnvOffsetBasis = 0xcbf29ce484222325ULL;
- const UInt64 fFnvPrime = 0x100000001b3ULL;
-
- UInt64 hash = kFnvOffsetBasis;
-
- while (*password) {
- hash ^= (Char) (*password++);
- hash *= fFnvPrime;
- }
-
- kout << "user_fnv_generator: Hashed user password.\r";
-
- return hash;
- }
-} // namespace Detail
-
-////////////////////////////////////////////////////////////
-/// @brief User ring constructor.
-////////////////////////////////////////////////////////////
-User::User(const Int32& sel, const Char* user_name) : mUserRing((UserRingKind) sel) {
- MUST_PASS(sel >= 0);
- rt_copy_memory_safe((VoidPtr) user_name, this->mUserName, rt_string_len(user_name),
- kMaxUserNameLen);
-}
-
-////////////////////////////////////////////////////////////
-/// @brief User ring constructor.
-////////////////////////////////////////////////////////////
-User::User(const UserRingKind& ring_kind, const Char* user_name) : mUserRing(ring_kind) {
- rt_copy_memory_safe((VoidPtr) user_name, this->mUserName, rt_string_len(user_name),
- kMaxUserNameLen);
-}
-
-////////////////////////////////////////////////////////////
-/// @brief User destructor class.
-////////////////////////////////////////////////////////////
-User::~User() = default;
-
-Bool User::Save(const UserPublicKey password) noexcept {
- if (!password || *password == 0) return No;
-
- this->mUserFNV = Detail::user_fnv_generator(password, this);
-
- kout << "User::Save: Saved password successfully...\r";
-
- return Yes;
-}
-
-Bool User::Login(const UserPublicKey password) noexcept {
- if (!password || !*password) return No;
-
- auto ret = this->mUserFNV == Detail::user_fnv_generator(password, this);
-
- // now check if the password matches.
- kout << (ret ? "User::Login: Password matches.\r" : "User::Login: Password doesn't match.\r");
- return ret;
-}
-
-Bool User::operator==(const User& lhs) {
- return lhs.mUserRing == this->mUserRing;
-}
-
-Bool User::operator!=(const User& lhs) {
- return lhs.mUserRing != this->mUserRing;
-}
-
-////////////////////////////////////////////////////////////
-/// @brief Returns the user's name.
-////////////////////////////////////////////////////////////
-
-Char* User::Name() noexcept {
- return this->mUserName;
-}
-
-////////////////////////////////////////////////////////////
-/// @brief Returns the user's ring.
-/// @return The king of ring the user is attached to.
-////////////////////////////////////////////////////////////
-
-const UserRingKind& User::Ring() noexcept {
- return this->mUserRing;
-}
-
-Bool User::IsStdUser() noexcept {
- return this->Ring() == UserRingKind::kRingStdUser;
-}
-
-Bool User::IsSuperUser() noexcept {
- return this->Ring() == UserRingKind::kRingSuperUser;
-}
-} // namespace Kernel