Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix: Fix binary permissions #103

Merged
merged 2 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions StabilityMatrix.Avalonia/Assets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@ internal static class Assets
public static AvaloniaResource LicensesJson => new(
"avares://StabilityMatrix.Avalonia/Assets/licenses.json");

private const UnixFileMode unix755 = UnixFileMode.UserRead | UnixFileMode.UserWrite |
UnixFileMode.UserExecute | UnixFileMode.GroupRead |
UnixFileMode.GroupExecute | UnixFileMode.OtherRead |
UnixFileMode.OtherExecute;

[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
public static AvaloniaResource SevenZipExecutable => Compat.Switch(
(PlatformKind.Windows,
new AvaloniaResource("avares://StabilityMatrix.Avalonia/Assets/win-x64/7za.exe")),
(PlatformKind.Linux | PlatformKind.X64,
new AvaloniaResource("avares://StabilityMatrix.Avalonia/Assets/linux-x64/7zzs", (UnixFileMode) 0777)),
new AvaloniaResource("avares://StabilityMatrix.Avalonia/Assets/linux-x64/7zzs", unix755)),
(PlatformKind.MacOS | PlatformKind.Arm,
new AvaloniaResource("avares://StabilityMatrix.Avalonia/Assets/macos-arm64/7zz", (UnixFileMode) 0x777)));
new AvaloniaResource("avares://StabilityMatrix.Avalonia/Assets/macos-arm64/7zz", unix755)));

[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
Expand Down
6 changes: 5 additions & 1 deletion StabilityMatrix.Avalonia/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ private static void HandleUpdateReplacement()
// Ensure permissions are set for unix
if (Compat.IsUnix)
{
File.SetUnixFileMode(targetExe, (UnixFileMode) 0x755);
File.SetUnixFileMode(targetExe, // 0755
UnixFileMode.UserRead | UnixFileMode.UserWrite |
UnixFileMode.UserExecute | UnixFileMode.GroupRead |
UnixFileMode.GroupExecute | UnixFileMode.OtherRead |
UnixFileMode.OtherExecute);
}

// Start the new app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ private async Task InstallUpdate()
// On unix, we need to set the executable bit
if (Compat.IsUnix)
{
File.SetUnixFileMode(UpdateHelper.ExecutablePath, (UnixFileMode) 0x755);
File.SetUnixFileMode(UpdateHelper.ExecutablePath, // 0755
UnixFileMode.UserRead | UnixFileMode.UserWrite |
UnixFileMode.UserExecute | UnixFileMode.GroupRead |
UnixFileMode.GroupExecute | UnixFileMode.OtherRead |
UnixFileMode.OtherExecute);
}

UpdateText = "Update complete. Restarting Stability Matrix in 3 seconds...";
Expand Down