Skip to content

Commit

Permalink
Setup localhost ssh env for ltp test
Browse files Browse the repository at this point in the history
  • Loading branch information
coolgw committed Sep 25, 2024
1 parent d170841 commit ad01a28
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/LTP/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ our @EXPORT = qw(
get_default_pkg
install_from_repo
prepare_whitelist_environment
setup_localhost_sshd
setup_ftp
);

sub loadtest_kernel {
Expand Down Expand Up @@ -527,4 +529,27 @@ sub prepare_whitelist_environment {
return $environment;
}

sub setup_localhost_sshd {
assert_script_run "ssh-keygen -t rsa -P '' -C 'root\@localhost' -f /root/.ssh/id_rsa";
assert_script_run "cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys";
assert_script_run "ssh-keyscan -H localhost >> /root/.ssh/known_hosts";

permit_root_ssh;

}

sub setup_ftp {
my $results = script_run("command -v vsftpd");
if (!$results) {
assert_script_run("sed -i 's/^write_enable.*\$/write_enable=YES/' /etc/vsftpd.conf");
assert_script_run("systemctl restart vsftpd");
}

my $results = script_run("test -e /etc/pam.d/vsftpd");
if ($results) {
assert_script_run("echo 'auth required pam_unix.so' >> /etc/pam.d/vsftpd");
assert_script_run("echo 'account required pam_unix.so' >> /etc/pam.d/vsftpd");
}
}

1;
5 changes: 5 additions & 0 deletions tests/kernel/boot_ltp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ sub run {
select_console('root-console') if get_var('LTP_DEBUG');
select_serial_terminal;

if (get_var('LTP_COMMAND_FILE') eq "net.tcp_cmds") {
setup_localhost_sshd;
setup_ftp;
}

# Debug code for poo#81142
script_run('gzip -9 </dev/fb0 >framebuffer.dat.gz');
upload_logs('framebuffer.dat.gz', failok => 1);
Expand Down
2 changes: 2 additions & 0 deletions tests/kernel/install_ltp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ sub run {
}

setup_network;
setup_localhost_sshd;
setup_ftp;

# we don't run LVM tests in 32bit, thus not generating the runtest file
# for 32 bit packages
Expand Down

0 comments on commit ad01a28

Please sign in to comment.