diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-05-08 21:20:01 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2026-05-08 21:20:01 -0300 |
| commit | dbad4b699e35442920baa60c13f76e95904fe317 (patch) | |
| tree | 70e35b6879349a750ea5be0b02790bb8d32d00b1 | |
| parent | 602af97c269bdc211cc7aeb34e436152053395cc (diff) | |
| download | RNT-dbad4b699e35442920baa60c13f76e95904fe317.tar.gz RNT-dbad4b699e35442920baa60c13f76e95904fe317.zip | |
restructure project and add readme
| -rw-r--r-- | Makefile | 69 | ||||
| -rw-r--r-- | README.org | 35 | ||||
| -rw-r--r-- | RelationalNT.vcxproj | 19 | ||||
| -rw-r--r-- | RelationalNT.vcxproj.filters | 57 | ||||
| -rw-r--r-- | images/logo.png | bin | 0 -> 1324 bytes | |||
| -rw-r--r-- | include/Api.h | 11 | ||||
| -rw-r--r-- | include/CursorManager.h | 10 | ||||
| -rw-r--r-- | include/HandlerManager.h | 25 | ||||
| -rw-r--r-- | include/IdentityManager.h | 15 | ||||
| -rw-r--r-- | include/LifecycleManager.h | 28 | ||||
| -rw-r--r-- | include/NT.h | 210 | ||||
| -rw-r--r-- | include/NamespaceReferenceManager.h | 10 | ||||
| -rw-r--r-- | include/ObjectManager.h | 47 | ||||
| -rw-r--r-- | include/PermissionsManager.h | 19 | ||||
| -rw-r--r-- | include/Runtime.h | 13 | ||||
| -rw-r--r-- | include/Types.h | 26 | ||||
| -rw-r--r-- | include/WAM.h | 10 | ||||
| -rw-r--r-- | src/CursorManager.cpp | 5 | ||||
| -rw-r--r-- | src/HandlerManager.cpp | 63 | ||||
| -rw-r--r-- | src/IdentityManager.cpp | 14 | ||||
| -rw-r--r-- | src/LifecycleManager.cpp | 17 | ||||
| -rw-r--r-- | src/NT.cpp | 6 | ||||
| -rw-r--r-- | src/NamespaceReferenceManager.cpp | 5 | ||||
| -rw-r--r-- | src/ObjectManager.cpp | 9 | ||||
| -rw-r--r-- | src/PermissionsManager.cpp | 19 | ||||
| -rw-r--r-- | src/WAM.cpp | 5 |
26 files changed, 536 insertions, 211 deletions
@@ -1,13 +1,11 @@ CXX = cl TARGET = RNT.exe -OBJECT = NT.obj -SOURCE = src\NT.cpp +OBJECTS = NT.obj ObjectManager.obj PermissionsManager.obj NamespaceReferenceManager.obj CursorManager.obj IdentityManager.obj LifecycleManager.obj HandlerManager.obj WAM.obj INCDIR = include DEFINES = /DNT_CONSOLE_APP /DNT_WAIT_ON_EXIT INCLUDE_FLAG = /I$(INCDIR) COMPILE_FLAGS = /std:c++17 /W4 /EHsc COMPILE_ONLY = /c -OBJECT_OUT = /Fo:$(OBJECT) LINK_FLAGS = TARGET_OUT = /Fe:$(TARGET) REMOVE = del /Q @@ -17,18 +15,69 @@ all: $(TARGET) windows: all unix: - $(MAKE) CXX=c++ TARGET=RNT OBJECT=NT.o SOURCE=src/NT.cpp DEFINES=-DNT_CONSOLE_APP INCLUDE_FLAG=-Iinclude COMPILE_FLAGS="-std=c++17 -Wall -Wextra" COMPILE_ONLY=-c OBJECT_OUT="-o NT.o" LINK_FLAGS= TARGET_OUT="-o RNT" REMOVE="rm -f" all + $(MAKE) CXX=c++ TARGET=RNT OBJECTS="NT.o ObjectManager.o PermissionsManager.o NamespaceReferenceManager.o CursorManager.o IdentityManager.o LifecycleManager.o HandlerManager.o WAM.o" DEFINES=-DNT_CONSOLE_APP INCLUDE_FLAG=-Iinclude COMPILE_FLAGS="-std=c++17 -Wall -Wextra" COMPILE_ONLY=-c LINK_FLAGS= TARGET_OUT="-o RNT" REMOVE="rm -f" all linux: unix macos: - $(MAKE) CXX=c++ TARGET=RNT OBJECT=NT.o SOURCE=src/NT.cpp DEFINES=-DNT_CONSOLE_APP INCLUDE_FLAG=-Iinclude COMPILE_FLAGS="-std=c++17 -Wall -Wextra" COMPILE_ONLY=-c OBJECT_OUT="-o NT.o" LINK_FLAGS= TARGET_OUT="-o RNT" REMOVE="rm -f" all + $(MAKE) CXX=c++ TARGET=RNT OBJECTS="NT.o ObjectManager.o PermissionsManager.o NamespaceReferenceManager.o CursorManager.o IdentityManager.o LifecycleManager.o HandlerManager.o WAM.o" DEFINES=-DNT_CONSOLE_APP INCLUDE_FLAG=-Iinclude COMPILE_FLAGS="-std=c++17 -Wall -Wextra" COMPILE_ONLY=-c LINK_FLAGS= TARGET_OUT="-o RNT" REMOVE="rm -f" all -$(TARGET): $(OBJECT) - $(CXX) $(LINK_FLAGS) $(OBJECT) $(TARGET_OUT) +$(TARGET): $(OBJECTS) + $(CXX) $(LINK_FLAGS) $(OBJECTS) $(TARGET_OUT) -$(OBJECT): $(SOURCE) - $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) $(SOURCE) $(OBJECT_OUT) +NT.obj: src\NT.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src\NT.cpp /Fo:NT.obj + +ObjectManager.obj: src\ObjectManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src\ObjectManager.cpp /Fo:ObjectManager.obj + +PermissionsManager.obj: src\PermissionsManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src\PermissionsManager.cpp /Fo:PermissionsManager.obj + +NamespaceReferenceManager.obj: src\NamespaceReferenceManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src\NamespaceReferenceManager.cpp /Fo:NamespaceReferenceManager.obj + +CursorManager.obj: src\CursorManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src\CursorManager.cpp /Fo:CursorManager.obj + +IdentityManager.obj: src\IdentityManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src\IdentityManager.cpp /Fo:IdentityManager.obj + +LifecycleManager.obj: src\LifecycleManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src\LifecycleManager.cpp /Fo:LifecycleManager.obj + +HandlerManager.obj: src\HandlerManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src\HandlerManager.cpp /Fo:HandlerManager.obj + +WAM.obj: src\WAM.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src\WAM.cpp /Fo:WAM.obj + +NT.o: src/NT.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src/NT.cpp -o NT.o + +ObjectManager.o: src/ObjectManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src/ObjectManager.cpp -o ObjectManager.o + +PermissionsManager.o: src/PermissionsManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src/PermissionsManager.cpp -o PermissionsManager.o + +NamespaceReferenceManager.o: src/NamespaceReferenceManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src/NamespaceReferenceManager.cpp -o NamespaceReferenceManager.o + +CursorManager.o: src/CursorManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src/CursorManager.cpp -o CursorManager.o + +IdentityManager.o: src/IdentityManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src/IdentityManager.cpp -o IdentityManager.o + +LifecycleManager.o: src/LifecycleManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src/LifecycleManager.cpp -o LifecycleManager.o + +HandlerManager.o: src/HandlerManager.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src/HandlerManager.cpp -o HandlerManager.o + +WAM.o: src/WAM.cpp + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) src/WAM.cpp -o WAM.o clean: - -$(REMOVE) RNT.exe RNT $(OBJECT) NT.o RNT.exp RNT.lib + -$(REMOVE) RNT.exe RNT $(OBJECTS) NT.obj ObjectManager.obj PermissionsManager.obj NamespaceReferenceManager.obj CursorManager.obj IdentityManager.obj LifecycleManager.obj HandlerManager.obj WAM.obj NT.o ObjectManager.o PermissionsManager.o NamespaceReferenceManager.o CursorManager.o IdentityManager.o LifecycleManager.o HandlerManager.o WAM.o RNT.exp RNT.lib diff --git a/README.org b/README.org new file mode 100644 index 0000000..f8da320 --- /dev/null +++ b/README.org @@ -0,0 +1,35 @@ +#+TITLE: Relational NT + +#+ATTR_ORG: :width 320 +[[file:images/logo.png]] + +* About + +This is a Relational NT-inspired database kernel. The goal of the project is to offer an approach similar to how the NT kernel offers for an OS, but for administrating database objects and state. + +Relational NT explores database internals through an object-manager style architecture. Instead of treating relations, tuples, transactions, namespaces, permissions, and handles as unrelated mechanisms, the runtime models them as managed objects with explicit lifecycle, uniform access paths and explicit security enforcement. + +* Design Direction + +- Object management: database objects are registered, located, and referenced through a central object manager. +- Permissions: access checks are separated from object lookup so security policy can evolve independently. +- Identity and lifecycle: opening, closing, monitoring, and contention decisions are represented as runtime responsibilities. +- Handles: authorized access to objects is modeled explicitly, making ownership and cleanup visible. + +* Current Status + +The project is early-stage and focused on shaping the runtime structure. Many components are intentionally skeletal while the core abstractions settle. + +* Building + +The repository includes a Visual Studio makefile project and a root =Makefile=. On Windows, build with the Visual Studio/NMake environment available: + +#+begin_src shell +nmake /f Makefile windows +#+end_src + +For Unix-like environments with a C++17 compiler and Make installed: + +#+begin_src shell +make unix +#+end_src diff --git a/RelationalNT.vcxproj b/RelationalNT.vcxproj index 8176edc..9827b07 100644 --- a/RelationalNT.vcxproj +++ b/RelationalNT.vcxproj @@ -85,10 +85,29 @@ <ItemDefinitionGroup></ItemDefinitionGroup> <ItemGroup> + <ClCompile Include="src\CursorManager.cpp" /> + <ClCompile Include="src\HandlerManager.cpp" /> + <ClCompile Include="src\IdentityManager.cpp" /> + <ClCompile Include="src\LifecycleManager.cpp" /> + <ClCompile Include="src\NamespaceReferenceManager.cpp" /> <ClCompile Include="src\NT.cpp" /> + <ClCompile Include="src\ObjectManager.cpp" /> + <ClCompile Include="src\PermissionsManager.cpp" /> + <ClCompile Include="src\WAM.cpp" /> </ItemGroup> <ItemGroup> + <ClInclude Include="include\Api.h" /> + <ClInclude Include="include\CursorManager.h" /> + <ClInclude Include="include\HandlerManager.h" /> + <ClInclude Include="include\IdentityManager.h" /> + <ClInclude Include="include\LifecycleManager.h" /> + <ClInclude Include="include\NamespaceReferenceManager.h" /> <ClInclude Include="include\NT.h" /> + <ClInclude Include="include\ObjectManager.h" /> + <ClInclude Include="include\PermissionsManager.h" /> + <ClInclude Include="include\Runtime.h" /> + <ClInclude Include="include\Types.h" /> + <ClInclude Include="include\WAM.h" /> </ItemGroup> <ItemGroup> <None Include="Makefile" /> diff --git a/RelationalNT.vcxproj.filters b/RelationalNT.vcxproj.filters index c942ddf..29a22eb 100644 --- a/RelationalNT.vcxproj.filters +++ b/RelationalNT.vcxproj.filters @@ -14,14 +14,71 @@ </Filter> </ItemGroup> <ItemGroup> + <ClCompile Include="src\CursorManager.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="src\HandlerManager.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="src\IdentityManager.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="src\LifecycleManager.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="src\NamespaceReferenceManager.cpp"> + <Filter>Source Files</Filter> + </ClCompile> <ClCompile Include="src\NT.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="src\ObjectManager.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="src\PermissionsManager.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="src\WAM.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> + <ClInclude Include="include\Api.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="include\CursorManager.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="include\HandlerManager.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="include\IdentityManager.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="include\LifecycleManager.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="include\NamespaceReferenceManager.h"> + <Filter>Header Files</Filter> + </ClInclude> <ClInclude Include="include\NT.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="include\ObjectManager.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="include\PermissionsManager.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="include\Runtime.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="include\Types.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="include\WAM.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="Makefile"> diff --git a/images/logo.png b/images/logo.png Binary files differnew file mode 100644 index 0000000..7277e7d --- /dev/null +++ b/images/logo.png diff --git a/include/Api.h b/include/Api.h new file mode 100644 index 0000000..d47636d --- /dev/null +++ b/include/Api.h @@ -0,0 +1,11 @@ +#pragma once + +#if defined(_WIN32) && defined(NT_CONSOLE_APP) +#define NT_API +#elif defined(_WIN32) && defined(NT_EXPORTS) +#define NT_API __declspec(dllexport) +#elif defined(_WIN32) +#define NT_API __declspec(dllimport) +#else +#define NT_API +#endif diff --git a/include/CursorManager.h b/include/CursorManager.h new file mode 100644 index 0000000..33230ab --- /dev/null +++ b/include/CursorManager.h @@ -0,0 +1,10 @@ +#pragma once + +#include "Api.h" + +namespace nt +{ + class NT_API CursorManager + { + }; +} diff --git a/include/HandlerManager.h b/include/HandlerManager.h new file mode 100644 index 0000000..d126680 --- /dev/null +++ b/include/HandlerManager.h @@ -0,0 +1,25 @@ +#pragma once + +#include "Api.h" +#include "ObjectManager.h" + +#include <string> +#include <vector> + +namespace nt +{ + class NT_API HandlerManager + { + public: + // This is supposed to represent an authorized access to a certain object in the registry + // This increases the handle count in the object manager + // We should consider adding on the object manager a vector of all the handles that refer to an object + struct handle { + ObjectManager::registry* object = nullptr; + void* connection_context = nullptr; + }; + void DeallocateHandle(struct handle* handle); + struct handle Open(std::vector<std::string> object_path, void* connection_context); + bool Close(struct handle* handle); + }; +} diff --git a/include/IdentityManager.h b/include/IdentityManager.h new file mode 100644 index 0000000..1a03fff --- /dev/null +++ b/include/IdentityManager.h @@ -0,0 +1,15 @@ +#pragma once + +#include "Api.h" +#include "ObjectManager.h" + +namespace nt +{ + class NT_API IdentityManager + { + public: + // Looks into the methods of the object type and asserts if it can be opened + const bool CanOpen(ObjectManager::registry* object); + const bool CanClose(ObjectManager::registry* object); + }; +} diff --git a/include/LifecycleManager.h b/include/LifecycleManager.h new file mode 100644 index 0000000..2cd270d --- /dev/null +++ b/include/LifecycleManager.h @@ -0,0 +1,28 @@ +#pragma once + +#include "Api.h" +#include "ObjectManager.h" + +namespace nt +{ + class NT_API LifecycleManager + { + public: + // If object is not being monitored already, monitors the lifecycle by updating the handle count. + // Maybe also look at the reference count and kill some categories of disposable objects no longer referenced by other objects, like transactions. + // Think of other use cases later. + void Monitor(ObjectManager::registry* object); + // Serializes contention for the change of a mutable reference. + // This can be used in, for example, the HEAD of a branch to serialize the access. + // If the object does not causes contention, like a relation (since they are immutable, just like multigroups, all snapshots) + // then just approve, as they do not cause any contention. Transactions also do not cause any, + // the only things that do are mutable reference states in shared sessions, + // for example: the HEAD of a branch, namespace collisions (creating two branches with the same name, or two multigroups with the same name from the same state, etc), + // multi-branch atomic commits (which I wish to not have as it damages isolation), + // garbage collection of old state (as in, we want to delete an old-enough history to save up space), etc. + const bool Contention(ObjectManager::registry* object); + // The inverse of `Monitor`, stops monitoring. + // Maybe garbage collect here also if the counters goes to zero. + void Unmonitor(ObjectManager::registry* object); + }; +} diff --git a/include/NT.h b/include/NT.h index a24d9d4..a97f6c8 100644 --- a/include/NT.h +++ b/include/NT.h @@ -1,202 +1,12 @@ #pragma once -#include <cstdint> -#include <set> -#include <vector> -#include <string> -#if defined(_WIN32) && defined(NT_CONSOLE_APP) -#define NT_API -#elif defined(_WIN32) && defined(NT_EXPORTS) -#define NT_API __declspec(dllexport) -#elif defined(_WIN32) -#define NT_API __declspec(dllimport) -#else -#define NT_API -#endif - -enum OBJECT_TYPE { - MULTIGROUP, - RELATION, - TUPLE, - ATTRIBUTE, - TRANSACTION -}; - -enum METHOD { - OPEN, - CLOSE, - PARSE, // To plug a secondary namespace - SECURITY -}; - -enum AUTH_CLAIM { - READ, - WRITE -}; - -enum AUTH_METHOD { - CERTIFICATE, - PLAIN_TEXT -}; - -namespace nt -{ - class NT_API ObjectManager - { - public: - class IObject { - public: - virtual ~IObject() = default; - }; - class Multigroup : IObject {}; - class Relation : IObject {}; - class Tuple : IObject {}; - class Transaction : IObject {}; - struct object_type { - OBJECT_TYPE label; - // If the object is not durable. E.g.: TRANSACTION - bool disposable; - std::set<METHOD> methods; - }; - struct registry_head { - uint32_t reference_count; - uint32_t handle_count; - struct object_type* type; - std::vector<std::string> path; - //security_descriptor to be added later, maybe also a set of labels - }; - struct registry { - struct registry_head* head; - IObject object; - // TODO: Treat as a list for now, but ideally it's a tree - struct registry* next; - }; - struct registry** entries; - // Looks into this registry and attempts to retrieve the entry - struct registry* Find(const std::vector<std::string> object_path) { return nullptr; } - }; - - class NT_API PermissionsManager - { - public: - // For validating connections at login - std::set<AUTH_CLAIM> Firewall(AUTH_METHOD method) { return {}; } - // For validating permission to an object - const bool Access(const ObjectManager::registry* object, const void* connection_context) { - // Checks the security descriptor on the head of the object we find in the ObjectManager::registry - // Then additionally check other metadata yet to be defined in the connection_context, - // like user group, policy, etc. - // Yet to decide if this should be summoned at every attempt to get ahold of an object, - // that might produce significant overhead. How can we solve this? - return object != nullptr && connection_context != nullptr; - } - }; - - class NT_API NamespaceReferenceManager - { - }; - - class NT_API CursorManager - { - }; - - class NT_API IdentityManager - { - public: - // Looks into the methods of the object type and asserts if it can be opened - const bool CanOpen(ObjectManager::registry* object) { return object != nullptr; } - const bool CanClose(ObjectManager::registry* object) { return object != nullptr; } - }; - - class NT_API LifecycleManager - { - public: - // If object is not being monitored already, monitors the lifecycle by updating the handle count. - // Maybe also look at the reference count and kill some categories of disposable objects no longer referenced by other objects, like transactions. - // Think of other use cases later. - void Monitor(ObjectManager::registry* object) {} - // Serializes contention for the change of a mutable reference. - // This can be used in, for example, the HEAD of a branch to serialize the access. - // If the object does not causes contention, like a relation (since they are immutable, just like multigroups, all snapshots) - // then just approve, as they do not cause any contention. Transactions also do not cause any, - // the only things that do are mutable reference states in shared sessions, - // for example: the HEAD of a branch, namespace collisions (creating two branches with the same name, or two multigroups with the same name from the same state, etc), - // multi-branch atomic commits (which I wish to not have as it damages isolation), - // garbage collection of old state (as in, we want to delete an old-enough history to save up space), etc. - const bool Contention(ObjectManager::registry* object){ return object != nullptr; } - // The inverse of `Monitor`, stops monitoring. - // Maybe garbage collect here also if the counters goes to zero. - void Unmonitor(ObjectManager::registry* object) {} - }; - - class NT_API HandlerManager - { - public: - // This is supposed to represent an authorized access to a certain object in the registry - // This increases the handle count in the object manager - // We should consider adding on the object manager a vector of all the handles that refer to an object - struct handle { - ObjectManager::registry* object = nullptr; - void* connection_context = nullptr; - }; - void DeallocateHandle(struct handle* handle) {} - struct handle Open(std::vector<std::string> object_path, void* connection_context) { - ObjectManager objects; - PermissionsManager permissions; - IdentityManager identities; - LifecycleManager lifecycles; - ObjectManager::registry* retrieved_object = objects.Find((const std::vector<std::string>)object_path); - if (permissions.Access(retrieved_object, (const void*)connection_context) - && identities.CanOpen(retrieved_object) - && lifecycles.Contention(retrieved_object)) { - // Starts monitoring this guy - lifecycles.Monitor(retrieved_object); - return { retrieved_object, connection_context }; // Return a successful handle - } - else { - // Return something more algebraic instead of null or an int - return {}; - }; - } - bool Close(struct handle *handle) { - if (handle == nullptr) { - return false; - } - PermissionsManager permissions; - IdentityManager identities; - LifecycleManager lifecycles; - // Somehow grab the object pointer and connection (maybe drop it...) from the handle - ObjectManager::registry* object = handle->object; - void* connection_context = handle->connection_context; - // Checking for permissions here may be relevant. - // What if we have a handle but no permission? Spooky - if (permissions.Access(object, connection_context) - && identities.CanClose(object) - // TODO: I think that in this case we do not need to worry about contention. - // But be careful to evaluate this scenario later. - //&& LifecycleManager::Contention(retrieved_object) - ) { - // Stops monitoring this guy - lifecycles.Unmonitor(object); - DeallocateHandle(handle); - return true; // Return a successful handle - } - else { - // Return something more algebraic instead of null or an int. - // It's kinda bad to not even report what went wrong. - return false; - }; - } - }; - - class NT_API WAM - { - }; - - class NT_API NT - { - public: - bool IsRunning() const; - void SimulateEntryCall() {}; - }; -} +#include "Types.h" +#include "ObjectManager.h" +#include "PermissionsManager.h" +#include "NamespaceReferenceManager.h" +#include "CursorManager.h" +#include "IdentityManager.h" +#include "LifecycleManager.h" +#include "HandlerManager.h" +#include "WAM.h" +#include "Runtime.h" diff --git a/include/NamespaceReferenceManager.h b/include/NamespaceReferenceManager.h new file mode 100644 index 0000000..922a0ca --- /dev/null +++ b/include/NamespaceReferenceManager.h @@ -0,0 +1,10 @@ +#pragma once + +#include "Api.h" + +namespace nt +{ + class NT_API NamespaceReferenceManager + { + }; +} diff --git a/include/ObjectManager.h b/include/ObjectManager.h new file mode 100644 index 0000000..8abf44c --- /dev/null +++ b/include/ObjectManager.h @@ -0,0 +1,47 @@ +#pragma once + +#include "Api.h" +#include "Types.h" + +#include <cstdint> +#include <set> +#include <string> +#include <vector> + +namespace nt +{ + class NT_API ObjectManager + { + public: + class IObject { + public: + virtual ~IObject() = default; + }; + class Multigroup : IObject {}; + class Relation : IObject {}; + class Tuple : IObject {}; + class Transaction : IObject {}; + struct object_type { + OBJECT_TYPE label; + // If the object is not durable. E.g.: TRANSACTION + bool disposable; + std::set<METHOD> methods; + }; + struct registry_head { + uint32_t reference_count; + uint32_t handle_count; + struct object_type* type; + std::vector<std::string> path; + //security_descriptor to be added later, maybe also a set of labels + }; + struct registry { + struct registry_head* head; + IObject object; + // TODO: Treat as a list for now, but ideally it's a tree + struct registry* next; + }; + struct registry** entries; + // Looks into this registry and attempts to retrieve the entry + struct registry* Find(const std::vector<std::string> object_path); + }; +} diff --git a/include/PermissionsManager.h b/include/PermissionsManager.h new file mode 100644 index 0000000..c51bd27 --- /dev/null +++ b/include/PermissionsManager.h @@ -0,0 +1,19 @@ +#pragma once + +#include "Api.h" +#include "ObjectManager.h" +#include "Types.h" + +#include <set> + +namespace nt +{ + class NT_API PermissionsManager + { + public: + // For validating connections at login + std::set<AUTH_CLAIM> Firewall(AUTH_METHOD method); + // For validating permission to an object + const bool Access(const ObjectManager::registry* object, const void* connection_context); + }; +} diff --git a/include/Runtime.h b/include/Runtime.h new file mode 100644 index 0000000..60a0b90 --- /dev/null +++ b/include/Runtime.h @@ -0,0 +1,13 @@ +#pragma once + +#include "Api.h" + +namespace nt +{ + class NT_API NT + { + public: + bool IsRunning() const; + void SimulateEntryCall(); + }; +} diff --git a/include/Types.h b/include/Types.h new file mode 100644 index 0000000..fe6afed --- /dev/null +++ b/include/Types.h @@ -0,0 +1,26 @@ +#pragma once + +enum OBJECT_TYPE { + MULTIGROUP, + RELATION, + TUPLE, + ATTRIBUTE, + TRANSACTION +}; + +enum METHOD { + OPEN, + CLOSE, + PARSE, // To plug a secondary namespace + SECURITY +}; + +enum AUTH_CLAIM { + READ, + WRITE +}; + +enum AUTH_METHOD { + CERTIFICATE, + PLAIN_TEXT +}; diff --git a/include/WAM.h b/include/WAM.h new file mode 100644 index 0000000..8f0cb11 --- /dev/null +++ b/include/WAM.h @@ -0,0 +1,10 @@ +#pragma once + +#include "Api.h" + +namespace nt +{ + class NT_API WAM + { + }; +} diff --git a/src/CursorManager.cpp b/src/CursorManager.cpp new file mode 100644 index 0000000..8ae4496 --- /dev/null +++ b/src/CursorManager.cpp @@ -0,0 +1,5 @@ +#include "CursorManager.h" + +namespace nt +{ +} diff --git a/src/HandlerManager.cpp b/src/HandlerManager.cpp new file mode 100644 index 0000000..895f553 --- /dev/null +++ b/src/HandlerManager.cpp @@ -0,0 +1,63 @@ +#include "HandlerManager.h" + +#include "IdentityManager.h" +#include "LifecycleManager.h" +#include "PermissionsManager.h" + +namespace nt +{ + void HandlerManager::DeallocateHandle(struct handle* handle) + { + } + + struct HandlerManager::handle HandlerManager::Open(std::vector<std::string> object_path, void* connection_context) + { + ObjectManager objects; + PermissionsManager permissions; + IdentityManager identities; + LifecycleManager lifecycles; + ObjectManager::registry* retrieved_object = objects.Find((const std::vector<std::string>)object_path); + if (permissions.Access(retrieved_object, (const void*)connection_context) + && identities.CanOpen(retrieved_object) + && lifecycles.Contention(retrieved_object)) { + // Starts monitoring this guy + lifecycles.Monitor(retrieved_object); + return { retrieved_object, connection_context }; // Return a successful handle + } + else { + // Return something more algebraic instead of null or an int + return {}; + }; + } + + bool HandlerManager::Close(struct handle* handle) + { + if (handle == nullptr) { + return false; + } + PermissionsManager permissions; + IdentityManager identities; + LifecycleManager lifecycles; + // Somehow grab the object pointer and connection (maybe drop it...) from the handle + ObjectManager::registry* object = handle->object; + void* connection_context = handle->connection_context; + // Checking for permissions here may be relevant. + // What if we have a handle but no permission? Spooky + if (permissions.Access(object, connection_context) + && identities.CanClose(object) + // TODO: I think that in this case we do not need to worry about contention. + // But be careful to evaluate this scenario later. + //&& LifecycleManager::Contention(retrieved_object) + ) { + // Stops monitoring this guy + lifecycles.Unmonitor(object); + DeallocateHandle(handle); + return true; // Return a successful handle + } + else { + // Return something more algebraic instead of null or an int. + // It's kinda bad to not even report what went wrong. + return false; + }; + } +} diff --git a/src/IdentityManager.cpp b/src/IdentityManager.cpp new file mode 100644 index 0000000..93ad705 --- /dev/null +++ b/src/IdentityManager.cpp @@ -0,0 +1,14 @@ +#include "IdentityManager.h" + +namespace nt +{ + const bool IdentityManager::CanOpen(ObjectManager::registry* object) + { + return object != nullptr; + } + + const bool IdentityManager::CanClose(ObjectManager::registry* object) + { + return object != nullptr; + } +} diff --git a/src/LifecycleManager.cpp b/src/LifecycleManager.cpp new file mode 100644 index 0000000..bcab4b5 --- /dev/null +++ b/src/LifecycleManager.cpp @@ -0,0 +1,17 @@ +#include "LifecycleManager.h" + +namespace nt +{ + void LifecycleManager::Monitor(ObjectManager::registry* object) + { + } + + const bool LifecycleManager::Contention(ObjectManager::registry* object) + { + return object != nullptr; + } + + void LifecycleManager::Unmonitor(ObjectManager::registry* object) + { + } +} @@ -1,4 +1,4 @@ -#include "NT.h" +#include "Runtime.h" #ifdef NT_CONSOLE_APP #include <iostream> @@ -10,6 +10,10 @@ namespace nt { return true; } + + void NT::SimulateEntryCall() + { + } } #ifdef NT_CONSOLE_APP diff --git a/src/NamespaceReferenceManager.cpp b/src/NamespaceReferenceManager.cpp new file mode 100644 index 0000000..1d9baac --- /dev/null +++ b/src/NamespaceReferenceManager.cpp @@ -0,0 +1,5 @@ +#include "NamespaceReferenceManager.h" + +namespace nt +{ +} diff --git a/src/ObjectManager.cpp b/src/ObjectManager.cpp new file mode 100644 index 0000000..ff85af2 --- /dev/null +++ b/src/ObjectManager.cpp @@ -0,0 +1,9 @@ +#include "ObjectManager.h" + +namespace nt +{ + struct ObjectManager::registry* ObjectManager::Find(const std::vector<std::string> object_path) + { + return nullptr; + } +} diff --git a/src/PermissionsManager.cpp b/src/PermissionsManager.cpp new file mode 100644 index 0000000..228dd2d --- /dev/null +++ b/src/PermissionsManager.cpp @@ -0,0 +1,19 @@ +#include "PermissionsManager.h" + +namespace nt +{ + std::set<AUTH_CLAIM> PermissionsManager::Firewall(AUTH_METHOD method) + { + return {}; + } + + const bool PermissionsManager::Access(const ObjectManager::registry* object, const void* connection_context) + { + // Checks the security descriptor on the head of the object we find in the ObjectManager::registry + // Then additionally check other metadata yet to be defined in the connection_context, + // like user group, policy, etc. + // Yet to decide if this should be summoned at every attempt to get ahold of an object, + // that might produce significant overhead. How can we solve this? + return object != nullptr && connection_context != nullptr; + } +} diff --git a/src/WAM.cpp b/src/WAM.cpp new file mode 100644 index 0000000..9088cd0 --- /dev/null +++ b/src/WAM.cpp @@ -0,0 +1,5 @@ +#include "WAM.h" + +namespace nt +{ +} |
