88# Maintainer: QE Security <[email protected] >99
1010package services::389ds_server ;
11- use base " opensusebasetest " ;
11+ use base ' consoletest ' ;
1212use testapi;
1313use utils;
1414use warnings;
@@ -17,6 +17,7 @@ use opensslca;
1717use network_utils ' iface' ;
1818use Utils::Architectures ' is_s390x' ;
1919use Utils::Systemd qw( disable_and_stop_service systemctl) ;
20+ use version_utils qw( has_selinux is_sle) ;
2021
2122my $local_name = ' 389ds' ;
2223my $remote_name = ' sssdclient' ;
@@ -27,21 +28,30 @@ sub install_service {
2728 zypper_call(" in 389-ds openssl" );
2829}
2930
30- # The function below covers all required steps for 389ds server's configuration
31- sub config_service {
31+ # move ssh server to another port on s390x architecture
32+ sub workaround_CC_s390x {
3233 my $server_ip = get_var(' SERVER_IP' , ' 10.0.2.101' );
3334 my $client_ip = get_var(' CLIENT_IP' , ' 10.0.2.102' );
34- if (is_s390x) {
35- my $ssh_port = ' 2222' ;
36- assert_script_run(" ip addr add $server_ip /24 dev " . iface);
37- assert_script_run(" echo \" $server_ip server master\" >> /etc/hosts" );
38- assert_script_run(" echo 'ListenAddress 0.0.0.0' >> /etc/ssh/sshd_config" );
39- assert_script_run(" echo \" Port $ssh_port \" >> /etc/ssh/sshd_config" );
40- systemctl(' restart sshd' );
41- disable_and_stop_service(' firewalld' , ignore_failure => 1);
42- disable_and_stop_service(' apparmor' , ignore_failure => 1);
43- }
35+ my $ssh_port = ' 2222' ;
36+ my $sshd_conf_file = is_sle(' >=16' ) ? ' /etc/ssh/sshd_config.d/root.conf' : ' /etc/ssh/sshd_config' ;
37+ assert_script_run " ip addr add $server_ip /24 dev " . iface;
38+ assert_script_run " echo \" $server_ip server master\" >> /etc/hosts" ;
39+ assert_script_run " echo 'ListenAddress 0.0.0.0' >> $sshd_conf_file " ;
40+ assert_script_run " echo \" Port $ssh_port \" >> $sshd_conf_file " ;
41+ # on SELINUX enabled system, we need to add new port type to avoid sshd start failure
42+ assert_script_run " semanage port -a -t ssh_port_t -p tcp $ssh_port " if has_selinux;
43+ systemctl(' restart sshd' );
44+ disable_and_stop_service(' firewalld' , ignore_failure => 1);
45+ disable_and_stop_service(' apparmor' , ignore_failure => 1);
46+ # TODO DEBUG
47+ record_info(' sshd configuration:' , script_output(' sshd -T' ));
48+ }
4449
50+ # The function below covers all required steps for 389ds server's configuration
51+ sub config_service {
52+ # Permit ssh/scp from client as root
53+ permit_root_ssh();
54+ workaround_CC_s390x if is_s390x;
4555 # Start a local instance with basic configuration file
4656 assert_script_run(" wget --quiet " . data_url(" 389ds/instance.inf" ) . " -O /tmp/instance.inf" );
4757 assert_script_run(" sed -i 's/\{\{ PASSWORD\}\} /$testapi::password /g' /tmp/instance.inf" );
@@ -114,8 +124,6 @@ sub config_service {
114124 # Set the ldap_uri with LDAP over SSL (LDAPS) Certificate
115125 assert_script_run(" sed -i 's/^ldap_uri =.*\$ /ldap_uri = ldaps:\\ /\\ /$local_name .example.com/' /tmp/sssd.conf" );
116126
117- # Permit ssh/scp from client as root
118- permit_root_ssh();
119127}
120128
121129sub enable_service {
0 commit comments