aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/zenserverprocess.cpp
diff options
context:
space:
mode:
authorLiam Mitchell <[email protected]>2025-03-13 17:46:06 -0700
committerGitHub Enterprise <[email protected]>2025-03-13 17:46:06 -0700
commit64f9055d3b5c445c57a0f2dacd20853667013819 (patch)
tree54cf2adb63dec15affcdb796335b472d19e06bac /src/zenutil/zenserverprocess.cpp
parentchangelog (diff)
parentUpdate Linux service type and add libsystemd dependency (diff)
downloadzen-64f9055d3b5c445c57a0f2dacd20853667013819.tar.xz
zen-64f9055d3b5c445c57a0f2dacd20853667013819.zip
Merge pull request #288 from ue-foundation/lm/zen-service-command
Implementation of service commands for Linux.
Diffstat (limited to 'src/zenutil/zenserverprocess.cpp')
-rw-r--r--src/zenutil/zenserverprocess.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/zenutil/zenserverprocess.cpp b/src/zenutil/zenserverprocess.cpp
index 11fcce02f..0409cb976 100644
--- a/src/zenutil/zenserverprocess.cpp
+++ b/src/zenutil/zenserverprocess.cpp
@@ -168,10 +168,22 @@ ZenServerState::Initialize()
}
#else
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);