Skip to content

Commit 32d64d9

Browse files
aborah-sudopbrezina
authored andcommitted
Add socket_responders() method to common configuration
Add a method to SSSDCommonConfiguration that configures SSSD for socket-activated responders by properly managing the services line in sssd.conf and starting the corresponding systemd socket units using the SystemdServices utility.
1 parent 936bc82 commit 32d64d9

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

sssd_test_framework/utils/sssd.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,3 +1043,41 @@ def pam(self, features: list[str] | None = None) -> None:
10431043

10441044
self.sssd.authselect.select("sssd", features)
10451045
self.sssd.enable_responder("pam")
1046+
1047+
def socket_responders(self, responders: list[str] | None = None) -> None:
1048+
"""
1049+
Configure SSSD for socket-activated responders.
1050+
1051+
Removes specified responders from the services line in sssd.conf
1052+
to enable socket activation, while keeping other services running
1053+
as traditional services.
1054+
1055+
:param responders: List of responders to enable via socket activation.
1056+
If None, enables all known socket responders.
1057+
:type responders: list[str] | None
1058+
:raises RuntimeError: If starting a socket unit fails.
1059+
"""
1060+
# All known SSSD responders that support socket activation
1061+
all_responders = ["nss", "pam", "sudo", "ssh", "pac", "autofs"]
1062+
1063+
if responders is None:
1064+
responders = all_responders
1065+
1066+
# Get current services list from the configuration
1067+
current_services = self.sssd.sssd.get("services", "")
1068+
1069+
# Parse the current services line
1070+
services_list = [s.strip() for s in current_services.split(",")] if current_services else []
1071+
1072+
# Remove responders that should use socket activation
1073+
updated_services = [s for s in services_list if s not in responders]
1074+
1075+
# Update the services line
1076+
# - Empty string: all responders use socket activation
1077+
# - Non-empty: listed services run as traditional, others use socket activation
1078+
self.sssd.sssd["services"] = ", ".join(updated_services) if updated_services else ""
1079+
1080+
# Ensure socket units are started using SystemdServices for proper management
1081+
for responder in responders:
1082+
socket_unit = f"sssd-{responder}.socket"
1083+
self.sssd.svc.start(socket_unit)

0 commit comments

Comments
 (0)