[PATCH] make nsswitch and libwbclient thread safe
Jeremy Allison
jra at samba.org
Mon Oct 29 16:20:57 UTC 2018
On Fri, Oct 05, 2018 at 12:11:44PM +0200, Ralph Wuerthner via samba-technical wrote:
> 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
Ping for Ralph and Volker.
I'd love to get this into master if you both are
happy with it !
Jeremy.
More information about the samba-technical
mailing list