Added website directory limit for website file manager

Added this change to prevent users deleting the log directories
This commit is contained in:
Marcel Baumgartner
2023-05-17 19:24:01 +02:00
parent 323342057e
commit b3738da1d2
2 changed files with 5 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ public class SftpFileAccess : FileAccess
private readonly string SftpPassword; private readonly string SftpPassword;
private readonly int SftpPort; private readonly int SftpPort;
private readonly bool ForceUserDir; private readonly bool ForceUserDir;
private readonly string AdditionalPath;
private readonly SftpClient Client; private readonly SftpClient Client;
@@ -19,20 +20,21 @@ public class SftpFileAccess : FileAccess
get get
{ {
if (ForceUserDir) if (ForceUserDir)
return $"/home/{SftpUser}{CurrentPath}"; return $"/home/{SftpUser}{AdditionalPath}{CurrentPath}";
return InternalPath; return InternalPath;
} }
} }
public SftpFileAccess(string sftpHost, string sftpUser, string sftpPassword, int sftpPort, public SftpFileAccess(string sftpHost, string sftpUser, string sftpPassword, int sftpPort,
bool forceUserDir = false) bool forceUserDir = false, string additionalPath = "")
{ {
SftpHost = sftpHost; SftpHost = sftpHost;
SftpUser = sftpUser; SftpUser = sftpUser;
SftpPassword = sftpPassword; SftpPassword = sftpPassword;
SftpPort = sftpPort; SftpPort = sftpPort;
ForceUserDir = forceUserDir; ForceUserDir = forceUserDir;
AdditionalPath = additionalPath;
Client = new( Client = new(
new ConnectionInfo( new ConnectionInfo(

View File

@@ -170,7 +170,7 @@ public class WebSpaceService
var webspace = EnsureData(w); var webspace = EnsureData(w);
return Task.FromResult<FileAccess>( return Task.FromResult<FileAccess>(
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}")
); );
} }