From 78f51a1d3c53248159c1e7643364b62e52457bb9 Mon Sep 17 00:00:00 2001 From: Justin Stephenson Date: Thu, 3 Jan 2019 12:07:01 -0500 Subject: [PATCH 1/4] s3:libsmb: Check disable_netbios in socket connect If the disable_netbios option is set then return NT_STATUS_NOT_SUPPORTED for a port 139 connection in the low level socket connection code. Signed-off-by: Justin Stephenson Reviewed-by: Noel Power Reviewed-by: Jeremy Allison --- source3/libsmb/smbsock_connect.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source3/libsmb/smbsock_connect.c b/source3/libsmb/smbsock_connect.c index 9f915e1bb42..bb3cb07646c 100644 --- a/source3/libsmb/smbsock_connect.c +++ b/source3/libsmb/smbsock_connect.c @@ -376,6 +376,11 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx, tevent_req_set_cleanup_fn(req, smbsock_connect_cleanup); if (port == NBT_SMB_PORT) { + if (lp_disable_netbios()) { + tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED); + return tevent_req_post(req, ev); + } + state->req_139 = nb_connect_send(state, state->ev, state->addr, state->called_name, state->called_type, -- 2.20.1 From 499f051c9d527a14f9712365f8403a1ee0662c5b Mon Sep 17 00:00:00 2001 From: Justin Stephenson Date: Mon, 17 Dec 2018 14:40:33 -0500 Subject: [PATCH 2/4] s3:libsmb: Print debug message about Netbios With a preceding patch, cli_connect_nb() will return NT_STATUS_NOT_SUPPORTED when 'disable netbios' is set in smb.conf. Print an informative error message to indicate Netbios is disabled if this occurs. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13727 Signed-off-by: Justin Stephenson Reviewed-by: Noel Power Reviewed-by: Jeremy Allison --- source3/libsmb/clidfs.c | 4 ++++ source3/libsmb/libsmb_server.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index 6918802396c..4342a3b1d1b 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -196,6 +196,10 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx, flags, &c); if (!NT_STATUS_IS_OK(status)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { + DBG_ERR("NetBIOS support disabled, unable to connect"); + } + DBG_WARNING("Connection to %s failed (Error %s)\n", server, nt_errstr(status)); diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 67dfcf72327..0067df48cac 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -489,6 +489,10 @@ SMBC_server_internal(TALLOC_CTX *ctx, } if (!NT_STATUS_IS_OK(status)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { + DBG_ERR("NetBIOS support disabled, unable to connect"); + } + errno = map_errno_from_nt_status(status); return NULL; } -- 2.20.1 From ecbb2f78cec6d9e6f5180c8ba274a1da2152f098 Mon Sep 17 00:00:00 2001 From: Justin Stephenson Date: Mon, 17 Dec 2018 14:57:59 -0500 Subject: [PATCH 3/4] s3:smbpasswd: Print debug message about Netbios With a preceding patch, cli_connect_nb() will return NT_STATUS_NOT_SUPPORTED when 'disable netbios' is set in smb.conf. Print an informative error message to indicate Netbios is disabled if this occurs. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13727 Signed-off-by: Justin Stephenson Reviewed-by: Noel Power Reviewed-by: Jeremy Allison --- source3/libsmb/passchange.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c index 48ffba8036f..f60e3079975 100644 --- a/source3/libsmb/passchange.c +++ b/source3/libsmb/passchange.c @@ -46,10 +46,18 @@ NTSTATUS remote_password_change(const char *remote_machine, result = cli_connect_nb(remote_machine, NULL, 0, 0x20, NULL, SMB_SIGNING_IPC_DEFAULT, 0, &cli); if (!NT_STATUS_IS_OK(result)) { - if (asprintf(err_str, "Unable to connect to SMB server on " - "machine %s. Error was : %s.\n", - remote_machine, nt_errstr(result))==-1) { - *err_str = NULL; + if (NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED)) { + if (asprintf(err_str, "Unable to connect to SMB server on " + "machine %s. NetBIOS support disabled\n", + remote_machine) == -1) { + *err_str = NULL; + } + } else { + if (asprintf(err_str, "Unable to connect to SMB server on " + "machine %s. Error was : %s.\n", + remote_machine, nt_errstr(result))==-1) { + *err_str = NULL; + } } return result; } -- 2.20.1 From 08867de2efde05e4730b41a335d13f775e44e397 Mon Sep 17 00:00:00 2001 From: Justin Stephenson Date: Mon, 17 Dec 2018 15:17:24 -0500 Subject: [PATCH 4/4] s3:utils:net: Print debug message about Netbios With a preceding patch, cli_connect_nb() will return NT_STATUS_NOT_SUPPORTED when 'disable netbios' is set in smb.conf. Print an informative error message to indicate Netbios is disabled if this occurs. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13727 Signed-off-by: Justin Stephenson Reviewed-by: Noel Power Reviewed-by: Jeremy Allison Autobuild-User(master): Noel Power Autobuild-Date(master): Wed Jan 9 22:38:21 CET 2019 on sn-devel-144 --- source3/utils/net_rpc.c | 3 +++ source3/utils/net_time.c | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index c300b8a4b3d..f2d63d2af65 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -7455,6 +7455,9 @@ bool net_rpc_check(struct net_context *c, unsigned flags) lp_netbios_name(), SMB_SIGNING_IPC_DEFAULT, 0, &cli); if (!NT_STATUS_IS_OK(status)) { + if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { + DBG_ERR("NetBIOS support disabled, unable to connect\n"); + } return false; } status = smbXcli_negprot(cli->conn, cli->timeout, PROTOCOL_CORE, diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c index 0091fc86333..5e6cf2ea15d 100644 --- a/source3/utils/net_time.c +++ b/source3/utils/net_time.c @@ -37,8 +37,13 @@ static time_t cli_servertime(const char *host, status = cli_connect_nb(host, dest_ss, 0, 0x20, lp_netbios_name(), SMB_SIGNING_DEFAULT, 0, &cli); if (!NT_STATUS_IS_OK(status)) { - fprintf(stderr, _("Can't contact server %s. Error %s\n"), - host, nt_errstr(status)); + if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) { + fprintf(stderr, "Can't contact server %s. NetBIOS support disabled," + " Error %s\n", host, nt_errstr(status)); + } else { + fprintf(stderr, "Can't contact server %s. Error %s\n", + host, nt_errstr(status)); + } goto done; } -- 2.20.1