[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Sat May 28 03:48:02 MDT 2011
The branch, master has been updated
via 9e05d34 s3: Fix a tiny memleak in copy_unix_token
via 77ce431 s3: Use talloc_memdup in copy_unix_token
via 4586f51 s3: Fix some nonempty blank lines
via 1c11186 s3: Use cli_connect_nb in cli_start_connection
via defcd40 s3: Add cli_connect_nb
from 51b43a4 packaging(RHEL-CTDB): align configure.rpm to the spec file
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 9e05d3430fedde70fcb1f6a1121c2cb67e4ce0f0
Author: Volker Lendecke <vl at samba.org>
Date: Sat May 28 10:39:25 2011 +0200
s3: Fix a tiny memleak in copy_unix_token
Autobuild-User: Volker Lendecke <vlendec at samba.org>
Autobuild-Date: Sat May 28 11:47:11 CEST 2011 on sn-devel-104
commit 77ce431fdbd9f85f44c9bd8812e275a0b0e73f5d
Author: Volker Lendecke <vl at samba.org>
Date: Sat May 28 10:38:52 2011 +0200
s3: Use talloc_memdup in copy_unix_token
commit 4586f5176bab04f7e003a3e93e4d62a512e8c047
Author: Volker Lendecke <vl at samba.org>
Date: Sat May 28 10:24:20 2011 +0200
s3: Fix some nonempty blank lines
commit 1c11186837e33a1b57ea3346d4034a180cc654cb
Author: Volker Lendecke <vl at samba.org>
Date: Thu May 26 22:02:28 2011 +0200
s3: Use cli_connect_nb in cli_start_connection
commit defcd409a38e0c9c624424a47becb45cb792ce76
Author: Volker Lendecke <vl at samba.org>
Date: Thu May 26 22:00:07 2011 +0200
s3: Add cli_connect_nb
This builds up a cli_state until after the netbios session setup. It makes use
of smbsock_connect, so it connects to 139 and 445 simultaneously. This improves
the connection to Windows 2008 which does not listen on *SMBSERVER anymore.
-----------------------------------------------------------------------
Summary of changes:
source3/libsmb/cliconnect.c | 184 ++++++++++++++++++++++++++++++++-----------
source3/libsmb/proto.h | 3 +
source3/locking/brlock.c | 12 ++--
source3/locking/locking.c | 27 +++---
4 files changed, 160 insertions(+), 66 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index a4a3c11..9ee3b79 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -3079,6 +3079,139 @@ NTSTATUS cli_connect(struct cli_state *cli,
return NT_STATUS_OK;
}
+static NTSTATUS cli_connect_sock(const char *host, int name_type,
+ const struct sockaddr_storage *pss,
+ const char *myname, uint16_t port,
+ int sec_timeout, int *pfd, uint16_t *pport)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ const char *prog;
+ unsigned int i, num_addrs;
+ const char **called_names;
+ const char **calling_names;
+ int *called_types;
+ NTSTATUS status;
+ int fd;
+
+ prog = getenv("LIBSMB_PROG");
+ if (prog != NULL) {
+ fd = sock_exec(prog);
+ if (fd == -1) {
+ return map_nt_error_from_unix(errno);
+ }
+ port = 0;
+ goto done;
+ }
+
+ if ((pss == NULL) || is_zero_addr(pss)) {
+ struct sockaddr_storage *addrs;
+ status = resolve_name_list(talloc_tos(), host, name_type,
+ &addrs, &num_addrs);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+ pss = addrs;
+ } else {
+ num_addrs = 1;
+ }
+
+ called_names = talloc_array(talloc_tos(), const char *, num_addrs);
+ if (called_names == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
+ }
+ called_types = talloc_array(talloc_tos(), int, num_addrs);
+ if (called_types == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
+ }
+ calling_names = talloc_array(talloc_tos(), const char *, num_addrs);
+ if (calling_names == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
+ }
+ for (i=0; i<num_addrs; i++) {
+ called_names[i] = host;
+ called_types[i] = name_type;
+ calling_names[i] = myname;
+ }
+ status = smbsock_any_connect(pss, called_names, called_types,
+ calling_names, NULL, num_addrs, port,
+ sec_timeout, &fd, NULL, &port);
+ if (!NT_STATUS_IS_OK(status)) {
+ goto fail;
+ }
+done:
+ *pfd = fd;
+ *pport = port;
+ status = NT_STATUS_OK;
+fail:
+ TALLOC_FREE(frame);
+ return status;
+}
+
+NTSTATUS cli_connect_nb(const char *host, struct sockaddr_storage *pss,
+ uint16_t port, const char *myname,
+ int signing_state, struct cli_state **pcli)
+{
+ TALLOC_CTX *frame = talloc_stackframe();
+ struct cli_state *cli;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+ int name_type = 0x20;
+ int fd = -1;
+ char *desthost;
+ char *p;
+ socklen_t length;
+ int ret;
+
+ desthost = talloc_strdup(talloc_tos(), host);
+ if (desthost == NULL) {
+ goto fail;
+ }
+
+ p = strchr(host, '#');
+ if (p != NULL) {
+ name_type = strtol(p+1, NULL, 16);
+ host = talloc_strndup(talloc_tos(), host, p - host);
+ if (host == NULL) {
+ goto fail;
+ }
+ }
+
+ cli = cli_initialise_ex(signing_state);
+ if (cli == NULL) {
+ goto fail;
+ }
+ cli->desthost = talloc_move(cli, &desthost);
+
+ status = cli_connect_sock(host, name_type, pss, myname, port, 20, &fd,
+ &port);
+ if (!NT_STATUS_IS_OK(status)) {
+ cli_shutdown(cli);
+ goto fail;
+ }
+ cli->fd = fd;
+ cli->port = port;
+
+ length = sizeof(cli->dest_ss);
+ ret = getpeername(fd, (struct sockaddr *)&cli->dest_ss, &length);
+ if (ret == -1) {
+ status = map_nt_error_from_unix(errno);
+ cli_shutdown(cli);
+ goto fail;
+ }
+
+ if (pss != NULL) {
+ *pss = cli->dest_ss;
+ }
+
+ *pcli = cli;
+ status = NT_STATUS_OK;
+fail:
+ TALLOC_FREE(frame);
+ return status;
+}
+
/**
establishes a connection to after the negprot.
@param output_cli A fully initialised cli structure, non-null only on success
@@ -3093,59 +3226,16 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli,
int signing_state, int flags)
{
NTSTATUS nt_status;
- struct nmb_name calling;
- struct nmb_name called;
struct cli_state *cli;
- struct sockaddr_storage ss;
-
- if (!my_name)
- my_name = global_myname();
-
- if (!(cli = cli_initialise_ex(signing_state))) {
- return NT_STATUS_NO_MEMORY;
- }
-
- make_nmb_name(&calling, my_name, 0x0);
- make_nmb_name(&called , dest_host, 0x20);
-
- cli_set_port(cli, port);
- cli_set_timeout(cli, 10000); /* 10 seconds. */
-
- if (dest_ss) {
- ss = *dest_ss;
- } else {
- zero_sockaddr(&ss);
- }
-again:
-
- DEBUG(3,("Connecting to host=%s\n", dest_host));
-
- nt_status = cli_connect(cli, dest_host, &ss);
+ nt_status = cli_connect_nb(dest_host, dest_ss, port, my_name,
+ signing_state, &cli);
if (!NT_STATUS_IS_OK(nt_status)) {
- char addr[INET6_ADDRSTRLEN];
- print_sockaddr(addr, sizeof(addr), &ss);
- DEBUG(1,("cli_start_connection: failed to connect to %s (%s). Error %s\n",
- nmb_namestr(&called), addr, nt_errstr(nt_status) ));
- cli_shutdown(cli);
+ DEBUG(10, ("cli_connect_nb failed: %s\n",
+ nt_errstr(nt_status)));
return nt_status;
}
- if (!cli_session_request(cli, &calling, &called)) {
- char *p;
- DEBUG(1,("session request to %s failed (%s)\n",
- called.name, cli_errstr(cli)));
- if ((p=strchr(called.name, '.')) && !is_ipaddress(called.name)) {
- *p = 0;
- goto again;
- }
- if (strcmp(called.name, STAR_SMBSERVER)) {
- make_nmb_name(&called , STAR_SMBSERVER, 0x20);
- goto again;
- }
- return NT_STATUS_BAD_NETWORK_NAME;
- }
-
if (flags & CLI_FULL_CONNECTION_DONT_SPNEGO)
cli->use_spnego = False;
else if (flags & CLI_FULL_CONNECTION_USE_KERBEROS)
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 213b811..3a34486 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -73,6 +73,9 @@ bool cli_session_request(struct cli_state *cli,
NTSTATUS cli_connect(struct cli_state *cli,
const char *host,
struct sockaddr_storage *dest_ss);
+NTSTATUS cli_connect_nb(const char *host, struct sockaddr_storage *pss,
+ uint16_t port, const char *myname,
+ int signing_state, struct cli_state **pcli);
NTSTATUS cli_start_connection(struct cli_state **output_cli,
const char *my_name,
const char *dest_host,
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index fd3bf23..220688c 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -5,17 +5,17 @@
Copyright (C) Andrew Tridgell 1992-2000
Copyright (C) Jeremy Allison 1992-2000
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -52,7 +52,7 @@ static void print_lock_struct(unsigned int i, struct lock_struct *pls)
(unsigned long long)pls->context.smblctx,
(unsigned int)pls->context.tid,
procid_str(talloc_tos(), &pls->context.pid) ));
-
+
DEBUG(10,("start = %.0f, size = %.0f, fnum = %d, %s %s\n",
(double)pls->start,
(double)pls->size,
@@ -180,7 +180,7 @@ static bool brl_conflict1(const struct lock_struct *lck1,
lck2->start >= (lck1->start + lck1->size)) {
return False;
}
-
+
return True;
}
#endif
@@ -1881,7 +1881,7 @@ static struct byte_range_lock *brl_get_locks_internal(TALLOC_CTX *mem_ctx,
memcpy(br_lck->lock_data, data.dptr, data.dsize);
}
-
+
if (!fsp->lockdb_clean) {
int orig_num_locks = br_lck->num_locks;
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index 9bb3b9c..a4561f5 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -4,17 +4,17 @@
Copyright (C) Andrew Tridgell 1992-2000
Copyright (C) Jeremy Allison 1992-2006
Copyright (C) Volker Lendecke 2005
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
@@ -310,15 +310,15 @@ NTSTATUS do_unlock(struct messaging_context *msg_ctx,
{
bool ok = False;
struct byte_range_lock *br_lck = NULL;
-
+
if (!fsp->can_lock) {
return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE;
}
-
+
if (!lp_locking(fsp->conn->params)) {
return NT_STATUS_OK;
}
-
+
DEBUG(10,("do_unlock: unlock start=%.0f len=%.0f requested for fnum %d file %s\n",
(double)offset, (double)count, fsp->fnum,
fsp_str_dbg(fsp)));
@@ -335,7 +335,7 @@ NTSTATUS do_unlock(struct messaging_context *msg_ctx,
offset,
count,
lock_flav);
-
+
TALLOC_FREE(br_lck);
if (!ok) {
@@ -365,7 +365,7 @@ NTSTATUS do_lock_cancel(files_struct *fsp,
return fsp->is_directory ?
NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE;
}
-
+
if (!lp_locking(fsp->conn->params)) {
return NT_STATUS_DOS(ERRDOS, ERRcancelviolation);
}
@@ -672,7 +672,7 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
}
lck->share_modes = NULL;
-
+
if (lck->num_share_modes != 0) {
if (dbuf.dsize < (sizeof(struct locking_data) +
@@ -680,7 +680,7 @@ static bool parse_share_modes(const TDB_DATA dbuf, struct share_mode_lock *lck)
sizeof(struct share_mode_entry)))) {
smb_panic("parse_share_modes: buffer too short");
}
-
+
lck->share_modes = (struct share_mode_entry *)
TALLOC_MEMDUP(lck,
dbuf.dptr+sizeof(struct locking_data),
@@ -1493,11 +1493,12 @@ static struct security_unix_token *copy_unix_token(TALLOC_CTX *ctx, const struct
cpy->ngroups = tok->ngroups;
if (tok->ngroups) {
/* Make this a talloc child of cpy. */
- cpy->groups = TALLOC_ARRAY(cpy, gid_t, tok->ngroups);
+ cpy->groups = (gid_t *)talloc_memdup(
+ cpy, tok->groups, tok->ngroups * sizeof(gid_t));
if (!cpy->groups) {
+ TALLOC_FREE(cpy);
return NULL;
}
- memcpy(cpy->groups, tok->groups, tok->ngroups * sizeof(gid_t));
}
return cpy;
}
@@ -1582,7 +1583,7 @@ void set_delete_on_close_lck(files_struct *fsp,
bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const struct security_unix_token *tok)
{
struct share_mode_lock *lck;
-
+
DEBUG(10,("set_delete_on_close: %s delete on close flag for "
"fnum = %d, file %s\n",
delete_on_close ? "Adding" : "Removing", fsp->fnum,
--
Samba Shared Repository
More information about the samba-cvs
mailing list