diff options
| author | Liam Mitchell <[email protected]> | 2025-08-22 16:12:38 -0700 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-08-22 16:12:38 -0700 |
| commit | 207c4a32612891711d9d69466b6dfc653428bb07 (patch) | |
| tree | d4b8de42a91ee3327b14fc0aa66c92bc3de46555 /src/zenutil/zenserverprocess.cpp | |
| parent | 5.6.18-pre0 (diff) | |
| parent | Move windows service utilities to zenutil and fix clang-format errors (diff) | |
| download | zen-207c4a32612891711d9d69466b6dfc653428bb07.tar.xz zen-207c4a32612891711d9d69466b6dfc653428bb07.zip | |
Merge pull request #139 from ue-foundation/de/zen-service-command
zen service command
Diffstat (limited to 'src/zenutil/zenserverprocess.cpp')
| -rw-r--r-- | src/zenutil/zenserverprocess.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/zenutil/zenserverprocess.cpp b/src/zenutil/zenserverprocess.cpp index a5b342cb0..4fd1cef9a 100644 --- a/src/zenutil/zenserverprocess.cpp +++ b/src/zenutil/zenserverprocess.cpp @@ -167,10 +167,23 @@ ZenServerState::Initialize() ThrowLastError("Could not map view of Zen server state"); } #else - int Fd = shm_open("/UnrealEngineZen", O_RDWR | O_CREAT | O_CLOEXEC, 0666); + ZEN_INFO("{}", S_IRUSR | S_IWUSR | S_IXUSR); + ZEN_INFO("{}", geteuid()); + int Fd = shm_open("/UnrealEngineZen", O_RDWR | O_CREAT | O_CLOEXEC, geteuid() == 0 ? 0766 : 0666); if (Fd < 0) { - ThrowLastError("Could not open a shared memory object"); + // Work around a potential issue if the service user is changed in certain configurations. + // If the sysctl 'fs.protected_regular' is set to 1 or 2 (default on many distros), + // we will be unable to open an existing shared memory object created by another user using O_CREAT, + // even if we have the correct permissions, or are running as root. If we destroy the existing + // shared memory object and retry, we'll be able to get past shm_open() so long as we have + // the appropriate permissions to create the shared memory object. + shm_unlink("/UnrealEngineZen"); + Fd = shm_open("/UnrealEngineZen", O_RDWR | O_CREAT | O_CLOEXEC, geteuid() == 0 ? 0766 : 0666); + if (Fd < 0) + { + ThrowLastError("Could not open a shared memory object"); + } } fchmod(Fd, 0666); void* hMap = (void*)intptr_t(Fd); |