bug fix?: 2.2.7a, nmbd/nmbd_packets.c, listen_for_packets()

Peter Hurley phurley at imaginexd.com
Sun Feb 16 16:11:56 GMT 2003


This is a follow-up to "WINS server incorrectly ignores 127.0.0.1
requests".

When running a WINS server using the following configuration:
	[global]
	wins support = yes
	interfaces = 192.168.1.0/24
	bind interfaces only = true
the WINS server erroneously discards 127.0.0.1 requests from SMBD
children.  This happens whenever libsmb/resolve_wins() is called.  I ran
into this trying to understand why bringing up a Print dialog would take
> 6 secs, but I would guess that there are other places this would come
up.

As a temporary solution, adding "127.0.0.0/8" to the "interfaces = "
configuration works, but has the side effect of starting SMBD on
127.0.0.1:139.

I would suggest two possible alterate fixes:
1) Change the 137 packet handler. In nmbd/nmbd_packets.c,
listen_for_packets(), lines# 1847~1860, reads:

if(lp_bind_interfaces_only() && (sock_array[i] == ClientNMB) &&
   (!is_local_net(packet->ip))) {
     DEBUG(7,("discarding nmb packet sent to broadcast socket from
%s:%d\n",
               inet_ntoa(packet->ip),packet->port));
     free_packet(packet);
} else if (ip_equal(loopback_ip, packet->ip) &&
           packet->port == global_nmb_port) {
     DEBUG(7,("discarding own packet from %s:%d\n",
               inet_ntoa(packet->ip),packet->port));
     free_packet(packet);
} else {
     /* Save the file descriptor this packet came in on. */
     packet->fd = sock_array[i];
     queue_packet(packet);
}

Replace with:

BOOL is_loopback = ip_equal(loopback_ip, packet->ip);
if (!is_loopback && lp_bind_interfaces_only() &&
     (sock_array[i] == ClientNMB) && (!is_local_net(packet->ip) )) {
     DEBUG(7,("discarding nmb packet sent to broadcast socket from
%s:%d\n",
               inet_ntoa(packet->ip),packet->port));
     free_packet(packet);
} else if (is_loopback && packet->port == global_nmb_port) {
     DEBUG(7,("discarding own packet from %s:%d\n",
               inet_ntoa(packet->ip),packet->port));
     free_packet(packet);
} else {
     /* Save the file descriptor this packet came in on. */
     packet->fd = sock_array[i];
     queue_packet(packet);
}

** OR **
2) return true from is_local_net if param ip is 127.0.0.1.  I have not
tried this because is_local_net() is used in two other places, both of
which are looking for DMB (one in smbd/password.c and one in
nsswitch/winbinddd_cm.c).  It's unclear to me what the side effects
would be here.

BTW, similar logic exists for the 138 handler in the same function. I'm
not sure whether that is cause for concern and if it should be fixed
like the 137 handler above.

Thanks,

Peter Hurley
phurley at imaginexd.com



More information about the samba-technical mailing list