diff options
Diffstat (limited to 'dev/ZKA/Sources')
| -rw-r--r-- | dev/ZKA/Sources/FS/NewFS.cxx | 46 | ||||
| -rw-r--r-- | dev/ZKA/Sources/Network/IPC.cxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/Sources/User.cxx | 76 |
3 files changed, 61 insertions, 63 deletions
diff --git a/dev/ZKA/Sources/FS/NewFS.cxx b/dev/ZKA/Sources/FS/NewFS.cxx index bdd4622a..88c415eb 100644 --- a/dev/ZKA/Sources/FS/NewFS.cxx +++ b/dev/ZKA/Sources/FS/NewFS.cxx @@ -469,11 +469,11 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL return false; } - Char sectorBuf[kNewFSSectorSz] = {0}; + Char fs_buf[kNewFSSectorSz] = {0}; Lba start = kNewFSRootCatalogStartAddress; - drive->fPacket.fPacketContent = sectorBuf; + drive->fPacket.fPacketContent = fs_buf; drive->fPacket.fPacketSize = kNewFSSectorSz; drive->fPacket.fLba = start; @@ -544,7 +544,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL // disk isnt faulty and data has been fetched. while (drive->fPacket.fPacketGood) { - NFS_ROOT_PARTITION_BLOCK* partBlock = (NFS_ROOT_PARTITION_BLOCK*)sectorBuf; + NFS_ROOT_PARTITION_BLOCK* partBlock = (NFS_ROOT_PARTITION_BLOCK*)fs_buf; // check for an empty partition here. if (partBlock->PartitionName[0] == 0 && @@ -575,7 +575,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL partBlock->DiskSize = diskSize; partBlock->FreeCatalog = sectorCount / sizeof(NFS_CATALOG_STRUCT); - drive->fPacket.fPacketContent = sectorBuf; + drive->fPacket.fPacketContent = fs_buf; drive->fPacket.fPacketSize = kNewFSSectorSz; drive->fPacket.fLba = kNewFSRootCatalogStartAddress; @@ -600,7 +600,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive, _Input const Lba endL start += partBlock->DiskSize; - drive->fPacket.fPacketContent = sectorBuf; + drive->fPacket.fPacketContent = fs_buf; drive->fPacket.fPacketSize = kNewFSSectorSz; drive->fPacket.fLba = start; @@ -715,19 +715,19 @@ _Output NFS_CATALOG_STRUCT* NewFSParser::FindCatalog(_Input const Char* catalogN { kcout << "newoskrnl: start finding catalog...\r"; - NFS_ROOT_PARTITION_BLOCK sectorBuf{0}; + NFS_ROOT_PARTITION_BLOCK fs_buf{0}; auto drive = sMountpointInterface.A(); rt_copy_memory((VoidPtr) "fs/newfs-packet", drive.fPacket.fPacketMime, rt_string_len("fs/newfs-packet")); - drive.fPacket.fPacketContent = §orBuf; + drive.fPacket.fPacketContent = &fs_buf; drive.fPacket.fPacketSize = sizeof(NFS_ROOT_PARTITION_BLOCK); drive.fPacket.fLba = kNewFSRootCatalogStartAddress; drive.fInput(&drive.fPacket); - NFS_ROOT_PARTITION_BLOCK* part = (NFS_ROOT_PARTITION_BLOCK*)§orBuf; + NFS_ROOT_PARTITION_BLOCK* part = (NFS_ROOT_PARTITION_BLOCK*)&fs_buf; auto startCatalogList = part->StartCatalog; const auto cCtartCatalogList = startCatalogList; @@ -937,57 +937,57 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, kcout << "newoskrnl: catalog " << catalog->Name << ", fork: " << hex_number(dataForkLba) << endl; - Char* sectorBuf = new Char[sizeof(NFS_FORK_STRUCT)]; + NFS_FORK_STRUCT* fs_buf = new NFS_FORK_STRUCT(); auto drive = sMountpointInterface.A(); rt_copy_memory((VoidPtr) "fs/newfs-packet", drive.fPacket.fPacketMime, rt_string_len("fs/newfs-packet")); - NFS_FORK_STRUCT* forkData = nullptr; + NFS_FORK_STRUCT* fs_fork_data = nullptr; while (dataForkLba >= kNewFSCatalogStartAddress) { drive.fPacket.fLba = dataForkLba; drive.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT); - drive.fPacket.fPacketContent = sectorBuf; + drive.fPacket.fPacketContent = fs_buf; drive.fInput(&drive.fPacket); - forkData = (NFS_FORK_STRUCT*)sectorBuf; + fs_fork_data = fs_buf; - kcout << "newoskrnl: name: " << forkData->ForkName << endl; + kcout << "newoskrnl: name: " << fs_fork_data->ForkName << endl; - if (forkData->DataOffset <= kNewFSCatalogStartAddress) + if (fs_fork_data->DataOffset <= kNewFSCatalogStartAddress) { - delete[] sectorBuf; + delete[] fs_buf; - kcout << "Fail-Data-Offset: " << hex_number(forkData->DataOffset) << endl; + kcout << "Fail-Data-Offset: " << hex_number(fs_fork_data->DataOffset) << endl; return nullptr; } - if (StringBuilder::Equals(forkName, forkData->ForkName) && - StringBuilder::Equals(catalog->Name, forkData->CatalogName)) + if (StringBuilder::Equals(forkName, fs_fork_data->ForkName) && + StringBuilder::Equals(catalog->Name, fs_fork_data->CatalogName)) break; - dataForkLba = forkData->NextSibling; + dataForkLba = fs_fork_data->NextSibling; } if (dataForkLba <= kNewFSCatalogStartAddress) { - delete[] sectorBuf; + delete[] fs_buf; return nullptr; } - Char* forkBuf = new Char[dataSz]; + NFS_FORK_STRUCT* forkBuf = new NFS_FORK_STRUCT(); - drive.fPacket.fLba = forkData->DataOffset; + drive.fPacket.fLba = fs_fork_data->DataOffset; drive.fPacket.fPacketSize = dataSz; drive.fPacket.fPacketContent = forkBuf; drive.fInput(&drive.fPacket); - delete[] sectorBuf; + delete[] fs_buf; return forkBuf; } diff --git a/dev/ZKA/Sources/Network/IPC.cxx b/dev/ZKA/Sources/Network/IPC.cxx index f703e650..926224d9 100644 --- a/dev/ZKA/Sources/Network/IPC.cxx +++ b/dev/ZKA/Sources/Network/IPC.cxx @@ -14,7 +14,7 @@ using namespace Kernel; /// @brief The internal sanitize function. Bool ipc_int_sanitize_packet(IPC_MESSAGE_STRUCT* pckt) { - auto endian = DEDUCE_ENDIAN(pckt, ((char*)pckt)[0]); + auto endian = DEDUCE_ENDIAN(pckt, ((Char*)pckt)[0]); switch (endian) { diff --git a/dev/ZKA/Sources/User.cxx b/dev/ZKA/Sources/User.cxx index df6a4b9b..620c62f1 100644 --- a/dev/ZKA/Sources/User.cxx +++ b/dev/ZKA/Sources/User.cxx @@ -10,6 +10,7 @@ * ======================================================== */ +#include "KernelKit/LPC.hxx" #include <KernelKit/User.hxx> #include <NewKit/KernelCheck.hxx> #include <KernelKit/FileManager.hxx> @@ -38,7 +39,11 @@ namespace Kernel for (Size i_pass = 0; i_pass < length; ++i_pass) { - Char cur_chr = in_password[i_pass]; + Char cur_chr = in_password[i_pass]; + + if (cur_chr == 0) + break; + password[i_pass] = cur_chr + (user->IsStdUser() ? cStdUser : cSuperUser); } @@ -61,7 +66,10 @@ namespace Kernel rt_copy_memory((VoidPtr)userName, this->fUserName, rt_string_len(userName)); } - User::~User() = default; + User::~User() + { + mm_delete_ke_heap(fUserNodePtr); + } Bool User::TrySave(const Char* password) noexcept { @@ -86,8 +94,7 @@ namespace Kernel if (!node) { - ErrLocal() = kErrorInternal; - + ErrLocal() = kErrorDiskIsFull; return false; } @@ -108,8 +115,8 @@ namespace Kernel // writing the data fork now. False means a data fork. bool wrote = new_fs->GetParser()->WriteCatalog(node, false, reinterpret_cast<VoidPtr>(token), len, this->fUserName); - delete node; - node = nullptr; + this->fUserNodePtr = reinterpret_cast<VoidPtr>(node); + rt_copy_memory(token, this->fUserToken, rt_string_len(token)); delete[] token; token = nullptr; @@ -166,9 +173,10 @@ namespace Kernel return view; } - Bool UserManager::TryLogIn(User& user, const Char* password) noexcept + Bool UserManager::TryLogIn(User& user) noexcept { - if (!password) + if (!user.fUserToken[0] || + !user.fUserNodePtr) { kcout << "newoskrnl: Incorrect data given.\r"; @@ -179,63 +187,53 @@ namespace Kernel kcout << "newoskrnl: Trying to log-in.\r"; - NewFilesystemManager* new_fs = (NewFilesystemManager*)NewFilesystemManager::GetMounted(); + kcout << "newoskrnl: reading: " << reinterpret_cast<NFS_CATALOG_STRUCT*>(user.fUserNodePtr)->Name << endl; - // do not use if unmounted. + NewFilesystemManager* new_fs = (NewFilesystemManager*)NewFilesystemManager::GetMounted(); if (!new_fs) - return false; + { + ErrLocal() = kErrorInvalidCreds; + kcout << "newoskrnl: Incorrect filesystem.\r"; - auto node = new_fs->GetParser()->GetCatalog(kUsersFile); + return false; + } - // ------------------------------------------ // - // Retrieve token from a specific file fork. - // Fail on null. - // ------------------------------------------ // + NFS_CATALOG_STRUCT* node = new_fs->GetParser()->GetCatalog(kUsersFile); if (!node) { - ErrLocal() = kErrorInvalidData; - kcout << "newoskrnl: No such path.\r"; - return false; - } + node = reinterpret_cast<NFS_CATALOG_STRUCT*>(user.fUserNodePtr); + + if (!node) + { + ErrLocal() = kErrorInvalidCreds; + kcout << "newoskrnl: Incorrect catalog.\r"; - kcout << "newoskrnl: reading: " << node->Name << endl; + return false; + } + } - auto token = new_fs->GetParser()->ReadCatalog(node, false, rt_string_len(password), user.fUserName); + auto token = new_fs->GetParser()->ReadCatalog(node, false, rt_string_len(user.fUserToken), user.fUserName); if (!token) { ErrLocal() = kErrorInvalidCreds; - kcout << "newoskrnl: Incorrect credentials.\r"; + kcout << "newoskrnl: Incorrect token.\r"; return false; } else { - Char generated_token[kMaxUserTokenLen] = {0}; - - // ================================================== // - // Provide password on token variable. - // ================================================== // - - rt_copy_memory((VoidPtr)password, generated_token, rt_string_len(password)); - - // ================================================== // - // Construct token. - // ================================================== // - - Detail::cred_construct_token(generated_token, password, &user, rt_string_len(password)); - // ================================================== // // Checks if it matches the current token we have. // ================================================== // - if (rt_string_cmp((Char*)token, generated_token, rt_string_len(password))) + if (rt_string_cmp(reinterpret_cast<Char*>(token), user.fUserToken, rt_string_len(user.fUserToken))) { kcout << "newoskrnl: Incorrect credentials.\r"; - mm_delete_ke_heap(token); + return false; } |
