diff -ruN smeserver-affa-3.3.1.old/root/sbin/affa smeserver-affa-3.3.1/root/sbin/affa --- smeserver-affa-3.3.1.old/root/sbin/affa 2021-09-22 16:40:29.475850541 +0200 +++ smeserver-affa-3.3.1/root/sbin/affa 2021-09-22 16:41:13.782580213 +0200 @@ -580,8 +580,7 @@ my @cmd = ( $1, '--run', $jobname, 'yearly' ); ExecCmd( @cmd, 1 ) if ( $job{'_doneDates'}->val( 'doneDates', 'yearly' ) ne $thisYear and $job{'yearlyKeep'} > 0 ); $cmd[3] = 'monthly'; - ExecCmd( @cmd, 1 ) - if ( $job{'_doneDates'}->val( 'doneDates', 'monthly' ) ne $thisMonth and $job{'monthlyKeep'} > 0 ); + ExecCmd( @cmd, 1 ) if ( $job{'_doneDates'}->val( 'doneDates', 'monthly' ) ne $thisMonth and $job{'monthlyKeep'} > 0 ); $cmd[3] = 'weekly'; ExecCmd( @cmd, 1 ) if ( $job{'_doneDates'}->val( 'doneDates', 'weekly' ) ne $thisWeek and $job{'weeklyKeep'} > 0 ); $cmd[3] = 'daily'; @@ -688,8 +687,7 @@ $job{'rsyncCompress'} eq 'yes' ? "--compress" : "", "--numeric-ids", "--rsync-path=\"$job{'_rsyncRemote'}\"", - "--rsh=\"$job{'localSSHBinary'} $job{'_sshOpts'}\"", - ( $linkDest ? "--link-dest='$job{'RootDir'}/$jobname/$linkDest'" : '' ), + "--rsh=\"$job{'localSSHBinary'} $job{'_sshOpts'}\"", ( $linkDest ? "--link-dest='$job{'RootDir'}/$jobname/$linkDest'" : '' ), $include, $exclude, $job{'rsyncOptions'}, @@ -1007,9 +1005,7 @@ # get Done Dates if ($jobname) { # reetp add -i id_rsa_affa here - $job{'_sshOpts'} = - "-p $job{'sshPort'} -i '/root/.ssh/id_rsa_affa' -o CheckHostIP=no -o StrictHostKeyChecking=no -o HostKeyAlias=$jobname -o UserKnownHostsFile=/root/.ssh/knownhosts-$jobname" - . ( $job{'Debug'} ne 'yes' ? ' -q' : '' ); + $job{'_sshOpts'} = "-p $job{'sshPort'} -i '/root/.ssh/id_rsa_affa' -o CheckHostIP=no -o StrictHostKeyChecking=no -o HostKeyAlias=$jobname -o UserKnownHostsFile=/root/.ssh/knownhosts-$jobname" . ( $job{'Debug'} ne 'yes' ? ' -q' : '' ); $job{'_lockfile'} = "$lockdir/$jobname"; } return %job; @@ -1345,10 +1341,7 @@ } else { lg( "Checking SSH connection to " . $job{'remoteUser'} . '@' . $job{'remoteHostName'} ); - @cmd = ( - '/usr/bin/ssh', '-o', "ConnectTimeout=$job{'ConnectionCheckTimeout'}", - '-o', 'PasswordAuthentication=no', $job{'_sshOpts'}, $job{'remoteUser'} . '@' . $job{'remoteHostName'}, - 'echo OK' + @cmd = ( '/usr/bin/ssh', '-o', "ConnectTimeout=$job{'ConnectionCheckTimeout'}", '-o', 'PasswordAuthentication=no', $job{'_sshOpts'}, $job{'remoteUser'} . '@' . $job{'remoteHostName'}, 'echo OK' ); ExecCmd( @cmd, 0 ); chomp($ExecCmdOut); @@ -1380,9 +1373,7 @@ #### ligne suivante: rajouté $jobname remoteCopy( $jobname, "/sbin/e-smith/affa-rpmlist.sh", "/sbin/e-smith/affa-rpmlist.sh" ); - @cmd = ( - '/usr/bin/ssh', '-o', "HostKeyAlias=$jobname", '-p', $job{'sshPort'}, $sshQuiet, $job{'remoteHostName'}, - "'/sbin/e-smith/affa-rpmlist.sh>$rpmlist'" + @cmd = ( '/usr/bin/ssh', '-p', $job{'sshPort'}, '-i', '/root/.ssh/id_rsa_affa', '-o', "HostKeyAlias=$jobname", $sshQuiet, $job{'remoteHostName'}, "'/sbin/e-smith/affa-rpmlist.sh>$rpmlist'" ); } not ExecCmd( @cmd, 0 ) or affaErrorExit("writing list of installed RPMs failed."); @@ -1691,9 +1682,7 @@ close(WDS); close(WD); chmod( 0700, "/tmp/$$.$WDName" ); - my @cmd = ( - '/usr/bin/ssh', '-o', "HostKeyAlias=$jobname", '-p', $job{'sshPort'}, $job{'remoteHostName'}, "/bin/rm", "-f", - "/etc/cron.hourly/$WDName-reminder" + my @cmd = ( '/usr/bin/ssh', '-p', $job{'sshPort'}, '-i', '/root/.ssh/id_rsa_affa', '-o', "HostKeyAlias=$jobname", $job{'remoteHostName'}, "/bin/rm", "-f", "/etc/cron.hourly/$WDName-reminder" ); not ExecCmd( @cmd, 0 ) or affaErrorExit("Couldn't delete /etc/cron.hourly/$WDName-reminder on remote host."); ##### ligne suivante: ajouté $jobname @@ -1726,9 +1715,7 @@ #### ligne suivante: ajouté $jobname remoteCopy( $jobname, "/usr/lib/affa/$WDName", "/tmp/" ); - my @cmd = ( - '/usr/bin/ssh', '-p', $job{'sshPort'}, '-o', "HostKeyAlias=$jobname", $sshQuiet, $job{'remoteHostName'}, - "/tmp/$WDName" + my @cmd = ( '/usr/bin/ssh', '-p', $job{'sshPort'}, '-i', '/root/.ssh/id_rsa_affa', '-o', "HostKeyAlias=$jobname", $sshQuiet, $job{'remoteHostName'}, "/tmp/$WDName" ); not ExecCmd( @cmd, 0 ) or affaErrorExit("Couldn't run /usr/lib/affa/$WDName on remote host."); } @@ -3104,9 +3091,7 @@ "--partial", $job{'rsync--inplace'} ne 'no' ? "--inplace" : "", "--numeric-ids", - "--rsh=\"$job{'localSSHBinary'} $job{'_sshOpts'}\"", - ( -d $src ? "$src/" : "$src" ), - $job{'remoteHostName'} eq 'localhost' ? "/$k" : $job{'remoteUser'} . '@' . $job{'remoteHostName'} . ":/$k" + "--rsh=\"$job{'localSSHBinary'} $job{'_sshOpts'}\"", ( -d $src ? "$src/" : "$src" ), $job{'remoteHostName'} eq 'localhost' ? "/$k" : $job{'remoteUser'} . '@' . $job{'remoteHostName'} . ":/$k" ); #################################################################################### @@ -3255,27 +3240,20 @@ printf "%-16s : ", $jb; if ( $job{'_rsyncd'} ) { print "Rsyncd connection "; - @cmd = ( - $job{'_rsyncLocal'}, '-dq', - ( $job{'rsyncdUser'} ? $job{'rsyncdUser'} . '@' : '' ) - . $job{'remoteHostName'} . "::'" - . $job{'rsyncdModule'} . "'" + @cmd = ( $job{'_rsyncLocal'}, '-dq', ( $job{'rsyncdUser'} ? $job{'rsyncdUser'} . '@' : '' ) . $job{'remoteHostName'} . "::'" . $job{'rsyncdModule'} . "'" ); print( ( ( ExecCmd( @cmd, 0 ) == 0 ) ? "ok" : "FAILED" ) . ". " ); } - print "SSH connection "; - @cmd = ( - '/usr/bin/ssh', '-p', - $job{'sshPort'}, '-o', - "HostKeyAlias=$jb", '-o', - 'StrictHostKeyChecking=yes', '-o', - "ConnectTimeout=$job{'ConnectionCheckTimeout'}", '-o', - 'PasswordAuthentication=no', $job{'_sshOpts'}, - $job{'remoteUser'} . '@' . $job{'remoteHostName'}, 'echo OK' - ); - ExecCmd( @cmd, 0 ); - chomp($ExecCmdOut); - print( $ExecCmdOut eq "OK" ? "ok\n" : "FAILED\n" ); + if ($jb ne 'localhost') { + print "SSH connection "; + @cmd = ( '/usr/bin/ssh', '-p', $job{'sshPort'}, '-i', '/root/.ssh/id_rsa_affa', '-o', "HostKeyAlias=$jb", '-o', 'StrictHostKeyChecking=yes', '-o', "ConnectTimeout=$job{'ConnectionCheckTimeout'}", '-o', 'PasswordAuthentication=no', $job{'_sshOpts'}, $job{'remoteUser'} . '@' . $job{'remoteHostName'}, 'echo OK' + ); + ExecCmd( @cmd, 0 ); + chomp($ExecCmdOut); + print( $ExecCmdOut eq "OK" ? "ok\n" : "FAILED\n" ); + } else { + print "Not tested\n"; + } } }