diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index 59a844526..c3942d268 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -37,6 +37,7 @@ namespace NzbDrone.Common.Disk public abstract long? GetAvailableSpace(string path); public abstract void InheritFolderPermissions(string filename); public abstract void SetEveryonePermissions(string filename); + public abstract void SetFilePermissions(string path, string mask, string group); public abstract void SetPermissions(string path, string mask, string group); public abstract void CopyPermissions(string sourcePath, string targetPath); public abstract long? GetTotalSize(string path); diff --git a/src/NzbDrone.Common/Disk/IDiskProvider.cs b/src/NzbDrone.Common/Disk/IDiskProvider.cs index 6eb8a9aa9..d418abbcc 100644 --- a/src/NzbDrone.Common/Disk/IDiskProvider.cs +++ b/src/NzbDrone.Common/Disk/IDiskProvider.cs @@ -12,6 +12,7 @@ namespace NzbDrone.Common.Disk long? GetAvailableSpace(string path); void InheritFolderPermissions(string filename); void SetEveryonePermissions(string filename); + void SetFilePermissions(string path, string mask, string group); void SetPermissions(string path, string mask, string group); void CopyPermissions(string sourcePath, string targetPath); long? GetTotalSize(string path); diff --git a/src/NzbDrone.Core/Update/InstallUpdateService.cs b/src/NzbDrone.Core/Update/InstallUpdateService.cs index af405dd3f..74e53142b 100644 --- a/src/NzbDrone.Core/Update/InstallUpdateService.cs +++ b/src/NzbDrone.Core/Update/InstallUpdateService.cs @@ -139,7 +139,7 @@ namespace NzbDrone.Core.Update // Set executable flag on update app if (OsInfo.IsOsx || (OsInfo.IsLinux && PlatformInfo.IsNetCore)) { - _diskProvider.SetPermissions(_appFolderInfo.GetUpdateClientExePath(updatePackage.Runtime), "0755", null); + _diskProvider.SetFilePermissions(_appFolderInfo.GetUpdateClientExePath(updatePackage.Runtime), "755", null); } _logger.Info("Starting update client {0}", _appFolderInfo.GetUpdateClientExePath(updatePackage.Runtime)); diff --git a/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs b/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs index b617eef16..0d076d1e1 100644 --- a/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs +++ b/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs @@ -38,6 +38,7 @@ namespace NzbDrone.Mono.Test.DiskProviderTests { Syscall.chmod(_tempPath, FilePermissions.S_IRUSR | FilePermissions.S_IWUSR); } + _tempPath = null; } } @@ -55,7 +56,6 @@ namespace NzbDrone.Mono.Test.DiskProviderTests protected void SetWritePermissionsInternal(string path, bool writable, bool setgid) { // Remove Write permissions, we're still owner so we can clean it up, but we'll have to do that explicitly. - Stat stat; Syscall.stat(path, out stat); FilePermissions mode = stat.st_mode; @@ -69,7 +69,6 @@ namespace NzbDrone.Mono.Test.DiskProviderTests mode &= ~(FilePermissions.S_IWUSR | FilePermissions.S_IWGRP | FilePermissions.S_IWOTH); } - if (setgid) { mode |= FilePermissions.S_ISGID; diff --git a/src/NzbDrone.Mono/Disk/DiskProvider.cs b/src/NzbDrone.Mono/Disk/DiskProvider.cs index b91f95237..91e7cf999 100644 --- a/src/NzbDrone.Mono/Disk/DiskProvider.cs +++ b/src/NzbDrone.Mono/Disk/DiskProvider.cs @@ -8,6 +8,7 @@ using Mono.Unix.Native; using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.EnsureThat; +using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation; @@ -24,6 +25,7 @@ namespace NzbDrone.Mono.Disk private readonly IProcMountProvider _procMountProvider; private readonly ISymbolicLinkResolver _symLinkResolver; private readonly IRefLinkCreator _createRefLink; + private readonly Logger _logger; public DiskProvider(IProcMountProvider procMountProvider, ISymbolicLinkResolver symLinkResolver, @@ -78,10 +80,15 @@ namespace NzbDrone.Mono.Disk { } - public override void SetPermissions(string path, string mask, string group) + public override void SetFilePermissions(string path, string mask, string group) { - _logger.Debug("Setting permissions: {0} on {1}", mask, path); + var permissions = NativeConvert.FromOctalPermissionString(mask); + SetPermissions(path, mask, group, permissions); + } + + public override void SetPermissions(string path, string mask, string group) + { var permissions = NativeConvert.FromOctalPermissionString(mask); if (_fileSystem.File.Exists(path)) @@ -89,6 +96,13 @@ namespace NzbDrone.Mono.Disk permissions = GetFilePermissions(permissions); } + SetPermissions(path, mask, group, permissions); + } + + protected void SetPermissions(string path, string mask, string group, FilePermissions permissions) + { + _logger.Debug("Setting permissions: {0} on {1}", mask, path); + // Preserve non-access permissions if (Syscall.stat(path, out var curStat) < 0) { diff --git a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs index 45ae551ab..c6c70cf01 100644 --- a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs +++ b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs @@ -128,7 +128,7 @@ namespace NzbDrone.Update.UpdateEngine // Set executable flag on Readarr app if (OsInfo.IsOsx || (OsInfo.IsLinux && PlatformInfo.IsNetCore)) { - _diskProvider.SetPermissions(Path.Combine(installationFolder, "Readarr"), "0755", null); + _diskProvider.SetFilePermissions(Path.Combine(installationFolder, "Readarr"), "755", null); } } catch (Exception e) diff --git a/src/NzbDrone.Windows/Disk/DiskProvider.cs b/src/NzbDrone.Windows/Disk/DiskProvider.cs index d1fbfa100..f480eaf36 100644 --- a/src/NzbDrone.Windows/Disk/DiskProvider.cs +++ b/src/NzbDrone.Windows/Disk/DiskProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.IO.Abstractions; using System.Linq; @@ -102,6 +102,10 @@ namespace NzbDrone.Windows.Disk } } + public override void SetFilePermissions(string path, string mask, string group) + { + } + public override void SetPermissions(string path, string mask, string group) { }