summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h10
-rw-r--r--source3/libsmb/clidgram.c83
-rw-r--r--source3/libsmb/clidgram.h14
-rw-r--r--source3/libsmb/namequery.c26
-rw-r--r--source3/libsmb/nmblib.c40
-rw-r--r--source3/libsmb/unexpected.c314
-rw-r--r--source3/nmbd/nmbd.c10
-rw-r--r--source3/nmbd/nmbd_packets.c10
-rw-r--r--source3/winbindd/winbindd_wins.c44
9 files changed, 2 insertions, 549 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a67f2b4690..0775acd21d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2792,9 +2792,6 @@ bool nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
int build_packet(char *buf, size_t buflen, struct packet_struct *p);
bool send_packet(struct packet_struct *p);
struct packet_struct *receive_packet(int fd,enum packet_type type,int t);
-struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id);
-struct packet_struct *receive_dgram_packet(int fd, int t,
- const char *mailslot_name);
bool match_mailslot_name(struct packet_struct *p, const char *mailslot_name);
int matching_len_bits(unsigned char *p1, unsigned char *p2, size_t len);
void sort_query_replies(char *data, int n, struct in_addr ip);
@@ -2936,13 +2933,6 @@ NTSTATUS change_trust_account_password( const char *domain, const char *remote_m
/* The following definitions come from libsmb/unexpected.c */
-bool is_requested_send_packet(struct packet_struct *p);
-bool store_outstanding_send_packet(struct packet_struct *p);
-void unexpected_packet(struct packet_struct *p);
-void clear_unexpected(time_t t);
-struct packet_struct *receive_unexpected(enum packet_type packet_type, int id,
- const char *mailslot_name);
-
struct nb_packet_server;
struct nb_packet_reader;
diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c
index 57fbd71da5..d46aadc802 100644
--- a/source3/libsmb/clidgram.c
+++ b/source3/libsmb/clidgram.c
@@ -174,48 +174,6 @@ fail:
return ret;
}
-bool send_getdc_request(struct messaging_context *msg_ctx,
- const struct sockaddr_storage *dc_ss,
- const char *domain_name,
- const struct dom_sid *sid,
- uint32_t nt_version,
- int dgm_id)
-{
- struct packet_struct p;
- pid_t nmbd_pid;
- char *my_mailslot;
- struct in_addr dc_ip;
- NTSTATUS status;
-
- if ((nmbd_pid = pidfile_pid("nmbd")) == 0) {
- DEBUG(3, ("No nmbd found\n"));
- return False;
- }
-
- if (dc_ss->ss_family != AF_INET) {
- return false;
- }
- dc_ip = ((struct sockaddr_in *)dc_ss)->sin_addr;
-
- my_mailslot = mailslot_name(talloc_tos(), dc_ip);
- if (my_mailslot == NULL) {
- return NULL;
- }
-
- if (!prep_getdc_request(dc_ss, domain_name, sid, nt_version,
- my_mailslot, dgm_id, &p)) {
- TALLOC_FREE(my_mailslot);
- return false;
- }
-
- status = messaging_send_buf(msg_ctx, pid_to_procid(nmbd_pid),
- MSG_SEND_PACKET,
- (uint8 *)&p, sizeof(p));
- TALLOC_FREE(my_mailslot);
-
- return NT_STATUS_IS_OK(status);
-}
-
static bool parse_getdc_response(
struct packet_struct *packet,
TALLOC_CTX *mem_ctx,
@@ -313,47 +271,6 @@ static bool parse_getdc_response(
return True;
}
-bool receive_getdc_response(TALLOC_CTX *mem_ctx,
- const struct sockaddr_storage *dc_ss,
- const char *domain_name,
- int dgm_id,
- uint32_t *nt_version,
- const char **dc_name,
- struct netlogon_samlogon_response **samlogon_response)
-{
- struct packet_struct *packet = NULL;
- char *my_mailslot = NULL;
- struct in_addr dc_ip;
- bool ret;
-
-
- if (dc_ss->ss_family != AF_INET) {
- return false;
- }
-
- dc_ip = ((struct sockaddr_in *)dc_ss)->sin_addr;
-
- my_mailslot = mailslot_name(mem_ctx, dc_ip);
- if (!my_mailslot) {
- return false;
- }
-
- packet = receive_unexpected(DGRAM_PACKET, dgm_id, my_mailslot);
-
- if (packet == NULL) {
- DEBUG(5, ("Did not receive packet for %s\n", my_mailslot));
- return False;
- }
-
- DEBUG(5, ("Received packet for %s\n", my_mailslot));
-
- ret = parse_getdc_response(packet, mem_ctx, domain_name, nt_version,
- dc_name, samlogon_response);
-
- free_packet(packet);
- return ret;
-}
-
struct nbt_getdc_state {
struct tevent_context *ev;
struct messaging_context *msg_ctx;
diff --git a/source3/libsmb/clidgram.h b/source3/libsmb/clidgram.h
index 3ddf9d6b1a..640a590248 100644
--- a/source3/libsmb/clidgram.h
+++ b/source3/libsmb/clidgram.h
@@ -2,20 +2,6 @@
/* The following definitions come from libsmb/clidgram.c */
-bool send_getdc_request(struct messaging_context *msg_ctx,
- const struct sockaddr_storage *dc_ss,
- const char *domain_name,
- const struct dom_sid *sid,
- uint32_t nt_version,
- int dgm_id);
-bool receive_getdc_response(TALLOC_CTX *mem_ctx,
- const struct sockaddr_storage *dc_ss,
- const char *domain_name,
- int dgm_id,
- uint32_t *nt_version,
- const char **dc_name,
- struct netlogon_samlogon_response **reply);
-
struct tevent_req *nbt_getdc_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct messaging_context *msg_ctx,
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index ab98a12146..e7dd22ad10 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -658,32 +658,6 @@ static NTSTATUS nb_trans_recv(struct tevent_req *req,
}
/****************************************************************************
- Try and send a request to nmbd to send a packet_struct packet first.
- If this fails, use send_packet().
-**************************************************************************/
-
-static bool send_packet_request(struct packet_struct *p)
-{
- struct messaging_context *msg_ctx = server_messaging_context();
- if (msg_ctx) {
- pid_t nmbd_pid = pidfile_pid("nmbd");
-
- if (nmbd_pid) {
- /* Try nmbd. */
- if (NT_STATUS_IS_OK(messaging_send_buf(msg_ctx,
- pid_to_procid(nmbd_pid),
- MSG_SEND_PACKET,
- (uint8_t *)p,
- sizeof(struct packet_struct)))) {
- return true;
- }
- }
- }
-
- return send_packet(p);
-}
-
-/****************************************************************************
Do a NBT node status query on an open socket and return an array of
structures holding the returned names or NULL if the query failed.
**************************************************************************/
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index fd011ebf27..ae7ad996b3 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -1133,51 +1133,11 @@ struct packet_struct *receive_packet(int fd,enum packet_type type,int t)
}
/****************************************************************************
- Receive a UDP/137 packet either via UDP or from the unexpected packet
- queue. The packet must be a reply packet and have the specified trn_id.
- The timeout is in milliseconds.
-***************************************************************************/
-
-struct packet_struct *receive_nmb_packet(int fd, int t, int trn_id)
-{
- struct packet_struct *p;
-
- p = receive_packet(fd, NMB_PACKET, t);
-
- if (p && p->packet.nmb.header.response &&
- p->packet.nmb.header.name_trn_id == trn_id) {
- return p;
- }
- if (p)
- free_packet(p);
-
- /* try the unexpected packet queue */
- return receive_unexpected(NMB_PACKET, trn_id, NULL);
-}
-
-/****************************************************************************
Receive a UDP/138 packet either via UDP or from the unexpected packet
queue. The packet must be a reply packet and have the specified mailslot name
The timeout is in milliseconds.
***************************************************************************/
-struct packet_struct *receive_dgram_packet(int fd, int t,
- const char *mailslot_name)
-{
- struct packet_struct *p;
-
- p = receive_packet(fd, DGRAM_PACKET, t);
-
- if (p && match_mailslot_name(p, mailslot_name)) {
- return p;
- }
- if (p)
- free_packet(p);
-
- /* try the unexpected packet queue */
- return receive_unexpected(DGRAM_PACKET, 0, mailslot_name);
-}
-
/****************************************************************************
See if a datagram has the right mailslot name.
***************************************************************************/
diff --git a/source3/libsmb/unexpected.c b/source3/libsmb/unexpected.c
index 4543ffe7c6..c05af9ba8a 100644
--- a/source3/libsmb/unexpected.c
+++ b/source3/libsmb/unexpected.c
@@ -21,320 +21,6 @@
#include "includes.h"
#include "lib/async_req/async_sock.h"
-static struct tdb_wrap *tdbd = NULL;
-
-/* the key type used in the unexpected packet database */
-struct unexpected_key {
- enum packet_type packet_type;
- time_t timestamp;
- int count;
-};
-
-struct pending_unexpected {
- struct pending_unexpected *prev, *next;
- enum packet_type packet_type;
- int id;
- time_t timeout;
-};
-
-static struct pending_unexpected *pu_list;
-
-/****************************************************************************
- This function is called when nmbd has received an unexpected packet.
- It checks against the list of outstanding packet transaction id's
- to see if it should be stored in the unexpected.tdb.
-**************************************************************************/
-
-static struct pending_unexpected *find_unexpected_packet(struct packet_struct *p)
-{
- struct pending_unexpected *pu;
-
- if (!p) {
- return NULL;
- }
-
- for (pu = pu_list; pu; pu = pu->next) {
- if (pu->packet_type == p->packet_type) {
- int id = (p->packet_type == DGRAM_PACKET) ?
- p->packet.dgram.header.dgm_id :
- p->packet.nmb.header.name_trn_id;
- if (id == pu->id) {
- DEBUG(10,("find_unexpected_packet: found packet "
- "with id = %d\n", pu->id ));
- return pu;
- }
- }
- }
-
- return NULL;
-}
-
-
-/****************************************************************************
- This function is called when nmbd has been given a packet to send out.
- It stores a list of outstanding packet transaction id's and the timeout
- when they should be removed.
-**************************************************************************/
-
-bool store_outstanding_send_packet(struct packet_struct *p)
-{
- struct pending_unexpected *pu = NULL;
-
- if (!p) {
- return false;
- }
-
- pu = find_unexpected_packet(p);
- if (pu) {
- /* This is a resend, and we haven't received a
- reply yet ! Ignore it. */
- return false;
- }
-
- pu = SMB_MALLOC_P(struct pending_unexpected);
- if (!pu || !p) {
- return false;
- }
-
- ZERO_STRUCTP(pu);
- pu->packet_type = p->packet_type;
- pu->id = (p->packet_type == DGRAM_PACKET) ?
- p->packet.dgram.header.dgm_id :
- p->packet.nmb.header.name_trn_id;
- pu->timeout = time(NULL) + 15;
-
- DLIST_ADD_END(pu_list, pu, struct pending_unexpected *);
-
- DEBUG(10,("store_outstanding_unexpected_packet: storing packet "
- "with id = %d\n", pu->id ));
-
- return true;
-}
-
-/****************************************************************************
- Return true if this is a reply to a packet we were requested to send.
-**************************************************************************/
-
-bool is_requested_send_packet(struct packet_struct *p)
-{
- return (find_unexpected_packet(p) != NULL);
-}
-
-/****************************************************************************
- This function is called when nmbd has received an unexpected packet.
- It checks against the list of outstanding packet transaction id's
- to see if it should be stored in the unexpected.tdb. Don't store if
- not found.
-**************************************************************************/
-
-static bool should_store_unexpected_packet(struct packet_struct *p)
-{
- struct pending_unexpected *pu = find_unexpected_packet(p);
-
- if (!pu) {
- return false;
- }
-
- /* Remove the outstanding entry. */
- DLIST_REMOVE(pu_list, pu);
- SAFE_FREE(pu);
- return true;
-}
-
-/****************************************************************************
- All unexpected packets are passed in here, to be stored in a unexpected
- packet database. This allows nmblookup and other tools to receive packets
- erroneously sent to the wrong port by broken MS systems.
-**************************************************************************/
-
-void unexpected_packet(struct packet_struct *p)
-{
- static int count;
- TDB_DATA kbuf, dbuf;
- struct unexpected_key key;
- char buf[1024];
- int len=0;
- uint32_t enc_ip;
-
- if (!should_store_unexpected_packet(p)) {
- DEBUG(10,("Not storing unexpected packet\n"));
- return;
- }
-
- DEBUG(10,("unexpected_packet: storing packet\n"));
-
- if (!tdbd) {
- tdbd = tdb_wrap_open(NULL, lock_path("unexpected.tdb"), 0,
- TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_INCOMPATIBLE_HASH,
- O_RDWR | O_CREAT, 0644);
- if (!tdbd) {
- DEBUG(0,("Failed to open unexpected.tdb\n"));
- return;
- }
- }
-
- memset(buf,'\0',sizeof(buf));
-
- /* Encode the ip addr and port. */
- enc_ip = ntohl(p->ip.s_addr);
- SIVAL(buf,0,enc_ip);
- SSVAL(buf,4,p->port);
-
- len = build_packet(&buf[6], sizeof(buf)-6, p) + 6;
-
- ZERO_STRUCT(key); /* needed for potential alignment */
-
- key.packet_type = p->packet_type;
- key.timestamp = p->timestamp;
- key.count = count++;
-
- kbuf.dptr = (uint8_t *)&key;
- kbuf.dsize = sizeof(key);
- dbuf.dptr = (uint8_t *)buf;
- dbuf.dsize = len;
-
- tdb_store(tdbd->tdb, kbuf, dbuf, TDB_REPLACE);
-}
-
-
-static time_t lastt;
-
-/****************************************************************************
- Delete the record if it is too old.
-**************************************************************************/
-
-static int traverse_fn(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
-{
- struct unexpected_key key;
-
- if (kbuf.dsize != sizeof(key)) {
- tdb_delete(ttdb, kbuf);
- }
-
- memcpy(&key, kbuf.dptr, sizeof(key));
-
- if (lastt - key.timestamp > NMBD_UNEXPECTED_TIMEOUT) {
- tdb_delete(ttdb, kbuf);
- }
-
- return 0;
-}
-
-
-/****************************************************************************
- Delete all old unexpected packets.
-**************************************************************************/
-
-void clear_unexpected(time_t t)
-{
- struct pending_unexpected *pu, *pu_next;
-
- for (pu = pu_list; pu; pu = pu_next) {
- pu_next = pu->next;
- if (pu->timeout < t) {
- DLIST_REMOVE(pu_list, pu);
- SAFE_FREE(pu);
- }
- }
-
- if (!tdbd) return;
-
- if ((lastt != 0) && (t < lastt + NMBD_UNEXPECTED_TIMEOUT))
- return;
-
- lastt = t;
-
- tdb_traverse(tdbd->tdb, traverse_fn, NULL);
-}
-
-struct receive_unexpected_state {
- struct packet_struct *matched_packet;
- int match_id;
- enum packet_type match_type;
- const char *match_name;
-};
-
-/****************************************************************************
- tdb traversal fn to find a matching 137 packet.
-**************************************************************************/
-
-static int traverse_match(TDB_CONTEXT *ttdb, TDB_DATA kbuf, TDB_DATA dbuf,
- void *private_data)
-{
- struct receive_unexpected_state *state =
- (struct receive_unexpected_state *)private_data;
- struct unexpected_key key;
- struct in_addr ip;
- uint32_t enc_ip;
- int port;
- struct packet_struct *p;
-
- if (kbuf.dsize != sizeof(key)) {
- return 0;
- }
-
- memcpy(&key, kbuf.dptr, sizeof(key));
-
- if (key.packet_type != state->match_type) return 0;
-
- if (dbuf.dsize < 6) {
- return 0;
- }
-
- /* Decode the ip addr and port. */
- enc_ip = IVAL(dbuf.dptr,0);
- ip.s_addr = htonl(enc_ip);
- port = SVAL(dbuf.dptr,4);
-
- p = parse_packet((char *)&dbuf.dptr[6],
- dbuf.dsize-6,
- state->match_type,
- ip,
- port);
- if (!p)
- return 0;
-
- if ((state->match_type == NMB_PACKET &&
- p->packet.nmb.header.name_trn_id == state->match_id) ||
- (state->match_type == DGRAM_PACKET &&
- match_mailslot_name(p, state->match_name) &&
- p->packet.dgram.header.dgm_id == state->match_id)) {
- state->matched_packet = p;
- tdb_delete(ttdb, kbuf);
- return -1;
- }
-
- free_packet(p);
-
- return 0;
-}
-
-/****************************************************************************
- Check for a particular packet in the unexpected packet queue.
-**************************************************************************/
-
-struct packet_struct *receive_unexpected(enum packet_type packet_type, int id,
- const char *mailslot_name)
-{
- struct tdb_wrap *tdb2;
- struct receive_unexpected_state state;
-
- tdb2 = tdb_wrap_open(talloc_tos(), lock_path("unexpected.tdb"), 0, 0,
- O_RDWR, 0);
- if (!tdb2) return NULL;
-
- state.matched_packet = NULL;
- state.match_id = id;
- state.match_type = packet_type;
- state.match_name = mailslot_name;
-
- tdb_traverse(tdb2->tdb, traverse_match, &state);
-
- TALLOC_FREE(tdb2);
-
- return state.matched_packet;
-}
-
static const char *nmbd_socket_dir(void)
{
return lp_parm_const_string(-1, "nmbd", "socket dir", "/tmp/.nmbd");
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index eaa5055998..446c8933f4 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -460,9 +460,7 @@ static void msg_nmbd_send_packet(struct messaging_context *msg,
p->packet.dgram.header.source_port = 138;
}
- if (store_outstanding_send_packet(p)) {
- send_packet(p);
- }
+ send_packet(p);
}
/**************************************************************************** **
@@ -658,12 +656,6 @@ static void process(void)
if (lp_enhanced_browsing())
sync_all_dmbs(t);
- /*
- * clear the unexpected packet queue
- */
-
- clear_unexpected(t);
-
/* check for new network interfaces */
reload_interfaces(t);
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index c2a5204fac..73ee141104 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -1223,7 +1223,6 @@ static void process_dgram(struct packet_struct *p)
/* If we aren't listening to the destination name then ignore the packet */
if (!listening(p,&dgram->dest_name)) {
nb_packet_dispatch(packet_server, p);
- unexpected_packet(p);
DEBUG(5,("process_dgram: ignoring dgram packet sent to name %s from %s\n",
nmb_namestr(&dgram->dest_name), inet_ntoa(p->ip)));
return;
@@ -1231,7 +1230,6 @@ static void process_dgram(struct packet_struct *p)
if (dgram->header.msg_type != 0x10 && dgram->header.msg_type != 0x11 && dgram->header.msg_type != 0x12) {
nb_packet_dispatch(packet_server, p);
- unexpected_packet(p);
/* Don't process error packets etc yet */
DEBUG(5,("process_dgram: ignoring dgram packet sent to name %s from IP %s as it is \
an error packet of type %x\n", nmb_namestr(&dgram->dest_name), inet_ntoa(p->ip), dgram->header.msg_type));
@@ -1318,7 +1316,6 @@ packet sent to name %s from IP %s\n",
}
nb_packet_dispatch(packet_server, p);
- unexpected_packet(p);
}
/****************************************************************************
@@ -1439,7 +1436,6 @@ static struct subnet_record *find_subnet_for_nmb_packet( struct packet_struct *p
DEBUG(3,("find_subnet_for_nmb_packet: response record not found for response id %hu\n",
nmb->header.name_trn_id));
nb_packet_dispatch(packet_server, p);
- unexpected_packet(p);
return NULL;
}
@@ -1927,7 +1923,6 @@ bool listen_for_packets(bool run_election)
const char *packet_name;
int client_fd;
int client_port;
- bool is_requested_send_reply = false;
if (sock_array[i] == -1) {
continue;
@@ -1956,8 +1951,6 @@ bool listen_for_packets(bool run_election)
continue;
}
- is_requested_send_reply = is_requested_send_packet(packet);
-
/*
* If we got a packet on the broadcast socket and interfaces
* only is set then check it came from one of our local nets.
@@ -1971,8 +1964,7 @@ bool listen_for_packets(bool run_election)
continue;
}
- if (!is_requested_send_reply &&
- (is_loopback_ip_v4(packet->ip) || ismyip_v4(packet->ip)) &&
+ if ((is_loopback_ip_v4(packet->ip) || ismyip_v4(packet->ip)) &&
packet->port == client_port)
{
if (client_port == DGRAM_PORT) {
diff --git a/source3/winbindd/winbindd_wins.c b/source3/winbindd/winbindd_wins.c
index 164816ce2e..adfe55247c 100644
--- a/source3/winbindd/winbindd_wins.c
+++ b/source3/winbindd/winbindd_wins.c
@@ -26,50 +26,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
-/* Use our own create socket code so we don't recurse.... */
-
-static int wins_lookup_open_socket_in(void)
-{
- struct sockaddr_in sock;
- int val=1;
- int res;
-
- memset((char *)&sock,'\0',sizeof(sock));
-
-#ifdef HAVE_SOCK_SIN_LEN
- sock.sin_len = sizeof(sock);
-#endif
- sock.sin_port = 0;
- sock.sin_family = AF_INET;
- sock.sin_addr.s_addr = interpret_addr("0.0.0.0");
- res = socket(AF_INET, SOCK_DGRAM, 0);
- if (res == -1)
- return -1;
-
- if (setsockopt(res,SOL_SOCKET,SO_REUSEADDR,(char *)&val,sizeof(val))) {
- close(res);
- return -1;
- }
-#ifdef SO_REUSEPORT
- if (setsockopt(res,SOL_SOCKET,SO_REUSEPORT,(char *)&val,sizeof(val))) {
- close(res);
- return -1;
- }
-#endif /* SO_REUSEPORT */
-
- /* now we've got a socket - we need to bind it */
-
- if (bind(res, (struct sockaddr *)(void *)&sock, sizeof(sock)) < 0) {
- close(res);
- return(-1);
- }
-
- set_socket_options(res,"SO_BROADCAST");
-
- return res;
-}
-
-
static struct node_status *lookup_byaddr_backend(TALLOC_CTX *mem_ctx,
const char *addr, int *count)
{