diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-23 23:31:58 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-23 23:31:58 +0200 |
| commit | 6551964ad66de7bc7ccb636c54351be2a260612b (patch) | |
| tree | 4b8adea356562f7e4365cd24b64f7cac1559da2e /dev/kernel/KernelKit/UserMgr.h | |
| parent | e2bd3c7b6fcd6147fcbf699be087a475608ffdf7 (diff) | |
feat(kernel/libSystem): Lots of improvements, see below.
what:
- Reworked NetworkDevice.
- Reworked RTL8139 driver.
- Don't assert fCleanup on NetworkDevice destructor.
- Add new Ref types in libSystem.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/KernelKit/UserMgr.h')
| -rw-r--r-- | dev/kernel/KernelKit/UserMgr.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/dev/kernel/KernelKit/UserMgr.h b/dev/kernel/KernelKit/UserMgr.h new file mode 100644 index 00000000..b7e7ac1d --- /dev/null +++ b/dev/kernel/KernelKit/UserMgr.h @@ -0,0 +1,92 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + +------------------------------------------- */ + +#ifndef INC_USER_H +#define INC_USER_H + +/* ------------------------------------------- + + Revision History: + + 04/03/25: Set users directory as /user/ instead of /usr/ + + ------------------------------------------- */ + +#include <CompilerKit/CompilerKit.h> +#include <KernelKit/KPC.h> +#include <NeKit/Defines.h> +#include <NeKit/KString.h> + +///! We got the Super, Standard (%s format) and Guest user, +///! all are used to make authorization operations on the OS. +#define kSuperUser "OS AUTHORITY/MGMT/%s" +#define kGuestUser "OS AUTHORITY/GUEST/%s" +#define kStdUser "OS AUTHORITY/STD/%s" + +#define kUsersDir "/users/" + +#define kMaxUserNameLen (256U) +#define kMaxUserTokenLen (256U) + +namespace Kernel { +class User; + +enum class UserRingKind { + kRingInvalid = 0, + kRingStdUser = 1, + kRingSuperUser = 2, + kRingGuestUser = 5, + kRingCount = 3, +}; + +typedef Char* UserPublicKey; +typedef Char UserPublicKeyType; + +/// @brief System User class. +class User final { + public: + User() = delete; + + User(const Int32& sel, const Char* username); + User(const UserRingKind& kind, const Char* username); + + ~User(); + + public: + NE_COPY_DEFAULT(User) + + public: + bool operator==(const User& lhs); + bool operator!=(const User& lhs); + + public: + /// @brief Get software ring + const UserRingKind& Ring() noexcept; + + /// @brief Get user name + Char* Name() noexcept; + + /// @brief Is he a standard user? + Bool IsStdUser() noexcept; + + /// @brief Is she a super user? + Bool IsSuperUser() noexcept; + + /// @brief Saves a password from the public key. + Bool Save(const UserPublicKey password) noexcept; + + /// @brief Checks if a password matches the **password**. + /// @param password the password to check. + Bool Login(const UserPublicKey password) noexcept; + + private: + UserRingKind mUserRing{UserRingKind::kRingStdUser}; + Char mUserName[kMaxUserNameLen] = {0}; + UInt64 mUserFNV{0UL}; +}; +} // namespace Kernel + +#endif /* ifndef INC_USER_H */ |
