[PATCH] make nsswitch and libwbclient thread safe

Ralph Wuerthner ralphw at de.ibm.com
Fri Oct 5 10:11:44 UTC 2018


On 04.10.2018 21:04, Volker Lendecke wrote:
> On Thu, Oct 04, 2018 at 04:36:25PM +0200, Ralph Wuerthner via samba-technical wrote:
>> Please see attached patchset to make nsswitch & libwbclient thread safe.
>>
>> Currently nsswitch & libwbclient share a common, global context when
>> communicating to winbindd. Threaded applications submitting requests in
>> parallel via nsswitch & libwbclient to winbindd can fail because of the
>> simplistic design of the communication protocol.
>>
>> With the patch applied, access to the global libwbclient context is
>> serialized by a mutex, similar to the mutex used in winbind_nss_linux.c.
> 
> Looks good to me. One question: Do you have a test to excercise the
> failure and the succeeding behaviour?
> 
> Thanks,
> 
> Volker

Hi Volker,

please see attached test to exercise NSS & libwbclient. Compile via

gcc -o stress-nss-libwbclient stress-nss-libwbclient.c 
-I/usr/include/samba-4.0 -lpthread -lwbclient

and run with 'stress-nss-libwbclient <domain user>'.

On my test system without the fix I get

./stress-nss-libwbclient 'virtual1\administrator'
query domain user 'virtual1\administrator'
getpwnam_r failed with rc=Success result=(nil)
wbcGetpwnam failed with WBC_ERR_WINBIND_NOT_AVAILABLE
test failed

and winbindd reports the following errors:

[2018/10/05 12:00:52.487482,  0] 
../source3/winbindd/winbindd.c:968(winbind_client_activity)
   winbind_client_activity[14976:GETPWNAM]:unexpected data from client - 
removing client
[2018/10/05 12:00:52.487662,  1] 
../source3/winbindd/winbindd_dual.c:337(wb_child_request_cleanup)
   wb_child_request_cleanup: keep orphaned subreq[0x7fb83040f980]
[2018/10/05 12:00:52.489158,  1] 
../source3/winbindd/winbindd_dual.c:281(wb_child_request_orphaned)
   wb_child_request_orphaned: cleanup orphaned subreq[0x7fb83040f980]

With the fix applied I get

./stress-nss-libwbclient 'virtual1\administrator'
query domain user 'virtual1\administrator'
test passed - with a total of 8375 NSS and winbind queries


Regards

    Ralph Wuerthner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stress-nss-libwbclient.c
Type: text/x-csrc
Size: 1986 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20181005/ffeb4007/stress-nss-libwbclient.c>


More information about the samba-technical mailing list