From 83cf6d428fe58149abd62783152966131a512c1d Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 1 Jul 2016 17:48:22 +0200 Subject: [PATCH] update receiver to handle symlinks symlinks need to be send to a new rpc "filedata.2" because the old rpc can't handle it. the updated receiver is installed under the old name "filedata" too in case older daemons send push --- clusterd | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/clusterd b/clusterd index c4bd8f5..e657052 100755 --- a/clusterd +++ b/clusterd @@ -302,6 +302,7 @@ our ($udp_peer_addr,$udp_peer_port); # ('141.14.12.12',1234) our %UDP_HANDLER= ( 'filedata' => \&udp_rx_filedata, + 'filedata.2' => \&udp_rx_filedata, 'amdtardata' => \&udp_rx_amdtardata, 'loadavg.2' => \&udp_rx_loadavg2, 'restart' => \&udp_rx_restart, @@ -587,6 +588,24 @@ sub udp_rx_filedata { return; } + if ($st_want->type eq 'L') { + if (!$st_is || $st_is->type ne 'L' || $st_is->target ne $st_want->target) { + $st_is and (unlink($filename) or return warn "$filename: failed to unlink: $!\n"); + symlink($st_want->target,$filename) or return warn "$filename: failed to create symlink: $!\n"; + lchown($st_want->uid,$st_want->gid,$filename); + lmtime($st_want->mtime,$filename); + warn "installed $filename -> ".$st_want->target."\n"; + } else { + if ($st_is->uid != $st_want->uid || $st_is->gid != $st_want->gid) { + lchown($st_want->uid,$st_want->gid,$filename); + } + if ($st_is->mtime != $st_want->mtime) { + lmtime($st_want->mtime,$filename); + } + } + return; + } + if (length($data) == $st_want->size) { # complete file in one broadcast my $fh=IO::File->new($tmp_filename,O_WRONLY|O_CREAT,0);