hardcoded port 445
Oskar Liljeblad
oskar at osk.mine.nu
Sun Oct 30 01:24:42 MDT 2011
Hello
I am writing a small application doing MSRPC using Samba4. It relies on
forwarded ports, it will for instance connect to 127.0.0.1:12345 which is
forwarded to 445 on some remote machine. So I looked at the Samba code and
noticed two places where 445 is hardcoded:
source4/libcli/raw/clitransport.c:
bool smbcli_transport_connect(struct smbcli_transport *transport,
struct nbt_name *calling,
struct nbt_name *called)
{
struct smbcli_request *req;
NTSTATUS status;
if (transport->socket->port == 445) {
return true;
}
req = smbcli_transport_connect_send(transport,
calling, called);
status = smbcli_transport_connect_recv(req);
return NT_STATUS_IS_OK(status);
}
source4/libcli/smb_composite/connect.c:
static NTSTATUS connect_socket(struct composite_context *c,
struct smb_composite_connect *io)
{
[..]
/* we have a connected socket - next step is a session
request, if needed. Port 445 doesn't need it, so it goes
straight to the negprot */
if (state->sock->port == 445) {
status = nbt_name_dup(state->transport, &called,
&state->transport->called);
NT_STATUS_NOT_OK_RETURN(status);
return connect_send_negprot(c, io);
}
state->req = smbcli_transport_connect_send(state->transport, &calling, &called);
NT_STATUS_HAVE_NO_MEMORY(state->req);
state->req->async.fn = request_handler;
state->req->async.private_data = c;
state->stage = CONNECT_SESSION_REQUEST;
return NT_STATUS_OK;
}
My application will not be connecting to 445 so will this cause
incompatibility? If so I see only one solution: Always keep track of what
type of port is specified, NetBIOS or CIFS. That would be needed in many
places, libcli (struct smbcli_socket), lib/socket/connect_multi.c etc,
and many functions would need to be modified.
Any suggestions how to go about here?
Regards,
Oskar Liljeblad (oskar at osk.mine.nu)
More information about the samba-technical
mailing list