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 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(

View File

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