Skip to content

sysdb: preserve memberships when renaming verified groups - #9050

Open
karlg100 wants to merge 4 commits into
SSSD:masterfrom
karlg100:kag/issue-9049-same-gid-rename
Open

sysdb: preserve memberships when renaming verified groups#9050
karlg100 wants to merge 4 commits into
SSSD:masterfrom
karlg100:kag/issue-9049-same-gid-rename

Conversation

@karlg100

@karlg100 karlg100 commented Aug 7, 2026

Copy link
Copy Markdown

Problem

When a group arrives under a new name with a GID already present in the
cache, SSSD deletes and recreates the existing group.

If both entries represent the same directory identity, replacement is
unnecessary. Deleting the cached group also causes the memberOf plugin to
synchronously rebuild membership references across the cached graph. With
large or deeply nested membership data, this work can exceed the backend
watchdog deadline and block user logins.

A raw LDB rename is not sufficient because existing member and memberOf
values continue to reference the old DN.

Solution

  • Teach the memberOf plugin to update member and memberOf references when
    an entry is renamed.
  • Bound rename search-result growth and guard against allocation-size
    overflow.
  • When an incoming same-GID group has the same stable identity as the cached
    group, rename the existing entry instead of deleting and recreating it.
  • Verify identity using SID or UUID, falling back to originalDN.
  • Remove the obsolete timestamp-cache key and store the incoming attributes
    under the renamed entry.
  • Add regression coverage for direct membership, nested membership, reverse
    membership, and initgroups results.

Scope

This fixes the verified same-GID delete/re-add trigger described in #9049.

It does not include the broader transactional memberOf graph derivation or
the NSS mmap cache-warming optimization. Those changes will be proposed
separately.

Validation

  • git diff --check passes.
  • The equivalent implementation has been exercised in the RHEL 9 and RHEL 10
    investigation branches.
  • Build and focused sysdb testing of the exact master-rebased series will be
    completed before the PR is marked ready for review.

Refs #9049

A raw LDB rename changes the entry DN but leaves member and memberOf values that refer to the old DN. That disconnects otherwise valid direct and transitive membership edges.

Add a rename handler that finds references to the old DN, forwards the rename, then replaces only the affected member and memberOf values while preserving controls and response data.

Dependency: none. This is independently useful and is required before the same-GID sysdb rename change.

Related: SSSD#9049
The rename reference search accumulates an unbounded number of matching entries. Keep its counters in size_t and reject growth at SIZE_MAX before computing num_entries + 1 for talloc_realloc().

This prevents integer wrap from turning a large result count into an undersized allocation followed by an out-of-bounds write.

Dependency: memberof rename support from the preceding patch.
When a group arrives under a new name with a GID already present in the cache, deleting and recreating the old entry discards membership state and forces expensive reconstruction.

Treat the entry as a rename only when stable identity attributes agree. Prefer SID or UUID, fall back to originalDN, rename the cached DN, remove the stale timestamp-cache key, and then store the incoming attributes.

After ldb_rename(), explicitly replace the stored name. Searches in the open transaction can already expose the new RDN and otherwise make the generic no-op comparison suppress this required write.

Dependency: memberof rename support, because all member and memberOf references must follow the renamed DN.

Related: SSSD#9049
Exercise a same-identity, same-GID group rename while the group is both a child and a parent in a nested graph.

Query member and memberOf explicitly, then verify the old name disappears, direct and inherited references use the new DN, and initgroups returns the renamed group without stale membership.

Dependencies: memberof rename support and the verified same-GID sysdb rename patches.
@karlg100
karlg100 force-pushed the kag/issue-9049-same-gid-rename branch from 05bc64a to cff8a4a Compare August 7, 2026 16:51
@karlg100
karlg100 marked this pull request as ready for review August 7, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant