[PATCH] A few minor fixes
Volker Lendecke
Volker.Lendecke at SerNet.DE
Tue Dec 8 19:25:35 UTC 2015
Hi!
Review appreciated!
Thanks, Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From bebeffd278d44a15ca5869e9bf04b5c4f930eee7 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 5 Dec 2015 12:59:49 +0100
Subject: [PATCH 1/8] lib: Avoid a includes.h
Signed-off-by: Volker Lendecke <vl at samba.org>
---
librpc/ndr/ndr_basic.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c
index 12e3942..ecc0f74 100644
--- a/librpc/ndr/ndr_basic.c
+++ b/librpc/ndr/ndr_basic.c
@@ -19,10 +19,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "includes.h"
+#include "replace.h"
#include "system/network.h"
#include "librpc/ndr/libndr.h"
#include "lib/util/util_net.h"
+#include "lib/util/debug.h"
#define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs))
#define NDR_IVAL(ndr, ofs) (NDR_BE(ndr)?RIVAL(ndr->data,ofs):IVAL(ndr->data,ofs))
--
1.9.1
From 89e31678f7bfed8b91f18538ee7b1908edb46c47 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 5 Dec 2015 13:00:07 +0100
Subject: [PATCH 2/8] lib: make debug_dsdcinfo_flags static
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/proto.h | 1 -
source3/libsmb/dsgetdcname.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 9dd08fb..7d0ba42 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -764,7 +764,6 @@ void flush_negative_conn_cache_for_domain(const char *domain);
struct netr_DsRGetDCNameInfo;
-void debug_dsdcinfo_flags(int lvl, uint32_t flags);
NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
const char *domain_name,
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index ac3bfd6..d7c9332 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -44,7 +44,7 @@ static NTSTATUS make_dc_info_from_cldap_reply(TALLOC_CTX *mem_ctx,
/****************************************************************
****************************************************************/
-void debug_dsdcinfo_flags(int lvl, uint32_t flags)
+static void debug_dsdcinfo_flags(int lvl, uint32_t flags)
{
DEBUG(lvl,("debug_dsdcinfo_flags: 0x%08x\n\t", flags));
--
1.9.1
From 93827b77bee4b1b0bd0b8c9c59533dd6e9c8df86 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 5 Dec 2015 13:49:55 +0100
Subject: [PATCH 3/8] lib: Lift lp_disable_netbios one level
This should fix an error code when neither DS_IS_FLAT_NAME nor
DS_IS_DNS_NAME are specified. If netbios is disabled and the DC
can't be found via DNS we should not return NOT_SUPPORTED but
DOMAIN_CONTROLLER_NOT_FOUND.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/libsmb/dsgetdcname.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index d7c9332..ca96811 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -483,10 +483,6 @@ static NTSTATUS discover_dc_netbios(TALLOC_CTX *mem_ctx,
*returned_dclist = NULL;
*returned_count = 0;
- if (lp_disable_netbios()) {
- return NT_STATUS_NOT_SUPPORTED;
- }
-
if (flags & DS_PDC_REQUIRED) {
name_type = NBT_NAME_PDC;
}
@@ -1046,6 +1042,10 @@ static NTSTATUS dsgetdcname_rediscover(TALLOC_CTX *mem_ctx,
if (flags & DS_IS_FLAT_NAME) {
+ if (lp_disable_netbios()) {
+ return NT_STATUS_NOT_SUPPORTED;
+ }
+
status = discover_dc_netbios(mem_ctx, domain_name, flags,
&dclist, &num_dcs);
NT_STATUS_NOT_OK_RETURN(status);
@@ -1076,6 +1076,10 @@ static NTSTATUS dsgetdcname_rediscover(TALLOC_CTX *mem_ctx,
}
}
+ if (lp_disable_netbios()) {
+ return NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
+ }
+
status = discover_dc_netbios(mem_ctx, domain_name, flags, &dclist,
&num_dcs);
NT_STATUS_NOT_OK_RETURN(status);
--
1.9.1
From bcab0934b73fd48bedf73268c556763c48d9d751 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 5 Dec 2015 18:46:34 +0100
Subject: [PATCH 4/8] lib: Use GUID_buf_string in discover_dc_dns
One talloc call less..
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/libsmb/dsgetdcname.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index ca96811..a63ba5a 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -543,7 +543,6 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
int numaddrs = 0;
struct ip_service_name *dclist = NULL;
int count = 0;
- char *guid_string;
if (flags & DS_PDC_REQUIRED) {
status = ads_dns_query_pdc(mem_ctx,
@@ -569,17 +568,14 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
&dcs,
&numdcs);
} else if (domain_guid) {
- guid_string = GUID_string(mem_ctx, domain_guid);
- if (!guid_string) {
- return NT_STATUS_NO_MEMORY;
- }
+ struct GUID_txt_buf buf;
+ GUID_buf_string(domain_guid, &buf);
status = ads_dns_query_dcs_guid(mem_ctx,
domain_name,
- guid_string,
+ buf.buf,
&dcs,
&numdcs);
- TALLOC_FREE(guid_string);
} else {
status = ads_dns_query_dcs(mem_ctx,
domain_name,
--
1.9.1
From b1a16f0f2e7e49a7f95e991ef2e25846f792cef5 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 6 Dec 2015 11:19:46 +0100
Subject: [PATCH 5/8] libdns: tsocket returns -1 and sets errno
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/dns/dns.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libcli/dns/dns.c b/libcli/dns/dns.c
index 43e1c4e..90b7618 100644
--- a/libcli/dns/dns.c
+++ b/libcli/dns/dns.c
@@ -67,20 +67,20 @@ struct tevent_req *dns_udp_request_send(TALLOC_CTX *mem_ctx,
ret = tsocket_address_inet_from_strings(state, "ip", NULL, 0,
&local_addr);
if (ret != 0) {
- tevent_req_werror(req, unix_to_werror(ret));
+ tevent_req_werror(req, unix_to_werror(errno));
return tevent_req_post(req, ev);
}
ret = tsocket_address_inet_from_strings(state, "ip", server_addr_string,
DNS_SERVICE_PORT, &server_addr);
if (ret != 0) {
- tevent_req_werror(req, unix_to_werror(ret));
+ tevent_req_werror(req, unix_to_werror(errno));
return tevent_req_post(req, ev);
}
ret = tdgram_inet_udp_socket(local_addr, server_addr, state, &dgram);
if (ret != 0) {
- tevent_req_werror(req, unix_to_werror(ret));
+ tevent_req_werror(req, unix_to_werror(errno));
return tevent_req_post(req, ev);
}
--
1.9.1
From ad96ba33f124a139e1819420e2c9067d84320bfc Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 6 Dec 2015 11:20:24 +0100
Subject: [PATCH 6/8] libdns: Properly set ENOMEM
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/dns/dns.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcli/dns/dns.c b/libcli/dns/dns.c
index 90b7618..cc1eba9 100644
--- a/libcli/dns/dns.c
+++ b/libcli/dns/dns.c
@@ -96,6 +96,7 @@ struct tevent_req *dns_udp_request_send(TALLOC_CTX *mem_ctx,
if (!tevent_req_set_endtime(req, ev,
timeval_current_ofs(DNS_REQUEST_TIMEOUT, 0))) {
+ tevent_req_oom(req);
return tevent_req_post(req, ev);
}
--
1.9.1
From e20e70dadf4d6a635f18c611f4a4f5d7233aa9ad Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 6 Dec 2015 11:31:23 +0100
Subject: [PATCH 7/8] libdns: Convert dns_udp_request to 0/errno
Replaces 5 calls to unix_to_werror with just one
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/dns/dns.c | 31 +++++++++++++++----------------
libcli/dns/libdns.h | 10 +++++-----
source4/dns_server/dns_query.c | 6 ++++--
3 files changed, 24 insertions(+), 23 deletions(-)
diff --git a/libcli/dns/dns.c b/libcli/dns/dns.c
index cc1eba9..cc3f90d 100644
--- a/libcli/dns/dns.c
+++ b/libcli/dns/dns.c
@@ -23,9 +23,8 @@
#include "system/network.h"
#include <tevent.h>
#include "lib/tsocket/tsocket.h"
-#include "libcli/util/werror.h"
#include "libcli/dns/libdns.h"
-#include "lib/util/tevent_werror.h"
+#include "lib/util/tevent_unix.h"
#include "lib/util/samba_util.h"
#include "libcli/util/error.h"
#include "librpc/gen_ndr/dns.h"
@@ -67,20 +66,20 @@ struct tevent_req *dns_udp_request_send(TALLOC_CTX *mem_ctx,
ret = tsocket_address_inet_from_strings(state, "ip", NULL, 0,
&local_addr);
if (ret != 0) {
- tevent_req_werror(req, unix_to_werror(errno));
+ tevent_req_error(req, errno);
return tevent_req_post(req, ev);
}
ret = tsocket_address_inet_from_strings(state, "ip", server_addr_string,
DNS_SERVICE_PORT, &server_addr);
if (ret != 0) {
- tevent_req_werror(req, unix_to_werror(errno));
+ tevent_req_error(req, errno);
return tevent_req_post(req, ev);
}
ret = tdgram_inet_udp_socket(local_addr, server_addr, state, &dgram);
if (ret != 0) {
- tevent_req_werror(req, unix_to_werror(errno));
+ tevent_req_error(req, errno);
return tevent_req_post(req, ev);
}
@@ -118,12 +117,12 @@ static void dns_udp_request_get_reply(struct tevent_req *subreq)
TALLOC_FREE(subreq);
if (len == -1 && err != 0) {
- tevent_req_werror(req, unix_to_werror(err));
+ tevent_req_error(req, err);
return;
}
if (len != state->query_len) {
- tevent_req_werror(req, WERR_NET_WRITE_FAULT);
+ tevent_req_error(req, EIO);
return;
}
@@ -150,7 +149,7 @@ static void dns_udp_request_done(struct tevent_req *subreq)
TALLOC_FREE(subreq);
if (len == -1 && err != 0) {
- tevent_req_werror(req, unix_to_werror(err));
+ tevent_req_error(req, err);
return;
}
@@ -159,23 +158,23 @@ static void dns_udp_request_done(struct tevent_req *subreq)
tevent_req_done(req);
}
-WERROR dns_udp_request_recv(struct tevent_req *req,
- TALLOC_CTX *mem_ctx,
- uint8_t **reply,
- size_t *reply_len)
+int dns_udp_request_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ uint8_t **reply,
+ size_t *reply_len)
{
struct dns_udp_request_state *state = tevent_req_data(req,
struct dns_udp_request_state);
- WERROR w_error;
+ int err;
- if (tevent_req_is_werror(req, &w_error)) {
+ if (tevent_req_is_unix_error(req, &err)) {
tevent_req_received(req);
- return w_error;
+ return err;
}
*reply = talloc_move(mem_ctx, &state->reply);
*reply_len = state->reply_len;
tevent_req_received(req);
- return WERR_OK;
+ return 0;
}
diff --git a/libcli/dns/libdns.h b/libcli/dns/libdns.h
index 31474eb..7ea2eb6 100644
--- a/libcli/dns/libdns.h
+++ b/libcli/dns/libdns.h
@@ -43,11 +43,11 @@ struct tevent_req *dns_udp_request_send(TALLOC_CTX *mem_ctx,
*@param mem_ctx talloc memory context to use for the reply string
*@param reply buffer that will be allocated and filled with the dns reply
*@param reply_len length of the reply buffer
- *@return WERROR code depending on the async request result
+ *@return 0/errno
*/
-WERROR dns_udp_request_recv(struct tevent_req *req,
- TALLOC_CTX *mem_ctx,
- uint8_t **reply,
- size_t *reply_len);
+int dns_udp_request_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ uint8_t **reply,
+ size_t *reply_len);
#endif /*__LIBDNS_H__*/
diff --git a/source4/dns_server/dns_query.c b/source4/dns_server/dns_query.c
index 89cfd64..956898e 100644
--- a/source4/dns_server/dns_query.c
+++ b/source4/dns_server/dns_query.c
@@ -203,12 +203,14 @@ static void ask_forwarder_done(struct tevent_req *subreq)
req, struct ask_forwarder_state);
DATA_BLOB in_blob;
enum ndr_err_code ndr_err;
- WERROR ret;
+ int ret;
ret = dns_udp_request_recv(subreq, state,
&in_blob.data, &in_blob.length);
TALLOC_FREE(subreq);
- if (tevent_req_werror(req, ret)) {
+
+ if (ret != 0) {
+ tevent_req_werror(req, unix_to_werror(ret));
return;
}
--
1.9.1
From d1aab46fd5ae5e1c533a4c60dd77f4143a6f7a12 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 6 Dec 2015 11:32:46 +0100
Subject: [PATCH 8/8] libdns: Small cleanup
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/dns/dns.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/libcli/dns/dns.c b/libcli/dns/dns.c
index cc3f90d..7d066d8 100644
--- a/libcli/dns/dns.c
+++ b/libcli/dns/dns.c
@@ -99,7 +99,6 @@ struct tevent_req *dns_udp_request_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
-
tevent_req_set_callback(subreq, dns_udp_request_get_reply, req);
return req;
}
@@ -132,7 +131,6 @@ static void dns_udp_request_get_reply(struct tevent_req *subreq)
}
tevent_req_set_callback(subreq, dns_udp_request_done, req);
- return;
}
static void dns_udp_request_done(struct tevent_req *subreq)
--
1.9.1
More information about the samba-technical
mailing list