Page MenuHomeFreeBSD

NS_RETURN incorrectly excluded from terminal states with custom status return rules
Needs ReviewPublic

Authored by david_crossfamilyweb.com on Oct 23 2024, 3:22 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 24, 12:04 AM
Unknown Object (File)
Sun, May 17, 1:28 PM
Unknown Object (File)
Sat, May 16, 4:05 PM
Unknown Object (File)
Sat, May 16, 4:05 PM
Unknown Object (File)
Wed, May 13, 6:21 PM
Unknown Object (File)
Tue, May 12, 9:44 AM
Unknown Object (File)
Apr 21 2026, 11:14 AM
Unknown Object (File)
Apr 15 2026, 11:38 AM
Subscribers

Details

Reviewers
markj
Summary

If you use the standard rules in nsswitch.conf then "NS_SUCCESS | NS_RETURN" are mapped to terminal states and everything else continues to the net source (notfound, unavailable, tryagain).

If you specify a custom status code handler, like [notfound = return] then the default flags are ONLY NS_SUCCESS. This means nsdispatch(3) routines returning NS_RETURN (for example for ERANGE to get more memory), instead fallback to the next source. This is incorrect behavior. for 3 reasons.

  1. NS_RETURN is explicit, it is to return, not fall back.
  2. there is no way to restore this behavior, 'return' is not a documented status code in nsswitch.conf or as far as I can see the parser to restore this behavior
  3. NS_RETURN's intent is to signal that there is SOMETHING there, but you may need to take additional action; by having the system fall through this completely hides this behavior from clients.

This fix sets the default for ALL to be NS_SUCCESS and NS_RETURN. I think there MAY be another bug where you cannot set NS_SUCCESS to continue (for last match semantics). but I will investigate that at a later time.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped