From f2c63bcdca0d0195b679852dcaa1a2322c975883 Mon Sep 17 00:00:00 2001 From: Viktor Ashirov Date: May 20 2019 12:50:47 +0000 Subject: Issue 50387 - enable_tls() should label ports with ldap_port_t Bug Description: In some tests we use enable_tls(), but the secure port doesn't get labeled automatically with ldap_port_t. Fix Description: Fix enable_tls() to label secure port. Additionally fix typo in pluginpath_validation_test.py Fixes https://pagure.io/389-ds-base/issue/50387 Reviewed by: mreynolds, mhonek (Thanks!) --- diff --git a/dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py b/dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py index 65a97be..660ceac 100644 --- a/dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py +++ b/dirsrvtests/tests/suites/plugins/pluginpath_validation_test.py @@ -67,7 +67,7 @@ def test_pluginpath_validation(topology_st): # Try using new remote location # If SELinux is enabled, plugin can't be loaded as it's not labeled properly - if selinux_present: + if selinux_present(): import selinux if selinux.is_selinux_enabled(): with pytest.raises(ldap.UNWILLING_TO_PERFORM): diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index df1add7..ed1c259 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -86,7 +86,9 @@ from lib389.utils import ( ensure_bytes, ensure_str, ensure_list_str, - format_cmd_list) + format_cmd_list, + selinux_present, + selinux_label_port) from lib389.paths import Paths from lib389.nss_ssl import NssSsl from lib389.tasks import BackupTask, RestoreTask @@ -1591,6 +1593,9 @@ class DirSrv(SimpleLDAPObject, object): self.config.set('nsslapd-security', 'on') self.use_ldaps_uri() + if selinux_present(): + selinux_label_port(self.sslport) + if self.ds_paths.perl_enabled: # We don't setup sslport correctly in perl installer .... self.config.set('nsslapd-secureport', '%s' % self.sslport)