From b3738da1d2ab49cf9f97c8ec80ab3c4cb5caa152 Mon Sep 17 00:00:00 2001 From: Marcel Baumgartner Date: Wed, 17 May 2023 19:24:01 +0200 Subject: [PATCH] Added website directory limit for website file manager Added this change to prevent users deleting the log directories --- Moonlight/App/Helpers/Files/SftpFileAccess.cs | 6 ++++-- Moonlight/App/Services/WebSpaceService.cs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Moonlight/App/Helpers/Files/SftpFileAccess.cs b/Moonlight/App/Helpers/Files/SftpFileAccess.cs index f79b4388..9ff4452d 100644 --- a/Moonlight/App/Helpers/Files/SftpFileAccess.cs +++ b/Moonlight/App/Helpers/Files/SftpFileAccess.cs @@ -11,6 +11,7 @@ public class SftpFileAccess : FileAccess private readonly string SftpPassword; private readonly int SftpPort; private readonly bool ForceUserDir; + private readonly string AdditionalPath; private readonly SftpClient Client; @@ -19,20 +20,21 @@ public class SftpFileAccess : FileAccess get { if (ForceUserDir) - return $"/home/{SftpUser}{CurrentPath}"; + return $"/home/{SftpUser}{AdditionalPath}{CurrentPath}"; return InternalPath; } } public SftpFileAccess(string sftpHost, string sftpUser, string sftpPassword, int sftpPort, - bool forceUserDir = false) + bool forceUserDir = false, string additionalPath = "") { SftpHost = sftpHost; SftpUser = sftpUser; SftpPassword = sftpPassword; SftpPort = sftpPort; ForceUserDir = forceUserDir; + AdditionalPath = additionalPath; Client = new( new ConnectionInfo( diff --git a/Moonlight/App/Services/WebSpaceService.cs b/Moonlight/App/Services/WebSpaceService.cs index 1f1820b8..600cd39a 100644 --- a/Moonlight/App/Services/WebSpaceService.cs +++ b/Moonlight/App/Services/WebSpaceService.cs @@ -170,7 +170,7 @@ public class WebSpaceService var webspace = EnsureData(w); return Task.FromResult( - new SftpFileAccess(webspace.CloudPanel.Host, webspace.UserName, webspace.Password, 22, true) + new SftpFileAccess(webspace.CloudPanel.Host, webspace.UserName, webspace.Password, 22, true, $"/htdocs/{webspace.Domain}") ); }