FW: Winbindd timeout on unreacheable domains

Lin Li linl at xandros.com
Thu Feb 19 21:47:40 GMT 2004


Andrew Bartlett wrote:

>On Fri, 2004-02-20 at 02:01, Lin Li wrote:
>  
>
>>Lin Li wrote:
>>
>>    
>>
>>>In fact I have logged a bug (#704) for this. It's doing 
>>>ads_try_connect(). My solution is to use ldap_init() instead of 
>>>ldap_open() and set a small timeout using ldap_set_option(). Here is 
>>>my patch (I'm using 3.0.0) and it works in my test.
>>>-------------------------------------
>>>+       struct timeval timeout;
>>>
>>>       if (!server || !*server) {
>>>               return False;
>>>@@ -58,11 +59,15 @@
>>>       /* this copes with inet_ntoa brokenness */
>>>       srv = strdup(server);
>>>
>>>-       ads->ld = ldap_open(srv, port);
>>>+       ads->ld = ldap_init(srv, port);
>>>       if (!ads->ld) {
>>>               free(srv);
>>>               return False;
>>>       }
>>>+
>>>+       timeout.tv_sec = 15;
>>>+       timeout.tv_usec = 0;
>>>+       ldap_set_option(ads->ld, LDAP_OPT_NETWORK_TIMEOUT, &timeout);
>>>       ads->ldap_port = port;
>>>       ads->ldap_ip = *interpret_addr2(srv);
>>>       free(srv);
>>>-------------------------------------
>>>
>>>Thanks,
>>>Lin
>>>
>>>      
>>>
>>Sorry, the patch is for source/libads/ldap.c
>>    
>>
>
>Unfortunetly, there is a problem with that patch.
>
>The issue is that making the connect() to the remote LDAP server is put
>off until the first LDAP operation.  The current code paths assume that
>if ldap_open() suceeds, then at least the remote sever is there...
>
>So, we need to at least 'ping' the remote server in some way, before we
>can say 'we connected'.  I would suggest this means calling
>ads_server_info() inside ads_try_connect() and ads_try_connect_uri(). 
>These functions should also return ADS_STATUS, and be correctly modified
>to return something useful (that ads_find_dc() can use) when the remote
>server just isn't there.
>
>Andrew Bartlett
>
>  
>
Yes, I know there is some problem since ldap_init() does not open a 
connection. I am not very familiar with the code so I just made some 
simple change and it works in my test environment. Maybe you can find a 
better solution and make it in the next release.

Thanks,
Lin

-- 
Xandros Corporation
Simple. Powerful. Linux.
Visit us at http://www.xandros.com




More information about the samba-technical mailing list