From d2c9ab62fe42e19ff1f8ae90870fff85b4528f7a Mon Sep 17 00:00:00 2001 From: ZephyrTFA Date: Sun, 18 Aug 2024 13:45:24 -0400 Subject: [PATCH] change usage --- .../Components/InstanceManager.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index b56f9c0dd3..c984de9ad2 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -676,9 +676,15 @@ namespace Tgstation.Server.Host.Components if (!systemIdentity.CanCreateSymlinks) throw new InvalidOperationException($"The user running {Constants.CanonicalPackageName} cannot create symlinks! Please try running as an administrative user!"); - if (systemIdentity is PosixSystemIdentity posixIdentity && posixIdentity.IsRoot()) + if (!platformIdentifier.IsWindows && systemIdentity.IsSuperUser!.Value) { - logger.LogWarning("TGS is being run as the root account. This is not recommended and may prevent launch in a future version."); + if (systemIdentity.IsSuperUser is not { } superUser) + { + throw new InvalidOperationException("Failed to determine if running as root."); + } + + if (superUser) + logger.LogWarning("TGS is being run as the root account. This is not recommended and may prevent launch in a future version."); } }