Bug 16275 - samba3.rpc.wkssvc(ad_member) intermittently fails with WERR_ACCESS_DENIED
Summary: samba3.rpc.wkssvc(ad_member) intermittently fails with WERR_ACCESS_DENIED
Status: ASSIGNED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: File services (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Andreas Schneider
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-10-09 11:52 UTC by Andreas Schneider
Modified: 2026-10-19 18:48 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schneider 2026-10-09 11:52:00 UTC
[1074(43018)/3239 at 1h6m4s, 1 errors] samba3.rpc.wkssvc(ad_member)
Testing NetWkstaEnumUsers level 0
UNEXPECTED(failure): samba3.rpc.wkssvc.wkssvc.NetWkstaEnumUsers(ad_member)
REASON: Exception: Exception: ../../source4/torture/rpc/wkssvc.c:206: r.out.result was WERR_ACCESS_DENIED, expected WERR_OK: NetWkstaEnumUsers failed


The `Administrator` session's security token on the `ad_member` test
environment is missing `BUILTIN\Administrators` (`S-1-5-32-544`), even though
it correctly contains `Domain Admins`. `_wkssvc_NetWkstaEnumUsers()` (and
`NetWkstaGetInfo` level 102) require `BUILTIN\Administrators` in the caller's
token or they fail with `WERR_ACCESS_DENIED`. Every other RPC call in the
test either doesn't check for that SID or is already in `knownfail.d`, so
only these two calls are visibly affected.

The missing membership is **not** caused by concurrency, and not caused by
talking to the wrong DC.

## Root cause

- `ad_member` loses a startup race between its first token-building
  sessions (including its own provisioning `net join`) and `winbindd`
  becoming ready, causing `create_builtin_administrators()` to abort with
  `NT_STATUS_PROTOCOL_UNREACHABLE` before ever adding `Domain Admins` as a
  member of `BUILTIN\Administrators`.
- The selftest harness has a known workaround for this exact race, but only
  applies it to `BUILTIN\Users`, not `BUILTIN\Administrators` or
  `BUILTIN\Guests`.
- `finalize_local_nt_token()` (`source3/auth/token_util.c:744-746`) assumes
  that a resolvable `BUILTIN\Administrators` SID implies populated
  membership, and never re-checks this. Once the alias starts resolving for
  any reason (proven: without real membership, via some other
  winbindd/idmap-reachability side effect), the code permanently stops
  trying to populate `Domain Admins` membership for the rest of that
  environment's lifetime.
- As a result, `Administrator`'s token on `ad_member` never contains
  `BUILTIN\Administrators`, and any RPC call that specifically requires it —
  in this test suite, `_wkssvc_NetWkstaEnumUsers()` and `NetWkstaGetInfo`
  level 102 — fails with `WERR_ACCESS_DENIED`. This is deterministic once the
  race is lost for a given environment instance, but whether the race is
  lost at all depends on machine timing, hence the intermittent failures in
  full `%check` runs and non-reproduction in narrow, low-contention runs.
Comment 1 Samba QA Contact 2026-10-19 18:48:04 UTC
This bug was referenced in samba master:

705217ffb64ce70a398e0938d6699e9ce735ea55
dbb8e042f567c2a5c9d2c02d87df7fd120935437
da972dab0e002660d71902419f5237a24b8e090e
de2f60fe540112c7f43c4219bf81dd5394ec6771
76368b5d2e16b29ac78bf547fd543d6866e28995