A few cleanup patches
Volker Lendecke
Volker.Lendecke at SerNet.DE
Sun Aug 11 04:42:59 MDT 2013
Hi!
Attached find a few cleanup patches from my attic.
Please review&push.
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 9c6c6d2de7fc69d094e8e7d4f5ecbfd34b5a1379 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 21 Jun 2013 18:11:07 +0200
Subject: [PATCH 01/10] lsa4: Remove an unused variable
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/rpc_server/lsa/dcesrv_lsa.c | 3 ---
1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c
index b5f3768..8d1a856 100644
--- a/source4/rpc_server/lsa/dcesrv_lsa.c
+++ b/source4/rpc_server/lsa/dcesrv_lsa.c
@@ -296,15 +296,12 @@ static NTSTATUS dcesrv_lsa_EnumPrivs(struct dcesrv_call_state *dce_call, TALLOC_
struct lsa_EnumPrivs *r)
{
struct dcesrv_handle *h;
- struct lsa_policy_state *state;
uint32_t i;
enum sec_privilege priv;
const char *privname;
DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_POLICY);
- state = h->data;
-
i = *r->in.resume_handle;
while (((priv = sec_privilege_from_index(i)) != SEC_PRIV_INVALID) &&
--
1.7.0.4
>From abd76b44a63e2117fe9ea70192b4cb73bc57f1df Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 21 Jun 2013 18:11:30 +0200
Subject: [PATCH 02/10] lsa4: Fix an set but unused variable warning
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/rpc_server/lsa/dcesrv_lsa.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c
index 8d1a856..d8a5aef 100644
--- a/source4/rpc_server/lsa/dcesrv_lsa.c
+++ b/source4/rpc_server/lsa/dcesrv_lsa.c
@@ -3342,7 +3342,7 @@ static NTSTATUS dcesrv_lsa_QuerySecret(struct dcesrv_call_state *dce_call, TALLO
if (!r->out.old_val) {
return NT_STATUS_NO_MEMORY;
}
- prior_val = ldb_msg_find_ldb_val(res[0], "priorValue");
+ prior_val = ldb_msg_find_ldb_val(msg, "priorValue");
if (prior_val && prior_val->length) {
secret.data = prior_val->data;
@@ -3368,7 +3368,7 @@ static NTSTATUS dcesrv_lsa_QuerySecret(struct dcesrv_call_state *dce_call, TALLO
if (!r->out.old_mtime) {
return NT_STATUS_NO_MEMORY;
}
- *r->out.old_mtime = ldb_msg_find_attr_as_uint64(res[0], "priorSetTime", 0);
+ *r->out.old_mtime = ldb_msg_find_attr_as_uint64(msg, "priorSetTime", 0);
}
if (r->in.new_val) {
@@ -3378,7 +3378,7 @@ static NTSTATUS dcesrv_lsa_QuerySecret(struct dcesrv_call_state *dce_call, TALLO
return NT_STATUS_NO_MEMORY;
}
- new_val = ldb_msg_find_ldb_val(res[0], "currentValue");
+ new_val = ldb_msg_find_ldb_val(msg, "currentValue");
if (new_val && new_val->length) {
secret.data = new_val->data;
@@ -3404,7 +3404,7 @@ static NTSTATUS dcesrv_lsa_QuerySecret(struct dcesrv_call_state *dce_call, TALLO
if (!r->out.new_mtime) {
return NT_STATUS_NO_MEMORY;
}
- *r->out.new_mtime = ldb_msg_find_attr_as_uint64(res[0], "lastSetTime", 0);
+ *r->out.new_mtime = ldb_msg_find_attr_as_uint64(msg, "lastSetTime", 0);
}
return NT_STATUS_OK;
--
1.7.0.4
>From 9de5767a8b9d6e907f5bdd66c1b6673aa20aa579 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 20 Jun 2013 13:49:45 +0200
Subject: [PATCH 03/10] lib: Remove unused "client_name"
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/util_net.h | 1 -
source3/include/proto.h | 1 -
source3/lib/util_sock.c | 5 -----
3 files changed, 0 insertions(+), 7 deletions(-)
diff --git a/lib/util/util_net.h b/lib/util/util_net.h
index 215a657..2f1beff 100644
--- a/lib/util/util_net.h
+++ b/lib/util/util_net.h
@@ -106,7 +106,6 @@ char *print_sockaddr(char *dest,
const struct sockaddr_storage *psa);
char *print_canonical_sockaddr(TALLOC_CTX *ctx,
const struct sockaddr_storage *pss);
-const char *client_name(int fd);
int get_socket_port(int fd);
const char *client_socket_addr(int fd, char *addr, size_t addr_len);
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a9270fc..4477246 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -571,7 +571,6 @@ char *print_sockaddr(char *dest,
const struct sockaddr_storage *psa);
char *print_canonical_sockaddr(TALLOC_CTX *ctx,
const struct sockaddr_storage *pss);
-const char *client_name(int fd);
int get_socket_port(int fd);
const char *client_addr(int fd, char *addr, size_t addrlen);
const char *client_socket_addr(int fd, char *addr, size_t addr_len);
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 54286b3..509e7b7 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -29,11 +29,6 @@
#include "../lib/util/tevent_ntstatus.h"
#include "../lib/tsocket/tsocket.h"
-const char *client_name(int fd)
-{
- return get_peer_name(fd,false);
-}
-
const char *client_addr(int fd, char *addr, size_t addrlen)
{
return get_peer_addr(fd,addr,addrlen);
--
1.7.0.4
>From 3b50bdcedb3c85800ace6e56ad54605fc3d418c6 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 21 Jun 2013 18:33:56 +0200
Subject: [PATCH 04/10] lib: Remove unused "get_peer_name"
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/include/proto.h | 1 -
source3/lib/util_sock.c | 79 -----------------------------------------------
2 files changed, 0 insertions(+), 80 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 4477246..13b1350 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -619,7 +619,6 @@ struct tevent_req *open_socket_out_defer_send(TALLOC_CTX *mem_ctx,
int timeout);
NTSTATUS open_socket_out_defer_recv(struct tevent_req *req, int *pfd);
int open_udp_socket(const char *host, int port);
-const char *get_peer_name(int fd, bool force_lookup);
const char *get_peer_addr(int fd, char *addr, size_t addr_len);
struct tsocket_address;
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 509e7b7..a35ae97 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1023,85 +1023,6 @@ static void store_nc(const struct name_addr_pair *nc)
}
/*******************************************************************
- Return the DNS name of the remote end of a socket.
-******************************************************************/
-
-const char *get_peer_name(int fd, bool force_lookup)
-{
- struct name_addr_pair nc;
- char addr_buf[INET6_ADDRSTRLEN];
- struct sockaddr_storage ss;
- socklen_t length = sizeof(ss);
- const char *p;
- int ret;
- char name_buf[MAX_DNS_NAME_LENGTH];
- char tmp_name[MAX_DNS_NAME_LENGTH];
-
- /* reverse lookups can be *very* expensive, and in many
- situations won't work because many networks don't link dhcp
- with dns. To avoid the delay we avoid the lookup if
- possible */
- if (!lp_hostname_lookups() && (force_lookup == false)) {
- length = sizeof(nc.ss);
- nc.name = get_peer_addr_internal(fd, addr_buf, sizeof(addr_buf),
- (struct sockaddr *)&nc.ss, &length);
- store_nc(&nc);
- lookup_nc(&nc);
- return nc.name ? nc.name : "UNKNOWN";
- }
-
- lookup_nc(&nc);
-
- memset(&ss, '\0', sizeof(ss));
- p = get_peer_addr_internal(fd, addr_buf, sizeof(addr_buf), (struct sockaddr *)&ss, &length);
-
- /* it might be the same as the last one - save some DNS work */
- if (sockaddr_equal((struct sockaddr *)&ss, (struct sockaddr *)&nc.ss)) {
- return nc.name ? nc.name : "UNKNOWN";
- }
-
- /* Not the same. We need to lookup. */
- if (fd == -1) {
- return "UNKNOWN";
- }
-
- /* Look up the remote host name. */
- ret = sys_getnameinfo((struct sockaddr *)&ss,
- length,
- name_buf,
- sizeof(name_buf),
- NULL,
- 0,
- 0);
-
- if (ret) {
- DEBUG(1,("get_peer_name: getnameinfo failed "
- "for %s with error %s\n",
- p,
- gai_strerror(ret)));
- strlcpy(name_buf, p, sizeof(name_buf));
- } else {
- if (!matchname(name_buf, (struct sockaddr *)&ss, length)) {
- DEBUG(0,("Matchname failed on %s %s\n",name_buf,p));
- strlcpy(name_buf,"UNKNOWN",sizeof(name_buf));
- }
- }
-
- strlcpy(tmp_name, name_buf, sizeof(tmp_name));
- alpha_strcpy(name_buf, tmp_name, "_-.", sizeof(name_buf));
- if (strstr(name_buf,"..")) {
- strlcpy(name_buf, "UNKNOWN", sizeof(name_buf));
- }
-
- nc.name = name_buf;
- nc.ss = ss;
-
- store_nc(&nc);
- lookup_nc(&nc);
- return nc.name ? nc.name : "UNKNOWN";
-}
-
-/*******************************************************************
Return the IP addr of the remote end of a socket as a string.
******************************************************************/
--
1.7.0.4
>From 834b068d955d90f1de27b88b400433d8c8eb9aeb Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 22 Jun 2013 18:40:31 +0200
Subject: [PATCH 05/10] smbd: Fix nonblank line endings
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/modules/vfs_default.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 304ef37..edac0de 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1033,10 +1033,10 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
}
status = file_set_sparse(handle->conn, fsp, set_sparse);
-
+
DEBUG(NT_STATUS_IS_OK(status) ? 10 : 9,
("FSCTL_SET_SPARSE: fname[%s] set[%u] - %s\n",
- smb_fname_str_dbg(fsp->fsp_name), set_sparse,
+ smb_fname_str_dbg(fsp->fsp_name), set_sparse,
nt_errstr(status)));
return status;
@@ -1125,17 +1125,17 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
if (SMB_VFS_GET_SHADOW_COPY_DATA(fsp, shadow_data, labels)!=0) {
TALLOC_FREE(shadow_data);
if (errno == ENOSYS) {
- DEBUG(5,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, not supported.\n",
+ DEBUG(5,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, not supported.\n",
fsp->conn->connectpath));
return NT_STATUS_NOT_SUPPORTED;
} else {
- DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, failed.\n",
+ DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, failed.\n",
fsp->conn->connectpath));
return NT_STATUS_UNSUCCESSFUL;
}
}
- labels_data_count = (shadow_data->num_volumes * 2 *
+ labels_data_count = (shadow_data->num_volumes * 2 *
sizeof(SHADOW_COPY_LABEL)) + 2;
if (!labels) {
@@ -1325,7 +1325,7 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
}
default:
- /*
+ /*
* Only print once ... unfortunately there could be lots of
* different FSCTLs that are called.
*/
--
1.7.0.4
>From 39be3b8f300f5176e43645bc85c03eaeec969c32 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 22 Jun 2013 18:43:00 +0200
Subject: [PATCH 06/10] smbd: Fix CID 1035550 Structurally dead code
Just a single ctl_code from my point of view is okay with an if(). All
other cases are handled behind the VFS these days.
The dead code was the last tevent_req_nterror and post routines.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source3/smbd/smb2_ioctl_named_pipe.c | 67 +++++++++++++++-------------------
1 files changed, 29 insertions(+), 38 deletions(-)
diff --git a/source3/smbd/smb2_ioctl_named_pipe.c b/source3/smbd/smb2_ioctl_named_pipe.c
index 601e1c3..13c4982 100644
--- a/source3/smbd/smb2_ioctl_named_pipe.c
+++ b/source3/smbd/smb2_ioctl_named_pipe.c
@@ -35,11 +35,13 @@ struct tevent_req *smb2_ioctl_named_pipe(uint32_t ctl_code,
struct tevent_req *req,
struct smbd_smb2_ioctl_state *state)
{
- struct tevent_req *subreq;
+ NTSTATUS status;
+ uint8_t *out_data = NULL;
+ uint32_t out_data_len = 0;
+
+ if (ctl_code == FSCTL_PIPE_TRANSCEIVE) {
+ struct tevent_req *subreq;
- switch (ctl_code) {
- case FSCTL_PIPE_TRANSCEIVE:
- {
if (!IS_IPC(state->smbreq->conn)) {
tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
return tevent_req_post(req, ev);
@@ -69,47 +71,36 @@ struct tevent_req *smb2_ioctl_named_pipe(uint32_t ctl_code,
smbd_smb2_ioctl_pipe_write_done,
req);
return req;
- break;
}
- default: {
- NTSTATUS status;
- uint8_t *out_data = NULL;
- uint32_t out_data_len = 0;
- if (state->fsp == NULL) {
- status = NT_STATUS_NOT_SUPPORTED;
- } else {
- status = SMB_VFS_FSCTL(state->fsp,
- state,
- ctl_code,
- state->smbreq->flags2,
- state->in_input.data,
- state->in_input.length,
- &out_data,
- state->in_max_output,
- &out_data_len);
- state->out_output = data_blob_const(out_data, out_data_len);
- if (NT_STATUS_IS_OK(status)) {
- tevent_req_done(req);
- return tevent_req_post(req, ev);
- }
+ if (state->fsp == NULL) {
+ status = NT_STATUS_NOT_SUPPORTED;
+ } else {
+ status = SMB_VFS_FSCTL(state->fsp,
+ state,
+ ctl_code,
+ state->smbreq->flags2,
+ state->in_input.data,
+ state->in_input.length,
+ &out_data,
+ state->in_max_output,
+ &out_data_len);
+ state->out_output = data_blob_const(out_data, out_data_len);
+ if (NT_STATUS_IS_OK(status)) {
+ tevent_req_done(req);
+ return tevent_req_post(req, ev);
}
+ }
- if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
- if (IS_IPC(state->smbreq->conn)) {
- status = NT_STATUS_FS_DRIVER_REQUIRED;
- } else {
- status = NT_STATUS_INVALID_DEVICE_REQUEST;
- }
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
+ if (IS_IPC(state->smbreq->conn)) {
+ status = NT_STATUS_FS_DRIVER_REQUIRED;
+ } else {
+ status = NT_STATUS_INVALID_DEVICE_REQUEST;
}
-
- tevent_req_nterror(req, status);
- return tevent_req_post(req, ev);
- break;
- }
}
- tevent_req_nterror(req, NT_STATUS_INTERNAL_ERROR);
+ tevent_req_nterror(req, status);
return tevent_req_post(req, ev);
}
--
1.7.0.4
>From 678617521bc77afec44c6e79f1874a47c79adc06 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 9 Jun 2013 11:41:32 +0200
Subject: [PATCH 07/10] libsmb: Avoid an unnecessary "else"
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/smb/smbXcli_base.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 5a5828a..b6d1ce9 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -1587,7 +1587,9 @@ static void smbXcli_conn_received(struct tevent_req *subreq)
* tevent_req_done().
*/
return;
- } else if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
+ }
+
+ if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
/*
* We got an error, so notify all pending requests
*/
--
1.7.0.4
>From cdd504c3d48e1c9cffa2e11da60edbbaa71d9c2d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 9 Jun 2013 18:02:27 +0200
Subject: [PATCH 08/10] libsmb: Remove an unnecessary variable assignment
Signed-off-by: Volker Lendecke <vl at samba.org>
---
libcli/smb/smbXcli_base.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index b6d1ce9..7397f83 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -1562,8 +1562,7 @@ static void smbXcli_conn_received(struct tevent_req *subreq)
if (subreq != conn->read_smb_req) {
DEBUG(1, ("Internal error: cli_smb_received called with "
"unexpected subreq\n"));
- status = NT_STATUS_INTERNAL_ERROR;
- smbXcli_conn_disconnect(conn, status);
+ smbXcli_conn_disconnect(conn, NT_STATUS_INTERNAL_ERROR);
TALLOC_FREE(frame);
return;
}
--
1.7.0.4
>From 270d530201938170b300a83bc1c9d222b5dcd857 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sat, 15 Jun 2013 20:39:53 +0200
Subject: [PATCH 09/10] libcli: Fix improper use of tevent_req_simple_recv_ntstatus
tevent_req_simple_recv_ntstatus is just for the simple return without
anything to do after it.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
source4/libcli/finddcs_cldap.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/source4/libcli/finddcs_cldap.c b/source4/libcli/finddcs_cldap.c
index bf8da4e..ce0e1c7 100644
--- a/source4/libcli/finddcs_cldap.c
+++ b/source4/libcli/finddcs_cldap.c
@@ -431,14 +431,18 @@ NTSTATUS finddcs_cldap_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, struct
talloc_free(req);
return NT_STATUS_INTERNAL_ERROR;
}
- status = tevent_req_simple_recv_ntstatus(req);
- if (NT_STATUS_IS_OK(status)) {
- talloc_steal(mem_ctx, state->netlogon);
- io->out.netlogon = state->netlogon->out.netlogon;
- io->out.address = talloc_steal(mem_ctx, state->srv_addresses[state->srv_address_index]);
+ if (tevent_req_is_nterror(req, &status)) {
+ tevent_req_received(req);
+ return status;
}
+
+ talloc_steal(mem_ctx, state->netlogon);
+ io->out.netlogon = state->netlogon->out.netlogon;
+ io->out.address = talloc_steal(
+ mem_ctx, state->srv_addresses[state->srv_address_index]);
+
tevent_req_received(req);
- return status;
+ return NT_STATUS_OK;
}
NTSTATUS finddcs_cldap(TALLOC_CTX *mem_ctx,
--
1.7.0.4
>From 0455b8d4d766bad7ab540ee5dcd1a223e23b4b0d Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 30 Jul 2013 14:37:16 +0200
Subject: [PATCH 10/10] tevent: Fix tutorial reference
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/tevent/doc/tevent_request.dox | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/lib/tevent/doc/tevent_request.dox b/lib/tevent/doc/tevent_request.dox
index 3358cfb..7fcfb55 100644
--- a/lib/tevent/doc/tevent_request.dox
+++ b/lib/tevent/doc/tevent_request.dox
@@ -182,10 +182,8 @@ tevent_wakeup_recv() )
@image html tevent_subrequest.png
-Comprehensive example containing features from this chapter is especially by
-reason of nested subrequests very long and therefore it is located as an
-example on the attached CD. Description and explanation is placed within the
-source code itself (subrequest.c) and enclosed file README. The example is
-available <a href="subrequest_example.zip">here</a>.
+A comprehensive example of nested subrequests can be found in the file
+echo_server.c. It implements a complete, self-contained echo server with no
+dependencies but libevent and libtalloc.
*/
--
1.7.0.4
More information about the samba-technical
mailing list