[pve-devel] applied: [PATCH storage 4/16] storage_migrate: also log with an insecure connection if there is a log function
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Feb 5 09:45:43 CET 2020
with the following follow-up:
commit 8e55b4f28838115c9cb3b85637d6b614da759cf6
Author: Fabian Grünbichler <f.gruenbichler at proxmox.com>
storage_migrate: only set errfunc for send stream
since we redirect the output to our (insecure) socket, logfunc is only
used for STDERR anyway, so we might as well make it explicit on the
caller side.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 2b292f6..62d72de 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -626,7 +626,7 @@ sub storage_migrate {
or die "failed to connect to tunnel at $ip:$port\n";
# we won't be reading from the socket
shutdown($socket, 0);
- run_command([$send, @cstream], output => '>&'.fileno($socket), logfunc => $logfunc);
+ run_command([$send, @cstream], output => '>&'.fileno($socket), errfunc => $logfunc);
# don't close the connection entirely otherwise the receiving end
# might not get all buffered data (and fails with 'connection reset by peer')
shutdown($socket, 1);
On January 29, 2020 2:30 pm, Fabian Ebner wrote:
> Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
> ---
> PVE/Storage.pm | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index 5fefa06..2b292f6 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -626,11 +626,21 @@ sub storage_migrate {
> or die "failed to connect to tunnel at $ip:$port\n";
> # we won't be reading from the socket
> shutdown($socket, 0);
> - run_command([$send, @cstream], output => '>&'.fileno($socket));
> + run_command([$send, @cstream], output => '>&'.fileno($socket), logfunc => $logfunc);
> # don't close the connection entirely otherwise the receiving end
> # might not get all buffered data (and fails with 'connection reset by peer')
> shutdown($socket, 1);
> - 1 while <$info>; # wait for the remote process to finish
> +
> + # wait for the remote process to finish
> + if ($logfunc) {
> + while (my $line = <$info>) {
> + chomp($line);
> + $logfunc->("[$target_sshinfo->{name}] $line");
> + }
> + } else {
> + 1 while <$info>;
> + }
> +
> # now close the socket
> close($socket);
> if (!close($info)) { # does waitpid()
> --
> 2.20.1
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
More information about the pve-devel
mailing list