diff options
| author | Liam Mitchell <[email protected]> | 2025-02-27 02:16:10 +0000 |
|---|---|---|
| committer | Liam Mitchell <[email protected]> | 2025-02-27 02:16:10 +0000 |
| commit | c49b0a053c5e28de1afa83600ebffd383766e38a (patch) | |
| tree | 3b9e7880e09ff816edd1fc9f996015ed9e6ee522 /src/zenutil/zenserverprocess.cpp | |
| parent | Linux compilation fixes (diff) | |
| download | zen-c49b0a053c5e28de1afa83600ebffd383766e38a.tar.xz zen-c49b0a053c5e28de1afa83600ebffd383766e38a.zip | |
Implementation of service commands for Linux.
Diffstat (limited to 'src/zenutil/zenserverprocess.cpp')
| -rw-r--r-- | src/zenutil/zenserverprocess.cpp | 14 |
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); |