Repository navigation
Description
Summary
With id_provider = ldap, SASL/GSSAPI LDAP binds and auth_provider = krb5, SSSD 2.13.1 can remain offline after an outage of both KDCs, even after a KDC returns and can issue tickets. The triggering DNS setup has identical host/port targets in the UDP and TCP Kerberos SRV records.
The duplicate-only SRV response path can return an unnamed SRV meta-server as the selected KDC. The next layer rejects it with Missing server name, and subsequent automatic online checks repeat the failure.
There is a minimal failover regression and a candidate fix below. Neither requires taking real infrastructure offline.
Version and environment
- SSSD 2.13.1, built from the official release tarball, which is still the latest stable release. Tarball SHA-256:
05ea79e89f0be399983925b8874ac196d6dc5fd4416f83609557b9fc8ef798b5. - Both
src/providers/fail_over.candsrc/tests/fail_over-tests.care byte-identical between that release and upstream master359c0716fe7f05b72aa8488e8d25441dd542c493. The executed tests below are on 2.13.1, not a complete master build. - Debian 13 (trixie), amd64, in disposable Docker containers under WSL2.
- MIT krb5 1.21.3 (
1.21.3-5+deb13u1), OpenLDAP 2.6.10 (2.6.10+dfsg-1), dnsmasq 2.91, LDB 2.11.0. - Real DNS, two standalone DB2 KDCs and one OpenLDAP server with StartTLS/GSSAPI, all on container loopback. Test containers use
--network none, no host mounts and no published ports. - Lab-specific differences: SSSD runs as container root (
--with-sssd-user=root --disable-linux-caps), DNS TTL is 30 seconds, and the runtime-outage/control cases cap host tickets at 60 seconds to exercise reauthentication without a day-long wait. The startup case uses a one-day ticket-lifetime ceiling. SSSD's normal offline retry settings are unchanged. - All names, identities, credentials and configuration used for the tests are synthetic.
Minimal regression: no KDC or LDAP server required
Save the two patches from the expandable sections below. In a configured SSSD 2.13.1 source/build tree:
patch --batch -p1 < sssd-srv-duplicate-test.patch
make fail_over-tests
./fail_over-testsThis adds one Check-framework test. Its SRV plugin returns the same localhost:88 target for UDP and TCP. After exhausting both address families for the UDP target, TCP discovery must return a named endpoint on port 88, not a port-zero placeholder. The test uses the normal localhost IPv4/IPv6 hosts entries and needs no external DNS.
Actual output on original code, exit status 1:
Running suite(s): fail_over
[sssd] [fo_resolve_service_send] (0x0020): No available servers for service 'http'
[sssd] [fo_resolve_service_send] (0x0020): No available servers for service 'ldap'
66%: Checks: 3, Failures: 1, Errors: 0
src/tests/fail_over-tests.c:175:F:FAIL_OVER Tests:test_fo_srv_duplicate_protocols:0: src/tests/fail_over-tests.c:370: Expected port 88, got 0
The http/ldap messages are from the pre-existing negative test cases. The new failure is the final port-zero assertion.
Then:
patch --batch -p1 < sssd-srv-duplicate-fix.patch
make fail_over-tests
./fail_over-testsWith the candidate fix, exit status 0, including both existing failover tests:
Running suite(s): fail_over
[sssd] [fo_resolve_service_send] (0x0020): No available servers for service 'http'
[sssd] [fo_resolve_service_send] (0x0020): No available servers for service 'ldap'
100%: Checks: 3, Failures: 0, Errors: 0
sssd-srv-duplicate-test.patch
diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c
--- a/src/tests/fail_over-tests.c
+++ b/src/tests/fail_over-tests.c
@@ -81,6 +81,7 @@
memset(&fopts, 0, sizeof(fopts));
fopts.retry_timeout = 30;
+ fopts.service_resolv_timeout = 5;
fopts.family_order = IPV4_FIRST;
ctx->fo_ctx = fo_context_init(ctx, &fopts);
@@ -289,6 +290,89 @@
}
END_TEST
+struct duplicate_srv_state {
+ struct fo_server_info *servers;
+};
+
+static struct tevent_req *
+duplicate_srv_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ const char *service,
+ const char *protocol,
+ const char *discovery_domain,
+ void *pvt)
+{
+ struct tevent_req *req;
+ struct duplicate_srv_state *state;
+
+ req = tevent_req_create(mem_ctx, &state, struct duplicate_srv_state);
+ sss_ck_fail_if_msg(req == NULL, "Could not allocate SRV request");
+
+ state->servers = talloc_zero_array(state, struct fo_server_info, 1);
+ sss_ck_fail_if_msg(state->servers == NULL, "Could not allocate SRV response");
+ state->servers[0].host = talloc_strdup(state->servers, "localhost");
+ sss_ck_fail_if_msg(state->servers[0].host == NULL, "Could not allocate SRV hostname");
+ state->servers[0].port = 88;
+
+ tevent_req_done(req);
+ return tevent_req_post(req, ev);
+}
+
+static errno_t
+duplicate_srv_recv(TALLOC_CTX *mem_ctx,
+ struct tevent_req *req,
+ char **dns_domain,
+ uint32_t *ttl,
+ struct fo_server_info **primary_servers,
+ size_t *num_primary_servers,
+ struct fo_server_info **backup_servers,
+ size_t *num_backup_servers)
+{
+ struct duplicate_srv_state *state;
+
+ state = tevent_req_data(req, struct duplicate_srv_state);
+ TEVENT_REQ_RETURN_ON_ERROR(req);
+
+ *dns_domain = talloc_strdup(mem_ctx, "test.invalid");
+ sss_ck_fail_if_msg(*dns_domain == NULL, "Could not allocate SRV domain");
+ *ttl = 3600;
+ *primary_servers = talloc_steal(mem_ctx, state->servers);
+ *num_primary_servers = 1;
+ *backup_servers = NULL;
+ *num_backup_servers = 0;
+ return EOK;
+}
+
+START_TEST(test_fo_srv_duplicate_protocols)
+{
+ struct test_ctx *ctx;
+ struct fo_service *service;
+ bool installed;
+ int ret;
+
+ ctx = setup_test();
+ ret = fo_new_service(ctx->fo_ctx, "KERBEROS", NULL, &service);
+ sss_ck_fail_if_msg(ret != EOK, "Could not create Kerberos service");
+
+ installed = fo_set_srv_lookup_plugin(ctx->fo_ctx, duplicate_srv_send,
+ duplicate_srv_recv, NULL);
+ sss_ck_fail_if_msg(!installed, "Could not install SRV lookup plugin");
+ ret = fo_add_srv_server(service, "kerberos", "test.invalid",
+ "test.invalid", "udp", NULL);
+ sss_ck_fail_if_msg(ret != EOK, "Could not add UDP SRV lookup");
+ ret = fo_add_srv_server(service, "kerberos", "test.invalid",
+ "test.invalid", "tcp", NULL);
+ sss_ck_fail_if_msg(ret != EOK, "Could not add TCP SRV lookup");
+
+ /* Exhaust both address families before TCP repeats the UDP target. */
+ get_request(ctx, service, EOK, 88, PORT_NOT_WORKING, -1);
+ get_request(ctx, service, EOK, 88, PORT_NOT_WORKING, -1);
+ get_request(ctx, service, EOK, 88, PORT_WORKING, SERVER_WORKING);
+
+ talloc_free(ctx);
+}
+END_TEST
+
Suite *
create_suite(void)
{
@@ -300,6 +384,7 @@
/* Do some testing */
tcase_add_test(tc, test_fo_new_service);
tcase_add_test(tc, test_fo_resolve_service);
+ tcase_add_test(tc, test_fo_srv_duplicate_protocols);
if (use_net_test) {
}
/* Add all test cases to the test suite */Real-service integration reproduction
These steps describe the isolated synthetic service test, not something to run against production KDCs.
- Start DNS and LDAP, with the synthetic configuration below, but leave both KDCs stopped.
- Start SSSD. A previously uncached identity lookup fails and the domain goes offline.
- After 10 seconds, start only
kdc1.sssd.test. Independently verify a keytabkinitagainst that KDC and a StartTLS/GSSAPI LDAP base-DN query, using a separate Kerberos configuration/cache from SSSD. - Create a new POSIX identity in LDAP after restoration, then poll
getent -s sss passwd after0002every five seconds for 240 seconds. Require the exact new name and UID, not just an existing cached user. Also observesssctl domain-status lab --online. - For the runtime case, begin with both KDCs independently verified healthy and an uncached identity lookup working. Stop both KDCs, wait for the 60-second host ticket to expire plus five seconds, and restart only the lab LDAP server to force a new authenticated connection. Require a fresh identity lookup to fail before restoring one KDC and repeating the independent control and new-identity probe.
- For the single-KDC control, instead stop only SSSD's selected active KDC (from the first endpoint in its locator file), leaving the other running. Again expire the ticket and reconnect LDAP, so an existing LDAP connection or ticket cannot hide the outage.
Expected and observed
Once the available KDC and LDAP can independently complete authentication, SSSD should eventually return online and resolve the newly created identity without a daemon restart or cache clearing.
| Scenario | Original 2.13.1 | Candidate fix |
|---|---|---|
| Both KDCs down at SSSD startup; restore one | Fresh identity still unavailable at 240 seconds after restoration; repeated Missing server name on automatic online checks |
Automatic recovery in 55-66 seconds in repeated runs |
| Both KDCs lost after healthy startup; expire ticket/reconnect LDAP; restore one | Still offline at 240 seconds after restoration | Automatic recovery in about 70 seconds in repeated runs |
| Stop only the active KDC; other remains available; expire ticket/reconnect LDAP | Fresh identity resolves; domain online | Same |
The 240-second failures are bounded observations, not a claim that the synthetic test ran indefinitely. No SSSD restart, cache clearing, explicit KDC list in SSSD, or reduced SSSD offline retry intervals were used to get the patched recoveries.
An example from an original-code online-check attempt after KDC restoration, with debug_level = 0x3ff0:
(2026-10-25 23:05:51): [be[LAB]] [resolve_srv_done] (0x0400): [RID#51] SRV lookup did not return any new server.
(2026-10-25 23:05:51): [be[LAB]] [be_resolve_server_process] (0x0020): [RID#51] Missing server name.
(2026-10-25 23:05:51): [be[LAB]] [be_check_online_done] (0x0400): [RID#51] Backend is offline
The more general name-less server / Server without name and address found in list look-ahead warnings also appear in healthy controls and with the fix. They are not the selected-placeholder failure above.
Synthetic topology and complete sssd.conf / krb5.conf used in the lab
DNS: 127.0.0.1:53
kdc1.sssd.test: 127.0.0.2:88, UDP and TCP
kdc2.sssd.test: 127.0.0.3:88, UDP and TCP
ldap.sssd.test: 127.0.0.4:389, StartTLS and SASL/GSSAPI
client.sssd.test: 127.0.0.5
Realm: SSSD.TEST
LDAP base: dc=sssd,dc=test
Both protocols deliberately have the same host/port pairs:
_kerberos._udp.sssd.test. 30 IN SRV 0 100 88 kdc1.sssd.test.
_kerberos._udp.sssd.test. 30 IN SRV 0 100 88 kdc2.sssd.test.
_kerberos._tcp.sssd.test. 30 IN SRV 0 100 88 kdc1.sssd.test.
_kerberos._tcp.sssd.test. 30 IN SRV 0 100 88 kdc2.sssd.test.
/etc/sssd/sssd.conf:
[sssd]
config_file_version = 2
services = nss, pam, ifp
domains = LAB
debug_level = 0x3ff0
[nss]
debug_level = 0x3ff0
[pam]
debug_level = 0x3ff0
[ifp]
allowed_uids = 0
debug_level = 0x3ff0
[domain/LAB]
debug_level = 0x3ff0
id_provider = ldap
ldap_uri = ldap://ldap.sssd.test
ldap_id_use_start_tls = true
ldap_sasl_mech = GSSAPI
ldap_sasl_authid = host/client.sssd.test
ldap_tls_cacert = /lab/run/ldap.crt
ldap_tls_reqcert = allow
auth_provider = krb5
cache_credentials = true
chpass_provider = krb5
krb5_realm = SSSD.TEST/etc/krb5.conf:
[libdefaults]
default_realm = SSSD.TEST
dns_lookup_kdc = true
dns_lookup_realm = false
rdns = false
[domain_realm]
.sssd.test = SSSD.TEST
sssd.test = SSSD.TESTThe host keytab and LDAP service keytab are generated fresh inside the disposable container. Their principals are host/client.sssd.test@SSSD.TEST and ldap/ldap.sssd.test@SSSD.TEST. No key material is needed for the minimal failover regression above.
Suspected cause and candidate fix
The relevant branch is in resolve_srv_done().
- UDP discovery inserts the real KDC endpoints. The TCP query can then return only endpoints that are already present.
fo_add_server_list()adds no server, leavinglast_server == state->meta.resolve_srv_done()returnsERR_SRV_DUPLICATESand selectsservice->last_tried_serverif non-NULL.- That pointer can be the unnamed TCP SRV placeholder itself.
fo_resolve_service_cont()intentionally proceeds onERR_SRV_DUPLICATES;get_server_status()treats an object withoutcommonas name-resolved, so the placeholder can emerge as a successful resolution. be_resolve_server_process()rejects the selected server because it has no name. Subsequent online checks can repeat the same selection.
The candidate patch below keeps the duplicate-response behaviour but uses last_tried_server only when named, otherwise scans for an existing named endpoint, and reports an explicit error if none exists. It also corrects the assumption in the old comment that duplicates only occur during concurrent lookups.
The older concurrent-request handling from SSSD/sssd#4164 / 03cb5ac6 is already present in the tested version. This reproducer reaches the duplicate path through overlapping protocol answers.
I'd appreciate review of the existing-endpoint selection policy as well as the regression. The patch fixes the isolated cases above; I am not claiming it is already reviewed or production-ready.
sssd-srv-duplicate-fix.patch
diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c
--- a/src/providers/fail_over.c
+++ b/src/providers/fail_over.c
@@ -1561,23 +1561,31 @@
}
if (last_server == state->meta) {
- /* SRV lookup returned only those servers that are already present.
- * This may happen only when an ongoing SRV resolution already
- * exist. We will return server, but won't set any state. */
+ /* SRV lookup returned only servers that are already present,
+ * either from another request or from another protocol's SRV
+ * records. Return an existing server without changing its state. */
DEBUG(SSSDBG_TRACE_FUNC, "SRV lookup did not return "
"any new server.\n");
ret = ERR_SRV_DUPLICATES;
- /* Since no new server is returned, state->meta->next is NULL.
- * We return last tried server if possible which is server
- * from previous resolution of SRV record, and first server
- * otherwise. */
- if (state->service->last_tried_server != NULL) {
+ /* The last tried server may be the meta-server of another
+ * protocol whose SRV records contain the same targets. Only
+ * return a named server, not an unresolved SRV placeholder. */
+ if (state->service->last_tried_server != NULL &&
+ fo_get_server_name(state->service->last_tried_server) != NULL) {
state->out = state->service->last_tried_server;
goto done;
}
- state->out = state->service->server_list;
+ DLIST_FOR_EACH(state->out, state->service->server_list) {
+ if (fo_get_server_name(state->out) != NULL) {
+ goto done;
+ }
+ }
+
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ "No named server found after duplicate SRV lookup.\n");
+ ret = EIO;
goto done;
}
Activity
pbrezina commentedon Nov 4, 2026
Hi, I would like to see logs from reproducing this issue. Would that be possible?
lightspd10 commentedon Nov 4, 2026
@pbrezina Yes. I reran the unmodified 2.13.1
startup-both-downcase on 2026-11-04 and captured the complete synthetic logs here:https://gist.github.com/lightspd10/9a52f322a247d7f33782f11a87478246
The bundle includes the full unfiltered
/var/log/sssd/*files, the actual syntheticsssd.confandkrb5.conf, the run timeline, and SHA-256 sums. SSSD debug level is0x3ff0;sssd_LAB.logis the main file.KDC 1 was restored at elapsed 11.12 seconds, and the independent keytab/GSSAPI LDAP control passed at 11.14 seconds. SSSD nevertheless remained offline and failed to resolve the newly created identity for the full 240-second observation.
Around line 1093 of
sssd_LAB.log, the later SRV lookup sees both endpoints as duplicates and then takes the failure path:The candidate patch was not applied for this log run. All names, credentials, services and data in the bundle are synthetic; production logs and key material were not copied.