[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-2404-g3426748

Jeremy Allison jra at samba.org
Thu Jun 18 20:16:06 GMT 2009


The branch, master has been updated
       via  34267482d53cb559cc40c4ec2bee929c21b7886b (commit)
      from  e7e98ba4807f3c4e0538b24ae0092f69383ae2d7 (commit)

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


- Log -----------------------------------------------------------------
commit 34267482d53cb559cc40c4ec2bee929c21b7886b
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jun 18 13:13:38 2009 -0700

    Replace the boilerplate calls to :
    resolve_dfspath() -> unix_convert() -> get_full_smb_filename() -> check_name()
    with a new function filename_convert().
    This restores the check_name() calls that had gone missing
    since the default create_file was changed. All "standard"
    pathname processing now goes through filename_convert().
    I'll take a look at the non-standard pathname processing
    next. As a benefit, fixed a missing resolve_dfspath()
    in the trans2 mkdir call.
    Jeremy.

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

Summary of changes:
 source3/include/proto.h    |   10 ++-
 source3/smbd/filename.c    |   52 ++++++++++++++
 source3/smbd/nttrans.c     |   30 +++-----
 source3/smbd/reply.c       |  168 +++++++++----------------------------------
 source3/smbd/smb2_create.c |   10 +--
 source3/smbd/trans2.c      |  154 ++++++++++++----------------------------
 6 files changed, 154 insertions(+), 270 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 4ae141e..6fc2825 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6384,6 +6384,12 @@ NTSTATUS check_name(connection_struct *conn, const char *name);
 int get_real_filename(connection_struct *conn, const char *path,
 		      const char *name, TALLOC_CTX *mem_ctx,
 		      char **found_name);
+NTSTATUS filename_convert(TALLOC_CTX *mem_ctx,
+			connection_struct *conn,
+			bool dfs_path,
+			const char *name_in,
+			struct smb_filename **pp_smb_fname,
+			char **pp_name);
 
 /* The following definitions come from smbd/files.c  */
 
@@ -7078,8 +7084,8 @@ void send_trans2_replies(connection_struct *conn,
 unsigned char *create_volume_objectid(connection_struct *conn, unsigned char objid[16]);
 NTSTATUS hardlink_internals(TALLOC_CTX *ctx,
 		connection_struct *conn,
-		const char *oldname_in,
-		const char *newname_in);
+		const struct smb_filename *smb_fname_old,
+		const struct smb_filename *smb_fname_new);
 NTSTATUS smb_set_file_time(connection_struct *conn,
 			   files_struct *fsp,
 			   const char *fname,
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 456caf5..e1e5454 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -1150,3 +1150,55 @@ static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,
 	TALLOC_FREE(streams);
 	return status;
 }
+
+/****************************************************************************
+ Go through all the steps to validate a filename.
+****************************************************************************/
+
+NTSTATUS filename_convert(TALLOC_CTX *ctx,
+				connection_struct *conn,
+				bool dfs_path,
+				const char *name_in,
+				struct smb_filename **pp_smb_fname,
+				char **pp_name)
+{
+	NTSTATUS status;
+
+	*pp_smb_fname = NULL;
+	*pp_name = NULL;
+
+	status = resolve_dfspath(ctx, conn,
+				dfs_path,
+				name_in,
+				pp_name);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(10,("filename_convert: resolve_dfspath failed "
+			"for name %s with %s\n",
+			name_in,
+			nt_errstr(status) ));
+		return status;
+	}
+	status = unix_convert(ctx, conn, *pp_name, pp_smb_fname, 0);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(10,("filename_convert: unix_convert failed "
+			"for name %s with %s\n",
+			*pp_name,
+			nt_errstr(status) ));
+		return status;
+	}
+
+	status = get_full_smb_filename(ctx, *pp_smb_fname, pp_name);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
+
+	status = check_name(conn, *pp_name);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(3,("filename_convert: check_name failed "
+			"for name %s with %s\n",
+			*pp_name,
+			nt_errstr(status) ));
+		return status;
+	}
+	return status;
+}
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index c4d0374..73c062e 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -535,10 +535,11 @@ void reply_ntcreate_and_X(struct smb_request *req)
 			? BATCH_OPLOCK : 0;
 	}
 
-	status = resolve_dfspath(ctx,
+	status = filename_convert(ctx,
 				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
 				fname,
+				&smb_fname,
 				&fname);
 
 	if (!NT_STATUS_IS_OK(status)) {
@@ -552,12 +553,6 @@ void reply_ntcreate_and_X(struct smb_request *req)
 		goto out;
 	}
 
-	status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
 	status = SMB_VFS_CREATE_FILE(
 		conn,					/* conn */
 		req,					/* req */
@@ -1021,10 +1016,11 @@ static void call_nt_transact_create(connection_struct *conn,
 		goto out;
 	}
 
-	status = resolve_dfspath(ctx,
+	status = filename_convert(ctx,
 				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
 				fname,
+				&smb_fname,
 				&fname);
 
 	if (!NT_STATUS_IS_OK(status)) {
@@ -1038,12 +1034,6 @@ static void call_nt_transact_create(connection_struct *conn,
 		goto out;
 	}
 
-	status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
 	oplock_request = (flags & REQUEST_OPLOCK) ? EXCLUSIVE_OPLOCK : 0;
 	if (oplock_request) {
 		oplock_request |= (flags & REQUEST_BATCH_OPLOCK)
@@ -1399,6 +1389,8 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
 void reply_ntrename(struct smb_request *req)
 {
 	connection_struct *conn = req->conn;
+	struct smb_filename *smb_fname_old = NULL;
+	struct smb_filename *smb_fname_new = NULL;
 	char *oldname = NULL;
 	char *newname = NULL;
 	const char *p;
@@ -1444,9 +1436,10 @@ void reply_ntrename(struct smb_request *req)
 		return;
 	}
 
-	status = resolve_dfspath(ctx, conn,
+	status = filename_convert(ctx, conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
 				oldname,
+				&smb_fname_old,
 				&oldname);
 	if (!NT_STATUS_IS_OK(status)) {
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
@@ -1460,9 +1453,10 @@ void reply_ntrename(struct smb_request *req)
 		return;
 	}
 
-	status = resolve_dfspath(ctx, conn,
+	status = filename_convert(ctx, conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
 				newname,
+				&smb_fname_new,
 				&newname);
 	if (!NT_STATUS_IS_OK(status)) {
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
@@ -1498,8 +1492,8 @@ void reply_ntrename(struct smb_request *req)
 			} else {
 				status = hardlink_internals(ctx,
 						conn,
-						oldname,
-						newname);
+						smb_fname_old,
+						smb_fname_new);
 			}
 			break;
 		case RENAME_FLAG_COPY:
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 996cba2..f11f3bf 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -987,10 +987,15 @@ void reply_checkpath(struct smb_request *req)
 		return;
 	}
 
-	status = resolve_dfspath(ctx, conn,
-			req->flags2 & FLAGS2_DFS_PATHNAMES,
-			name,
-			&name);
+	DEBUG(3,("reply_checkpath %s mode=%d\n", name, (int)SVAL(req->vwv+0, 0)));
+
+	status = filename_convert(ctx,
+				conn,
+				req->flags2 & FLAGS2_DFS_PATHNAMES,
+				name,
+				&smb_fname,
+				&name);
+
 	if (!NT_STATUS_IS_OK(status)) {
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
 			reply_botherror(req, NT_STATUS_PATH_NOT_COVERED,
@@ -1001,24 +1006,6 @@ void reply_checkpath(struct smb_request *req)
 		goto path_err;
 	}
 
-	DEBUG(3,("reply_checkpath %s mode=%d\n", name, (int)SVAL(req->vwv+0, 0)));
-
-	status = unix_convert(ctx, conn, name, &smb_fname, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		goto path_err;
-	}
-
-	status = get_full_smb_filename(ctx, smb_fname, &name);
-	if (!NT_STATUS_IS_OK(status)) {
-		goto path_err;
-	}
-
-	status = check_name(conn, name);
-	if (!NT_STATUS_IS_OK(status)) {
-		DEBUG(3,("reply_checkpath: check_name of %s failed (%s)\n",name,nt_errstr(status)));
-		goto path_err;
-	}
-
 	if (!VALID_STAT(smb_fname->st) &&
 	    (SMB_VFS_STAT(conn, name, &smb_fname->st) != 0)) {
 		DEBUG(3,("reply_checkpath: stat of %s failed (%s)\n",name,strerror(errno)));
@@ -1091,20 +1078,6 @@ void reply_getatr(struct smb_request *req)
 		goto out;
 	}
 
-	status = resolve_dfspath(ctx, conn,
-				req->flags2 & FLAGS2_DFS_PATHNAMES,
-				fname,
-				&fname);
-	if (!NT_STATUS_IS_OK(status)) {
-		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
-			reply_botherror(req, NT_STATUS_PATH_NOT_COVERED,
-					ERRSRV, ERRbadpath);
-			goto out;
-		}
-		reply_nterror(req, status);
-		goto out;
-	}
-
 	/* dos smetimes asks for a stat of "" - it returns a "hidden directory"
 		under WfWg - weird! */
 	if (*fname == '\0') {
@@ -1115,19 +1088,18 @@ void reply_getatr(struct smb_request *req)
 		size = 0;
 		mtime = 0;
 	} else {
-		status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-		if (!NT_STATUS_IS_OK(status)) {
-			reply_nterror(req, status);
-			goto out;
-		}
-		status = get_full_smb_filename(ctx, smb_fname, &fname);
-		if (!NT_STATUS_IS_OK(status)) {
-			reply_nterror(req, status);
-			goto out;
-		}
-		status = check_name(conn, fname);
+		status = filename_convert(ctx,
+				conn,
+				req->flags2 & FLAGS2_DFS_PATHNAMES,
+				fname,
+				&smb_fname,
+				&fname);
 		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(3,("reply_getatr: check_name of %s failed (%s)\n",fname,nt_errstr(status)));
+			if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
+				reply_botherror(req, NT_STATUS_PATH_NOT_COVERED,
+						ERRSRV, ERRbadpath);
+				goto out;
+			}
 			reply_nterror(req, status);
 			goto out;
 		}
@@ -1201,9 +1173,11 @@ void reply_setatr(struct smb_request *req)
 		goto out;
 	}
 
-	status = resolve_dfspath(ctx, conn,
+	status = filename_convert(ctx,
+				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
 				fname,
+				&smb_fname,
 				&fname);
 	if (!NT_STATUS_IS_OK(status)) {
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
@@ -1215,24 +1189,6 @@ void reply_setatr(struct smb_request *req)
 		goto out;
 	}
 
-	status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
-	status = get_full_smb_filename(ctx, smb_fname, &fname);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
-	status = check_name(conn, fname);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
 	if (fname[0] == '.' && fname[1] == '\0') {
 		/*
 		 * Not sure here is the right place to catch this
@@ -1769,10 +1725,11 @@ void reply_open(struct smb_request *req)
 		goto out;
 	}
 
-	status = resolve_dfspath(ctx,
+	status = filename_convert(ctx,
 				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
 				fname,
+				&smb_fname,
 				&fname);
 	if (!NT_STATUS_IS_OK(status)) {
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
@@ -1785,12 +1742,6 @@ void reply_open(struct smb_request *req)
 		goto out;
 	}
 
-	status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
 	if (!map_open_params_to_ntcreate(
 		    fname, deny_mode, OPENX_FILE_EXISTS_OPEN, &access_mask,
 		    &share_mode, &create_disposition, &create_options)) {
@@ -1930,10 +1881,11 @@ void reply_open_and_X(struct smb_request *req)
 		goto out;
 	}
 
-	status = resolve_dfspath(ctx,
+	status = filename_convert(ctx,
 				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
 				fname,
+				&smb_fname,
 				&fname);
 	if (!NT_STATUS_IS_OK(status)) {
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
@@ -1946,12 +1898,6 @@ void reply_open_and_X(struct smb_request *req)
 		goto out;
 	}
 
-	status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
 	if (!map_open_params_to_ntcreate(
 		    fname, deny_mode, smb_ofun, &access_mask,
 		    &share_mode, &create_disposition, &create_options)) {
@@ -2143,10 +2089,11 @@ void reply_mknew(struct smb_request *req)
 		goto out;
 	}
 
-	status = resolve_dfspath(ctx,
+	status = filename_convert(ctx,
 				conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
 				fname,
+				&smb_fname,
 				&fname);
 	if (!NT_STATUS_IS_OK(status)) {
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
@@ -2159,12 +2106,6 @@ void reply_mknew(struct smb_request *req)
 		goto out;
 	}
 
-	status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
 	if (fattr & aVOLID) {
 		DEBUG(0,("Attempt to create file (%s) with volid set - "
 			"please report this\n", fname));
@@ -2281,9 +2222,10 @@ void reply_ctemp(struct smb_request *req)
 		goto out;
 	}
 
-	status = resolve_dfspath(ctx, conn,
+	status = filename_convert(ctx, conn,
 				req->flags2 & FLAGS2_DFS_PATHNAMES,
 				fname,
+				&smb_fname,
 				&fname);
 	if (!NT_STATUS_IS_OK(status)) {
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
@@ -2295,18 +2237,6 @@ void reply_ctemp(struct smb_request *req)
 		goto out;
 	}
 
-	status = unix_convert(ctx, conn, fname, &smb_fname, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
-	status = check_name(conn, smb_fname->base_name);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
 	tmpfd = mkstemp(smb_fname->base_name);
 	if (tmpfd == -1) {
 		reply_unixerror(req, ERRDOS, ERRnoaccess);
@@ -5263,9 +5193,10 @@ void reply_mkdir(struct smb_request *req)
 		goto out;
 	}
 
-	status = resolve_dfspath(ctx, conn,
+	status = filename_convert(ctx, conn,
 				 req->flags2 & FLAGS2_DFS_PATHNAMES,
 				 directory,
+				 &smb_dname,
 				 &directory);
 	if (!NT_STATUS_IS_OK(status)) {
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
@@ -5277,18 +5208,6 @@ void reply_mkdir(struct smb_request *req)
 		goto out;
 	}
 
-	status = unix_convert(ctx, conn, directory, &smb_dname, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
-	status = check_name(conn, smb_dname->base_name);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
 	status = create_directory(conn, req, smb_dname);
 
 	DEBUG(5, ("create_directory returned %s\n", nt_errstr(status)));
@@ -5535,9 +5454,10 @@ void reply_rmdir(struct smb_request *req)
 		goto out;
 	}
 
-	status = resolve_dfspath(ctx, conn,
+	status = filename_convert(ctx, conn,
 				 req->flags2 & FLAGS2_DFS_PATHNAMES,
 				 directory,
+				 &smb_dname,
 				 &directory);
 	if (!NT_STATUS_IS_OK(status)) {
 		if (NT_STATUS_EQUAL(status,NT_STATUS_PATH_NOT_COVERED)) {
@@ -5549,24 +5469,6 @@ void reply_rmdir(struct smb_request *req)
 		goto out;
 	}
 
-	status = unix_convert(ctx, conn, directory, &smb_dname, 0);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
-	status = get_full_smb_filename(ctx, smb_dname, &directory);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}
-
-	status = check_name(conn, directory);
-	if (!NT_STATUS_IS_OK(status)) {
-		reply_nterror(req, status);
-		goto out;
-	}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list