mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-23 13:07:07 +01:00
remove nullable
This commit is contained in:
@@ -676,15 +676,9 @@ 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 (!platformIdentifier.IsWindows && systemIdentity.IsSuperUser!.Value)
|
||||
if (!platformIdentifier.IsWindows && systemIdentity.IsSuperUser)
|
||||
{
|
||||
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.");
|
||||
logger.LogWarning("TGS is being run as the root account. This is not recommended and may prevent launch in a future version.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Tgstation.Server.Host.Security
|
||||
/// Is this identity a SuperUser for the OS.
|
||||
/// See Administrator on Windows or root on Linux.
|
||||
/// </summary>
|
||||
bool? IsSuperUser { get; }
|
||||
bool IsSuperUser { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Clone the <see cref="ISystemIdentity"/> creating another copy that must have <see cref="IDisposable.Dispose"/> called on it.
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Tgstation.Server.Host.Security
|
||||
sealed class PosixSystemIdentity : ISystemIdentity
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public bool? IsSuperUser => Syscall.getuid() == 0;
|
||||
public bool IsSuperUser => Syscall.getuid() == 0;
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Uid => throw new NotImplementedException();
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace Tgstation.Server.Host.Security
|
||||
public string Username => userPrincipal?.Name ?? identity!.Name;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool CanCreateSymlinks => canCreateSymlinks ?? throw new NotSupportedException();
|
||||
public bool CanCreateSymlinks => IsSuperUser;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool? IsSuperUser => identity?.IsSystem;
|
||||
public bool IsSuperUser => IsSuperUser;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="WindowsIdentity"/> for the <see cref="WindowsSystemIdentity"/>.
|
||||
@@ -38,9 +38,9 @@ namespace Tgstation.Server.Host.Security
|
||||
readonly UserPrincipal? userPrincipal;
|
||||
|
||||
/// <summary>
|
||||
/// Backing field for <see cref="CanCreateSymlinks"/>.
|
||||
/// Backing field for <see cref="IsSuperUser"/>.
|
||||
/// </summary>
|
||||
readonly bool? canCreateSymlinks;
|
||||
readonly bool? isAdmin;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WindowsSystemIdentity"/> class.
|
||||
@@ -52,7 +52,7 @@ namespace Tgstation.Server.Host.Security
|
||||
if (identity.IsAnonymous)
|
||||
throw new ArgumentException($"Cannot use anonymous {nameof(WindowsIdentity)} as a {nameof(WindowsSystemIdentity)}!", nameof(identity));
|
||||
|
||||
canCreateSymlinks = new WindowsPrincipal(identity).IsInRole(WindowsBuiltInRole.Administrator);
|
||||
isAdmin = new WindowsPrincipal(identity).IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user