libsmbclient: Vista servers disconnect on netbios keepalive message
on port 445
elupus
elupus at xboxmediacenter.com
Sun Dec 24 01:47:46 GMT 2006
If libsmbclient is connected to a vista server on port 445, only every
second command will work. Before every command libsmbclient tries to verify
that the server is valid by sending it a SMBkeepalive. However this is a
netbios packet and can't be used on port 445 (smb over tcp). It seems
previous windows version ignored this, vista however disconnects the client
on such an invalid request.
I changed the smbc_check_server to only do the keepalive when connected on
port 139, sorry for this not being a patch, but I currently don't have any
checked out version of samba. The alternative is to use cli_echo, but
waiting for a roundtrip before trying to do anything seems overkill.
The proper solution would be to do a retry on a failed request instead of
the current way if checking connection prior to doing the actual request.
But that is abit to much work for me.
Cheers
/Joakim
static int
smbc_check_server(SMBCCTX * context,
SMBCSRV * server)
{
if (server->cli.port == 139)
{
if ( send_keepalive(server->cli.fd) == False )
return 1;
}
else
{
/* can't send netbios keepalive over raw tcp samba sockets
*/
struct sockaddr addr;
int size = sizeof(addr);
if (getpeername(server->cli.fd, &addr, &size))
return 1;
}
/* connection is ok */
return 0;
}
More information about the samba-technical
mailing list