diff options
| author | Dan Engelbrecht <[email protected]> | 2024-10-23 10:31:43 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-10-23 10:31:43 +0200 |
| commit | 530ab3394938331f224058c381a1db5d4a68e6a9 (patch) | |
| tree | 5060eb394d67b7454855aed0fa8d7d3acf5f5c98 /src/zencore/filesystem.cpp | |
| parent | fix gc date (#204) (diff) | |
| download | zen-530ab3394938331f224058c381a1db5d4a68e6a9.tar.xz zen-530ab3394938331f224058c381a1db5d4a68e6a9.zip | |
workspace share security (#192)
- Improvement: Reworked workspace shares to be more secure. Workspaces and workspace shares can only be created using the `zen workspace` command, the http endpoint is disabled unless zenserver is started with the `--workspaces-allow-changes` option enabled.
- Each workspace are now configured via a `zenworkspaceconfig.json` file in the root of each workspace
- A workspace can allow shares to be created via the http interface if the workspace is created with the `--allow-share-create-from-http` option enabled
- A new http endpoint at `/ws` - issuing a `Get` operation will get you a list of workspaces
- A new http endpoint at `/ws/refresh` - issuing a `Get` will make zenserver scan for edits in workspaces and workspace shares
Diffstat (limited to 'src/zencore/filesystem.cpp')
| -rw-r--r-- | src/zencore/filesystem.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp index ac2aabbf0..93383a656 100644 --- a/src/zencore/filesystem.cpp +++ b/src/zencore/filesystem.cpp @@ -14,6 +14,9 @@ #if ZEN_PLATFORM_WINDOWS # include <zencore/windows.h> +# include <ShlObj.h> +# pragma comment(lib, "shell32.lib") +# pragma comment(lib, "ole32.lib") #endif #if ZEN_PLATFORM_WINDOWS @@ -28,6 +31,7 @@ ZEN_THIRD_PARTY_INCLUDES_END # include <fcntl.h> # include <sys/resource.h> # include <sys/stat.h> +# include <pwd.h> # include <unistd.h> #endif @@ -38,6 +42,7 @@ ZEN_THIRD_PARTY_INCLUDES_END # include <sys/resource.h> # include <sys/stat.h> # include <sys/syslimits.h> +# include <pwd.h> # include <unistd.h> #endif @@ -1702,6 +1707,31 @@ SearchPathForExecutable(std::string_view ExecutableName) #endif } +std::filesystem::path +PickDefaultSystemRootDirectory() +{ +#if ZEN_PLATFORM_WINDOWS + // Pick sensible default + PWSTR ProgramDataDir = nullptr; + HRESULT hRes = SHGetKnownFolderPath(FOLDERID_ProgramData, 0, NULL, &ProgramDataDir); + + if (SUCCEEDED(hRes)) + { + std::filesystem::path FinalPath(ProgramDataDir); + FinalPath /= L"Epic\\Zen"; + ::CoTaskMemFree(ProgramDataDir); + + return FinalPath; + } + + return L""; +#else // ZEN_PLATFORM_WINDOWS + int UserId = getuid(); + const passwd* Passwd = getpwuid(UserId); + return std::filesystem::path(Passwd->pw_dir) / ".zen"; +#endif // ZEN_PLATFORM_WINDOWS +} + ////////////////////////////////////////////////////////////////////////// // // Testing related code follows... |