From 4c9a2f1824b7d75a5506a1402a2bc23602bb3608 Mon Sep 17 00:00:00 2001 From: ChiaraBm Date: Mon, 17 Feb 2025 20:37:54 +0100 Subject: [PATCH] Fixed installation permission issue --- .../Extensions/ServerConfigurationExtensions.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MoonlightServers.Daemon/Extensions/ServerConfigurationExtensions.cs b/MoonlightServers.Daemon/Extensions/ServerConfigurationExtensions.cs index 868014d..97d6993 100644 --- a/MoonlightServers.Daemon/Extensions/ServerConfigurationExtensions.cs +++ b/MoonlightServers.Daemon/Extensions/ServerConfigurationExtensions.cs @@ -153,7 +153,16 @@ public static class ServerConfigurationExtensions // - User // Note: Some images might not work if we set a user here - parameters.User = "0:0"; + + var userId = Syscall.getuid(); + + // If we are root, we are able to change owner permissions after the installation + // so we run the installation as root, otherwise we need to run it as our current user, + // so we are able to access the files created by the installer + if (userId == 0) + parameters.User = "0:0"; + else + parameters.User = $"{userId}:{userId}"; // -- Mounts parameters.HostConfig.Mounts = new List();