diff options
| author | Bond-009 <bond.009@outlook.com> | 2022-12-07 17:17:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-07 17:17:37 +0100 |
| commit | 584c80e323ac2a1386d86ff9f59e50daf174418e (patch) | |
| tree | 4dbb2861cb79cf418a76a4b8f364fdc5c62b56f7 /Jellyfin.Server/Program.cs | |
| parent | f3c57e6a0ae015dc51cf548a0380d1bed33959c2 (diff) | |
| parent | 227aa0540bf0d6c00848b0efb8a5e0ece86c7412 (diff) | |
Merge pull request #8547 from Bond-009/net7
Diffstat (limited to 'Jellyfin.Server/Program.cs')
| -rw-r--r-- | Jellyfin.Server/Program.cs | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 0b922f821..46f45b9ad 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Net; using System.Reflection; using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -201,7 +202,7 @@ namespace Jellyfin.Server { await webHost.StartAsync(_tokenSource.Token).ConfigureAwait(false); - if (startupConfig.UseUnixSocket() && Environment.OSVersion.Platform == PlatformID.Unix) + if (!OperatingSystem.IsWindows() && startupConfig.UseUnixSocket()) { var socketPath = GetUnixSocketPath(startupConfig, appPaths); @@ -691,27 +692,15 @@ namespace Jellyfin.Server return socketPath; } + [UnsupportedOSPlatform("windows")] private static void SetUnixSocketPermissions(IConfiguration startupConfig, string socketPath) { var socketPerms = startupConfig.GetUnixSocketPermissions(); if (!string.IsNullOrEmpty(socketPerms)) { - #pragma warning disable SA1300 // Entrypoint is case sensitive. - [DllImport("libc")] - static extern int chmod(string pathname, int mode); - #pragma warning restore SA1300 - - var exitCode = chmod(socketPath, Convert.ToInt32(socketPerms, 8)); - - if (exitCode < 0) - { - _logger.LogError("Failed to set Kestrel unix socket permissions to {SocketPerms}, return code: {ExitCode}", socketPerms, exitCode); - } - else - { - _logger.LogInformation("Kestrel unix socket permissions set to {SocketPerms}", socketPerms); - } + File.SetUnixFileMode(socketPath, (UnixFileMode)Convert.ToInt32(socketPerms, 8)); + _logger.LogInformation("Kestrel unix socket permissions set to {SocketPerms}", socketPerms); } } } |
