Browse Source

Linux Auth

flabbet 2 months ago
parent
commit
1fa733aebe

+ 13 - 0
src/.config/dotnet-tools.json

@@ -0,0 +1,13 @@
+{
+  "version": 1,
+  "isRoot": true,
+  "tools": {
+    "dotnet-dump": {
+      "version": "9.0.607501",
+      "commands": [
+        "dotnet-dump"
+      ],
+      "rollForward": false
+    }
+  }
+}

+ 3 - 1
src/PixiEditor.Linux/LinuxProcessUtility.cs

@@ -9,7 +9,9 @@ public class LinuxProcessUtility : IProcessUtility
 {
     public Process RunAsAdmin(string path, string args)
     {
-        throw new NotImplementedException("Running as admin is not supported on Linux");
+        // polkit 
+        
+        return Execute("pkexec", $"env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY {path} {args}");
     }
 
     public bool IsRunningAsAdministrator()

+ 0 - 5
src/PixiEditor/Helpers/ProcessHelper.cs

@@ -7,11 +7,6 @@ internal static class ProcessHelper
 {
     public static Process RunAsAdmin(string path, string? args = null)
     {
-        if (IOperatingSystem.Current.IsLinux)
-        {
-            return IOperatingSystem.Current.ProcessUtility.ShellExecute(path, args);
-        }
-        
         return IOperatingSystem.Current.ProcessUtility.RunAsAdmin(path, args);
     }
 

+ 6 - 12
src/PixiEditor/ViewModels/SubViewModels/UpdateViewModel.cs

@@ -125,15 +125,16 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
     public UpdateViewModel(ViewModelMain owner)
         : base(owner)
     {
+        IOperatingSystem.Current.ProcessUtility.RunAsAdmin("whoami", null);
         if (IOperatingSystem.Current.IsLinux)
         {
-            if(File.Exists("no-updates"))
+            if (File.Exists("no-updates"))
             {
                 UpdateState = UpdateState.UnableToCheck;
                 return;
             }
         }
-        
+
         Owner.OnStartupEvent += Owner_OnStartupEvent;
         Owner.OnClose += Owner_OnClose;
         PixiEditorSettings.Update.UpdateChannel.ValueChanged += (_, value) =>
@@ -198,7 +199,8 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
                 UpdateState = UpdateState.Downloading;
                 if (updateCompatible)
                 {
-                    await UpdateDownloader.DownloadReleaseZip(UpdateChecker.LatestReleaseInfo, ZipContentType, ZipExtension);
+                    await UpdateDownloader.DownloadReleaseZip(UpdateChecker.LatestReleaseInfo, ZipContentType,
+                        ZipExtension);
                 }
                 else if (IOperatingSystem.Current.IsWindows) // TODO: Add macos
                 {
@@ -325,15 +327,7 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
     {
         try
         {
-            if (IOperatingSystem.Current.IsLinux)
-            {
-                IOperatingSystem.Current.ProcessUtility.ShellExecute(updateExeFile, null);
-            }
-            else
-            {
-                IOperatingSystem.Current.ProcessUtility.RunAsAdmin(updateExeFile, null);
-            }
-
+            IOperatingSystem.Current.ProcessUtility.RunAsAdmin(updateExeFile, null);
             Shutdown();
         }
         catch (Win32Exception)