diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-03-23 19:13:48 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2025-03-23 19:15:17 +0100 |
| commit | a13e1c0911c0627184bc38f18c7fdda64447b3ad (patch) | |
| tree | 073a62c09bf216e85a3f310376640fa1805147f9 /dev/kernel/KernelKit/User.h | |
| parent | 149fa096eb306d03686b3b67e813cf1a78e08cd0 (diff) | |
meta(kernel): Reworked repository's filesystem structure.
Removing useless parts of the project too.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/kernel/KernelKit/User.h')
| -rw-r--r-- | dev/kernel/KernelKit/User.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/dev/kernel/KernelKit/User.h b/dev/kernel/KernelKit/User.h new file mode 100644 index 00000000..9ab2b02e --- /dev/null +++ b/dev/kernel/KernelKit/User.h @@ -0,0 +1,95 @@ +/* ------------------------------------------- + + 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/LPC.h> +#include <NewKit/KString.h> +#include <NewKit/Defines.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/SUPER/%s" +#define kGuestUser "OS AUTHORITY/GUEST/%s" +#define kStdUser "OS AUTHORITY/STD/%s" + +#define kUsersDir "/user/" + +#define kMaxUserNameLen (256U) +#define kMaxUserTokenLen (256U) + +namespace NeOS +{ + class User; + + enum class UserRingKind + { + kRingInvalid = 0, + kRingStdUser = 1, + kRingSuperUser = 2, + kRingGuestUser = 5, + kRingCount = 3, + }; + + typedef Char* UserPublicKey; + typedef Char UserPublicKeyType; + + /// @brief 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 Matches(const UserPublicKey password) noexcept; + + private: + UserRingKind mUserRing{UserRingKind::kRingStdUser}; + Char mUserName[kMaxUserNameLen] = {0}; + Char mUserKey[kMaxUserTokenLen] = {0}; + }; +} // namespace NeOS + +#endif /* ifndef INC_USER_H */ |
