From 3e8aad3b2eb504b3e07cca877352710a7f4732eb Mon Sep 17 00:00:00 2001 From: Daniel Poelzleithner Date: Wed, 8 Dec 2021 18:26:11 +0100 Subject: [PATCH] Use sshopts for rsyncssh tests --- lsyncd.lua | 20 ++++++++++++++++++++ tests/churn-rsyncssh.lua | 4 ++-- tests/testlib.lua | 11 ++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/lsyncd.lua b/lsyncd.lua index 6690a9a..02922e4 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -4645,6 +4645,7 @@ OPTIONS: -nodaemon Does not detach and logs to stdout/stderr -pidfile FILE Writes Lsyncds PID into FILE -runner FILE Loads Lsyncds lua part from FILE + -script FILE Script to load before execting runner (ADVANCED) -sshopts Additional ssh command options when using rsyncssh -version Prints versions and exits @@ -4781,6 +4782,18 @@ function runner.configure( args, monitors ) end }, + script = + { + 1, + function + ( + file + ) + clSettings.scripts = clSettings.scripts or {} + table.insert(clSettings.scripts, file) + end + }, + rsync = { 2, @@ -4898,6 +4911,13 @@ function runner.configure( args, monitors ) i = i + 1 end + if clSettings.scripts then + for _, file in ipairs(clSettings.scripts) do + log( 'Info', 'Run addition script: ' .. file ) + dofile(file) + end + end + if clSettings.syncs then if #nonopts ~= 0 diff --git a/tests/churn-rsyncssh.lua b/tests/churn-rsyncssh.lua index 379dbbb..581bf26 100644 --- a/tests/churn-rsyncssh.lua +++ b/tests/churn-rsyncssh.lua @@ -8,8 +8,6 @@ dofile( 'tests/testlib.lua' ) cwriteln( '****************************************************************' ) cwriteln( ' Testing default.rsyncssh with random data activity ' ) cwriteln( '****************************************************************' ) -cwriteln( '( this test needs passwordless ssh localhost access )' ) -cwriteln( '( for current user )' ) local tdir, srcdir, trgdir = mktemps() @@ -24,6 +22,8 @@ local pid = spawn( '-nodaemon', '-delay', '5', + '-sshopts', + '-i tests/ssh/id_rsa -p 2468 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null', '-rsyncssh', srcdir, 'localhost', diff --git a/tests/testlib.lua b/tests/testlib.lua index e976f2e..7930fc8 100644 --- a/tests/testlib.lua +++ b/tests/testlib.lua @@ -114,11 +114,20 @@ function startSshd() cwriteln(script_path() .. "ssh/sshd_config") local sshdPath = script_path() .. "/ssh/" + + if posix.stat( sshdPath ) == nil then + cwriteln("setup ssh server in " .. sshdPath) + posix.mkdir(sshdPath) + os.execute("ssh-keygen -t rsa -N '' -f" .. sshdPath .. "id_rsa") + os.execute("cp ".. sshdPath .. "id_rsa.pub ".. sshdPath .. "authorized_keys") + os.execute("ssh-keygen -t rsa -N '' -f ".. sshdPath .. "ssh_host_rsa_key") + cwriteln("done") + end + local f = io.open( sshdPath .. "sshd_config", 'w') f:write([[ Port 2468 HostKey ]] .. sshdPath .. [[ssh_host_rsa_key - HostKey ]] .. sshdPath .. [[ssh_host_dsa_key AuthorizedKeysFile ]] .. sshdPath .. [[authorized_keys ChallengeResponseAuthentication no UsePAM no