Skip to content

Commit

Permalink
Setup localhost ssh env for ltp ftp test
Browse files Browse the repository at this point in the history
  • Loading branch information
coolgw committed Sep 27, 2024
1 parent d170841 commit 8ab0500
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions data/kernel/pam_vsftpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
auth required pam_unix.so
account required pam_unix.so
24 changes: 24 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,26 @@ 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");
}

$results = script_run("test -e /etc/pam.d/vsftpd");
if ($results) {
assert_script_run("curl -L -v -o " . "/etc/pam.d/vsftpd " . autoinst_url . "/data/kernel/pam_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 (check_var_array('LTP_COMMAND_FILE', '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

0 comments on commit 8ab0500

Please sign in to comment.