[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Sun Dec 4 00:20:02 MST 2011


The branch, master has been updated
       via  6be10cb Revert fac5c654e2fe17c2c11d150b16088e8a51f6be20
       via  c8a1082 Move the callers that need to use the new cli_open() back to calling it from cli_openx().
       via  b44cfdf Add cli_open() back as a synchronous wrapper function the calls NtCreateX followed by openX() if NtCreateX is unsupported.
       via  4e709dc Rename cli_open -> cli_openx. Prelude to replacing generic cli_open() with a call that uses NTCreateX in preference to OpenAndX.
      from  c326b37 s4 dns: Test SOA queries

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 6be10cb7613d03c3b216a3d43a71622f769f7b05
Author: Jeremy Allison <jra at samba.org>
Date:   Sat Dec 3 21:44:14 2011 -0800

    Revert fac5c654e2fe17c2c11d150b16088e8a51f6be20
    
    s3: Add a fallback for missing open&x support in OS/X Lion
    
    This is now done inside the synchronous cli_open() wrapper
    function.
    
    Autobuild-User: Jeremy Allison <jra at samba.org>
    Autobuild-Date: Sun Dec  4 08:19:31 CET 2011 on sn-devel-104

commit c8a1082f2b4912647d8a28362c7fb3302bdce5c2
Author: Jeremy Allison <jra at samba.org>
Date:   Sat Dec 3 21:36:47 2011 -0800

    Move the callers that need to use the new cli_open() back to calling
    it from cli_openx().

commit b44cfdf163d5dc0d408a4d2d27854ebfa1e783e5
Author: Jeremy Allison <jra at samba.org>
Date:   Sat Dec 3 21:31:32 2011 -0800

    Add cli_open() back as a synchronous wrapper function the calls
    NtCreateX followed by openX() if NtCreateX is unsupported.

commit 4e709dc42fff464191f21dfa150a18a072d48569
Author: Jeremy Allison <jra at samba.org>
Date:   Sat Dec 3 21:13:08 2011 -0800

    Rename cli_open -> cli_openx. Prelude to replacing generic cli_open()
    with a call that uses NTCreateX in preference to OpenAndX.

-----------------------------------------------------------------------

Summary of changes:
 source3/client/client.c                 |  121 +---------------
 source3/client/client_proto.h           |    2 -
 source3/client/clitar.c                 |    4 +-
 source3/libgpo/gpo_filesync.c           |    2 +-
 source3/libsmb/clifile.c                |  236 ++++++++++++++++++++-----------
 source3/libsmb/proto.h                  |    7 +-
 source3/torture/denytest.c              |   12 +-
 source3/torture/locktest.c              |    4 +-
 source3/torture/locktest2.c             |    2 +-
 source3/torture/mangle_test.c           |    4 +-
 source3/torture/masktest.c              |    2 +-
 source3/torture/scanner.c               |    8 +-
 source3/torture/test_case_insensitive.c |    4 +-
 source3/torture/torture.c               |  174 +++++++++++-----------
 source3/torture/utable.c                |    2 +-
 15 files changed, 267 insertions(+), 317 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/client/client.c b/source3/client/client.c
index b355917..47d4470 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -301,121 +301,6 @@ static void send_message(const char *username)
 }
 
 /****************************************************************************
- Wrapper function around cli_open() that does an NtCreateX open by preference.
-****************************************************************************/
-
-NTSTATUS smbclient_cli_open(struct cli_state *cli, const char *fname, int flags,
-			int share_mode_in, uint16_t *pfnum)
-{
-	NTSTATUS status;
-	unsigned int openfn = 0;
-	unsigned int dos_deny = 0;
-	uint32_t access_mask, share_mode, create_disposition, create_options;
-
-	/* Do the initial mapping into OpenX parameters. */
-	if (flags & O_CREAT) {
-		openfn |= (1<<4);
-	}
-	if (!(flags & O_EXCL)) {
-		if (flags & O_TRUNC)
-			openfn |= (1<<1);
-		else
-			openfn |= (1<<0);
-	}
-
-	dos_deny = (share_mode_in<<4);
-
-	if ((flags & O_ACCMODE) == O_RDWR) {
-		dos_deny |= 2;
-	} else if ((flags & O_ACCMODE) == O_WRONLY) {
-		dos_deny |= 1;
-	}
-
-#if defined(O_SYNC)
-	if ((flags & O_SYNC) == O_SYNC) {
-		dos_deny |= (1<<14);
-	}
-#endif /* O_SYNC */
-
-	if (share_mode_in == DENY_FCB) {
-		dos_deny = 0xFF;
-	}
-
-#if 0
-	/* Hmmm. This is what I think the above code
-	   should look like if it's using the constants
-	   we #define. JRA. */
-
-	if (flags & O_CREAT) {
-		openfn |= OPENX_FILE_CREATE_IF_NOT_EXIST;
-	}
-	if (!(flags & O_EXCL)) {
-		if (flags & O_TRUNC)
-			openfn |= OPENX_FILE_EXISTS_TRUNCATE;
-		else
-			openfn |= OPENX_FILE_EXISTS_OPEN;
-	}
-
-	dos_deny = SET_DENY_MODE(share_mode_in);
-
-	if ((flags & O_ACCMODE) == O_RDWR) {
-		dos_deny |= DOS_OPEN_RDWR;
-	} else if ((flags & O_ACCMODE) == O_WRONLY) {
-		dos_deny |= DOS_OPEN_WRONLY;
-	}
-
-#if defined(O_SYNC)
-	if ((flags & O_SYNC) == O_SYNC) {
-		dos_deny |= FILE_SYNC_OPENMODE;
-	}
-#endif /* O_SYNC */
-
-	if (share_mode_in == DENY_FCB) {
-		dos_deny = 0xFF;
-	}
-#endif
-
-	if (!map_open_params_to_ntcreate(fname, dos_deny,
-					openfn, &access_mask,
-					&share_mode, &create_disposition,
-					&create_options, NULL)) {
-		goto try_openx;
-	}
-
-	status = cli_ntcreate(cli,
-				fname,
-				0,
-				access_mask,
-				0,
-				share_mode,
-				create_disposition,
-				create_options,
-				0,
-				pfnum);
-
-	/* Try and cope will all varients of "we don't do this call"
-	   and fall back to openX. */
-
-	if (NT_STATUS_EQUAL(status,NT_STATUS_NOT_IMPLEMENTED) ||
-			NT_STATUS_EQUAL(status,NT_STATUS_INVALID_INFO_CLASS) ||
-			NT_STATUS_EQUAL(status,NT_STATUS_PROCEDURE_NOT_FOUND) ||
-			NT_STATUS_EQUAL(status,NT_STATUS_INVALID_LEVEL) ||
-			NT_STATUS_EQUAL(status,NT_STATUS_INVALID_PARAMETER) ||
-			NT_STATUS_EQUAL(status,NT_STATUS_INVALID_DEVICE_REQUEST) ||
-			NT_STATUS_EQUAL(status,NT_STATUS_INVALID_DEVICE_STATE) ||
-			NT_STATUS_EQUAL(status,NT_STATUS_CTL_FILE_NOT_SUPPORTED) ||
-			NT_STATUS_EQUAL(status,NT_STATUS_UNSUCCESSFUL)) {
-		goto try_openx;
-	}
-
-	return status;
-
-  try_openx:
-
-	return cli_open(cli, fname, flags, share_mode_in, pfnum);
-}
-
-/****************************************************************************
  Check the space on a device.
 ****************************************************************************/
 
@@ -1212,7 +1097,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
 
 	clock_gettime_mono(&tp_start);
 
-	status = smbclient_cli_open(targetcli, targetname, O_RDONLY, DENY_NONE, &fnum);
+	status = cli_open(targetcli, targetname, O_RDONLY, DENY_NONE, &fnum);
 	if (!NT_STATUS_IS_OK(status)) {
 		d_printf("%s opening remote file %s\n", nt_errstr(status),
 			 rname);
@@ -1971,7 +1856,7 @@ static int do_put(const char *rname, const char *lname, bool reput)
 	clock_gettime_mono(&tp_start);
 
 	if (reput) {
-		status = smbclient_cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE, &fnum);
+		status = cli_open(targetcli, targetname, O_RDWR|O_CREAT, DENY_NONE, &fnum);
 		if (NT_STATUS_IS_OK(status)) {
 			if (!NT_STATUS_IS_OK(status = cli_qfileinfo_basic(
 						     targetcli, fnum, NULL,
@@ -1986,7 +1871,7 @@ static int do_put(const char *rname, const char *lname, bool reput)
 			}
 		}
 	} else {
-		status = smbclient_cli_open(targetcli, targetname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum);
+		status = cli_open(targetcli, targetname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum);
 	}
 
 	if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/client/client_proto.h b/source3/client/client_proto.h
index 3032e5b..d119014 100644
--- a/source3/client/client_proto.h
+++ b/source3/client/client_proto.h
@@ -30,8 +30,6 @@ struct file_info;
 
 const char *client_get_cur_dir(void);
 const char *client_set_cur_dir(const char *newdir);
-NTSTATUS smbclient_cli_open(struct cli_state *cli, const char *fname, int flags,
-			int share_mode_in, uint16_t *pfnum);
 NTSTATUS do_list(const char *mask,
 			uint16 attribute,
 			NTSTATUS (*fn)(struct cli_state *cli_state, struct file_info *,
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index d8890ea..5943926 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -655,7 +655,7 @@ static NTSTATUS do_atar(const char *rname_in, char *lname,
 		goto cleanup;
 	}
 
-	status = smbclient_cli_open(cli, rname, O_RDONLY, DENY_NONE, &fnum);
+	status = cli_open(cli, rname, O_RDONLY, DENY_NONE, &fnum);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0,("%s opening remote file %s (%s)\n",
 				nt_errstr(status),rname, client_get_cur_dir()));
@@ -1016,7 +1016,7 @@ static int get_file(file_info2 finfo)
 		return False;
 	}
 
-	status = smbclient_cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum);
+	status = cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(0, ("abandoning restore\n"));
 		return False;
diff --git a/source3/libgpo/gpo_filesync.c b/source3/libgpo/gpo_filesync.c
index ead9261..7f0e410 100644
--- a/source3/libgpo/gpo_filesync.c
+++ b/source3/libgpo/gpo_filesync.c
@@ -50,7 +50,7 @@ NTSTATUS gpo_copy_file(TALLOC_CTX *mem_ctx,
 	int read_size = io_bufsize;
 	off_t nread = 0;
 
-	result = cli_open(cli, nt_path, O_RDONLY, DENY_NONE, &fnum);
+	result = cli_openx(cli, nt_path, O_RDONLY, DENY_NONE, &fnum);
 	if (!NT_STATUS_IS_OK(result)) {
 		goto out;
 	}
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index ec83956..168dd4b 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -2111,84 +2111,81 @@ NTSTATUS cli_nttrans_create(struct cli_state *cli,
  WARNING: if you open with O_WRONLY then getattrE won't work!
 ****************************************************************************/
 
-struct cli_open_state {
-	struct tevent_context *ev;
-	struct cli_state *cli;
+struct cli_openx_state {
 	const char *fname;
 	uint16_t vwv[15];
 	uint16_t fnum;
-	unsigned openfn;
-	unsigned dos_deny;
-	uint8_t additional_flags;
 	struct iovec bytes;
 };
 
-static void cli_open_done(struct tevent_req *subreq);
-static void cli_open_ntcreate_done(struct tevent_req *subreq);
+static void cli_openx_done(struct tevent_req *subreq);
 
-struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
+struct tevent_req *cli_openx_create(TALLOC_CTX *mem_ctx,
 				   struct event_context *ev,
 				   struct cli_state *cli, const char *fname,
 				   int flags, int share_mode,
 				   struct tevent_req **psmbreq)
 {
 	struct tevent_req *req, *subreq;
-	struct cli_open_state *state;
+	struct cli_openx_state *state;
+	unsigned openfn;
+	unsigned accessmode;
+	uint8_t additional_flags;
 	uint8_t *bytes;
 
-	req = tevent_req_create(mem_ctx, &state, struct cli_open_state);
+	req = tevent_req_create(mem_ctx, &state, struct cli_openx_state);
 	if (req == NULL) {
 		return NULL;
 	}
-	state->ev = ev;
-	state->cli = cli;
-	state->fname = fname;
 
+	openfn = 0;
 	if (flags & O_CREAT) {
-		state->openfn |= (1<<4);
+		openfn |= (1<<4);
 	}
 	if (!(flags & O_EXCL)) {
 		if (flags & O_TRUNC)
-			state->openfn |= (1<<1);
+			openfn |= (1<<1);
 		else
-			state->openfn |= (1<<0);
+			openfn |= (1<<0);
 	}
 
-	state->dos_deny = (share_mode<<4);
+	accessmode = (share_mode<<4);
 
 	if ((flags & O_ACCMODE) == O_RDWR) {
-		state->dos_deny |= 2;
+		accessmode |= 2;
 	} else if ((flags & O_ACCMODE) == O_WRONLY) {
-		state->dos_deny |= 1;
+		accessmode |= 1;
 	}
 
 #if defined(O_SYNC)
 	if ((flags & O_SYNC) == O_SYNC) {
-		state->dos_deny |= (1<<14);
+		accessmode |= (1<<14);
 	}
 #endif /* O_SYNC */
 
 	if (share_mode == DENY_FCB) {
-		state->dos_deny = 0xFF;
+		accessmode = 0xFF;
 	}
 
 	SCVAL(state->vwv + 0, 0, 0xFF);
 	SCVAL(state->vwv + 0, 1, 0);
 	SSVAL(state->vwv + 1, 0, 0);
 	SSVAL(state->vwv + 2, 0, 0);  /* no additional info */
-	SSVAL(state->vwv + 3, 0, state->dos_deny);
+	SSVAL(state->vwv + 3, 0, accessmode);
 	SSVAL(state->vwv + 4, 0, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
 	SSVAL(state->vwv + 5, 0, 0);
 	SIVAL(state->vwv + 6, 0, 0);
-	SSVAL(state->vwv + 8, 0, state->openfn);
+	SSVAL(state->vwv + 8, 0, openfn);
 	SIVAL(state->vwv + 9, 0, 0);
 	SIVAL(state->vwv + 11, 0, 0);
 	SIVAL(state->vwv + 13, 0, 0);
 
+	additional_flags = 0;
+
 	if (cli->use_oplocks) {
 		/* if using oplocks then ask for a batch oplock via
                    core and extended methods */
-		state->additional_flags =
+		additional_flags =
 			FLAG_REQUEST_OPLOCK|FLAG_REQUEST_BATCH_OPLOCK;
 		SSVAL(state->vwv+2, 0, SVAL(state->vwv+2, 0) | 6);
 	}
@@ -2204,26 +2201,25 @@ struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
 	state->bytes.iov_base = (void *)bytes;
 	state->bytes.iov_len = talloc_get_size(bytes);
 
-	subreq = cli_smb_req_create(state, ev, cli, SMBopenX,
-				    state->additional_flags,
+	subreq = cli_smb_req_create(state, ev, cli, SMBopenX, additional_flags,
 				    15, state->vwv, 1, &state->bytes);
 	if (subreq == NULL) {
 		TALLOC_FREE(req);
 		return NULL;
 	}
-	tevent_req_set_callback(subreq, cli_open_done, req);
+	tevent_req_set_callback(subreq, cli_openx_done, req);
 	*psmbreq = subreq;
 	return req;
 }
 
-struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+struct tevent_req *cli_openx_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
 				 struct cli_state *cli, const char *fname,
 				 int flags, int share_mode)
 {
 	struct tevent_req *req, *subreq;
 	NTSTATUS status;
 
-	req = cli_open_create(mem_ctx, ev, cli, fname, flags, share_mode,
+	req = cli_openx_create(mem_ctx, ev, cli, fname, flags, share_mode,
 			      &subreq);
 	if (req == NULL) {
 		return NULL;
@@ -2236,76 +2232,31 @@ struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
 	return req;
 }
 
-static void cli_open_done(struct tevent_req *subreq)
+static void cli_openx_done(struct tevent_req *subreq)
 {
 	struct tevent_req *req = tevent_req_callback_data(
 		subreq, struct tevent_req);
-	struct cli_open_state *state = tevent_req_data(
-		req, struct cli_open_state);
+	struct cli_openx_state *state = tevent_req_data(
+		req, struct cli_openx_state);
 	uint8_t wct;
 	uint16_t *vwv;
 	uint8_t *inbuf;
 	NTSTATUS status;
-	uint32_t access_mask, share_mode, create_disposition, create_options;
 
 	status = cli_smb_recv(subreq, state, &inbuf, 3, &wct, &vwv, NULL,
 			      NULL);
 	TALLOC_FREE(subreq);
-
-	if (NT_STATUS_IS_OK(status)) {
-		state->fnum = SVAL(vwv+2, 0);
-		tevent_req_done(req);
-		return;
-	}
-
-	if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
-		tevent_req_nterror(req, status);
-		return;
-	}
-
-	/*
-	 * For the new shiny OS/X Lion SMB server, try a ntcreate
-	 * fallback.
-	 */
-
-	if (!map_open_params_to_ntcreate(state->fname, state->dos_deny,
-					 state->openfn, &access_mask,
-					 &share_mode, &create_disposition,
-					 &create_options, NULL)) {
-		tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
-		return;
-	}
-
-	subreq = cli_ntcreate_send(state, state->ev, state->cli,
-				   state->fname, 0, access_mask,
-				   0, share_mode, create_disposition,
-				   create_options, 0);
-	if (tevent_req_nomem(subreq, req)) {
-		return;
-	}
-	tevent_req_set_callback(subreq, cli_open_ntcreate_done, req);
-}
-
-static void cli_open_ntcreate_done(struct tevent_req *subreq)
-{
-	struct tevent_req *req = tevent_req_callback_data(
-		subreq, struct tevent_req);
-	struct cli_open_state *state = tevent_req_data(
-		req, struct cli_open_state);
-	NTSTATUS status;
-
-	status = cli_ntcreate_recv(subreq, &state->fnum);
-	TALLOC_FREE(subreq);
 	if (tevent_req_nterror(req, status)) {
 		return;
 	}
+	state->fnum = SVAL(vwv+2, 0);
 	tevent_req_done(req);
 }
 
-NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *pfnum)
+NTSTATUS cli_openx_recv(struct tevent_req *req, uint16_t *pfnum)
 {
-	struct cli_open_state *state = tevent_req_data(
-		req, struct cli_open_state);
+	struct cli_openx_state *state = tevent_req_data(
+		req, struct cli_openx_state);
 	NTSTATUS status;
 
 	if (tevent_req_is_nterror(req, &status)) {
@@ -2315,7 +2266,7 @@ NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *pfnum)
 	return NT_STATUS_OK;
 }
 
-NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags,
+NTSTATUS cli_openx(struct cli_state *cli, const char *fname, int flags,
 	     int share_mode, uint16_t *pfnum)
 {
 	TALLOC_CTX *frame = talloc_stackframe();
@@ -2337,7 +2288,7 @@ NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags,
 		goto fail;
 	}
 
-	req = cli_open_send(frame, ev, cli, fname, flags, share_mode);
+	req = cli_openx_send(frame, ev, cli, fname, flags, share_mode);
 	if (req == NULL) {
 		status = NT_STATUS_NO_MEMORY;
 		goto fail;
@@ -2348,11 +2299,126 @@ NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags,
 		goto fail;
 	}
 
-	status = cli_open_recv(req, pfnum);
+	status = cli_openx_recv(req, pfnum);
  fail:
 	TALLOC_FREE(frame);
 	return status;
 }
+/****************************************************************************
+ Synchronous wrapper function that does an NtCreateX open by preference
+ and falls back to openX if this fails.
+****************************************************************************/
+
+NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags,
+			int share_mode_in, uint16_t *pfnum)
+{
+	NTSTATUS status;
+	unsigned int openfn = 0;
+	unsigned int dos_deny = 0;
+	uint32_t access_mask, share_mode, create_disposition, create_options;
+
+	/* Do the initial mapping into OpenX parameters. */
+	if (flags & O_CREAT) {
+		openfn |= (1<<4);
+	}
+	if (!(flags & O_EXCL)) {
+		if (flags & O_TRUNC)
+			openfn |= (1<<1);
+		else
+			openfn |= (1<<0);
+	}
+
+	dos_deny = (share_mode_in<<4);
+
+	if ((flags & O_ACCMODE) == O_RDWR) {
+		dos_deny |= 2;
+	} else if ((flags & O_ACCMODE) == O_WRONLY) {
+		dos_deny |= 1;
+	}
+
+#if defined(O_SYNC)
+	if ((flags & O_SYNC) == O_SYNC) {
+		dos_deny |= (1<<14);
+	}
+#endif /* O_SYNC */
+
+	if (share_mode_in == DENY_FCB) {
+		dos_deny = 0xFF;
+	}
+
+#if 0
+	/* Hmmm. This is what I think the above code
+	   should look like if it's using the constants


-- 
Samba Shared Repository


More information about the samba-cvs mailing list