dear all
we encountered a problem when using SecureBridge 3.0 (the licensed version, not the demo version) with Delphi XE ond Windows 7 professional 64bit.
we tried to delete a remote file using the method TScSFTPClient.RemoveFile. If the file is located directly in the serverroot directory, deleting works. However, if the file is placed in a subdirectory (e.g. [SERVERROOT]/subdir/testfile.txt), we get a "EScSFTPError" exception with the message "SFTP server error occured: Permission denied".
the user has all permissions for the server root directory, the subdirectory and the file to be deleted.
by the way, we have the same problem with the method TScSFTPClient.DownloadFile
the same method call worked with Windows XP, SecureBridge 2.6 and Delphi 2006.
is this a known problem? can you give us any advice?
thanks steve
Unable to delete remote file with SFTP
Update
We have further analysed the situation.
The "permission denied" error occurs only if the OpenDirectory procedure is called before the RemoveFile method. If the OpenDirectory call is removed, then the RemoveFile method succeeds.
The following piece of code illustrates the problem. When commenting out the line 27 and 28 (see comments), the file "foo.bar" is deleted on the remote server.
As already stated, the procedure DownloadFile shows the same behaviour.
Greets Steve
The "permission denied" error occurs only if the OpenDirectory procedure is called before the RemoveFile method. If the OpenDirectory call is removed, then the RemoveFile method succeeds.
The following piece of code illustrates the problem. When commenting out the line 27 and 28 (see comments), the file "foo.bar" is deleted on the remote server.
As already stated, the procedure DownloadFile shows the same behaviour.
Greets Steve
Code: Select all
procedure MyClass.ScSSHClientServerKeyValidate_(Sender: TObject; NewServerKey: TScKey; var Accept: Boolean);
begin
Accept := True;
end;
procedure MyClass.sampleMethod;
var
ScSSHClient: TScSSHClient;
ScFileStorage: TScFileStorage;
ScSFTPClient: TScSFTPClient;
remoteDirFileHandle: TScSFTPFileHandle;
begin
ScFileStorage := TScFileStorage.Create(nil);
ScSSHClient := TScSSHClient.Create(nil);
ScSSHClient.KeyStorage := ScFileStorage;
ScSSHClient.OnServerKeyValidate := ScSSHClientServerKeyValidate_;
ScSSHClient.HostName := '192.168.9.33';
ScSSHClient.User := 'myUser';
ScSSHClient.Password := 'myPass';
ScSSHClient.Connect;
ScSFTPClient := TScSFTPClient.Create(nil);
ScSFTPClient.SSHClient := ScSSHClient;
ScSFTPClient.Initialize;
remoteDirFileHandle := ScSFTPClient.OpenDirectory('./subdir'); // line 27
ScSFTPClient.CloseHandle(remoteDirFileHandle); // line 28
ScSFTPClient.RemoveFile('./subdir/foo.bar');
ScSFTPClient.Disconnect;
end;