datalad_ria.patches.sshremoteio
Correct flaws in SSHRemoteIO operation
The original code has a number of problems.
The
cmd-argument for the shell ssh-process, which is created by:self.shell = subprocess.Popen(cmd, ...)is not correct, ifself.ssh``i is an instance of ``NoMultiplexSSHConnection.The changes in this patch build the correct
cmd-argument by adding additional arguments tocmd, if self.ssh is an instance ofNoMultiplexSSHConnection. More precisely, the arguments that are required to open a "shell" in aNoMultiplexSSHConnectionare stored inNoMultiplexSSHConnection._ssh_open_argsand not inNoMultiplexSSHConnection._ssh_args. This patch therefore provides arguments from both lists, i.e. from_ssh_argsand_ssh_open_argsin the call that opens a "shell", ifself.sshis an instance ofNoMultiplexSSHConnection.The while-loop that waits to read
b"RIA-REMOTE-LOGIN-END\n"from the shell ssh-process did not contain any error handling. That led to an infinite loop in case that the shell ssh-process terminates without writingb"RIA-REMOTE-LOGIN-END\n"to its stdout, or in the case that the stdout-pipeline of the shell ssh-process is closed.This patch introduces two checks into the while loop. One check for termination of the ssh shell-process, and one check for a closed stdout-pipeline of the ssh shell-process, i.e. reading an EOF from the stdout-pipeline. If any of those two cases appears, an exception is raised.
The output endmarker handling in
SSHRemoteIO._run()could not reliably handle commands that would yield output without a final newline (e.g.,catof a file without a trailing newline). This patch changes to endmarker handling to guarantee that they appear on a dedicated line, by prefixing the marker itself with a newline (which is withheld form the actual output).SSHRemoteIO.remove_dir()would not fail (unlikeFileIO.remove_dir()) when ran on a non-empty directory. Despite not failing, it would also not remove that directory.
In addition, this patch modifies two comments. It adds a missing description of
the buffer_size-parameter of SSHRemoteIO.__init__``to the doc-string, and
fixes the description of the condition in the comment on the use of
``DEFAULT_BUFFER_SIZE.
- datalad_ria.patches.sshremoteio.SSHRemoteIO_append_end_markers(self, cmd)[source]
Append end markers to remote command
- datalad_ria.patches.sshremoteio.patch(self, path)