summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-06-13 12:52:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:23:18 -0500
commit0e0fed6f25520d31966a5b29429533397ee5e171 (patch)
treeeb9ba613f8c4560899188e05278be2b58c012629 /source3/smbd
parent719df44c03c54429504c9f58922f348a5cb5aafe (diff)
downloadsamba-0e0fed6f25520d31966a5b29429533397ee5e171.tar.gz
samba-0e0fed6f25520d31966a5b29429533397ee5e171.tar.bz2
samba-0e0fed6f25520d31966a5b29429533397ee5e171.zip
r23467: Next little simplification: In rename_internals it's a bit pointless to
first ask for existence of a file when we do the open_file_ntcreate in can_rename later on anyway. That also gets us the right error message in case the file is not there automatically. (This used to be commit f3d582cb908f95c1b557bda5d41b5a8aff75b124)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/reply.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index f2ff0b85e0..14dbdcafbd 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -4588,38 +4588,9 @@ NTSTATUS rename_internals(connection_struct *conn,
}
/*
- * The source object must exist.
+ * The source object must exist, and it may not have a
+ * conflicting share mode.
*/
-
- if (!vfs_object_exist(conn, directory, &sbuf1)) {
- DEBUG(3, ("rename_internals: source doesn't exist "
- "doing rename %s -> %s\n",
- directory,newname));
-
- if (errno == ENOTDIR || errno == EISDIR
- || errno == ENOENT) {
- /*
- * Must return different errors depending on
- * whether the parent directory existed or
- * not.
- */
-
- p = strrchr_m(directory, '/');
- if (!p)
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- *p = '\0';
- if (vfs_object_exist(conn, directory, NULL))
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
- return NT_STATUS_OBJECT_PATH_NOT_FOUND;
- }
- status = map_nt_error_from_unix(errno);
- DEBUG(3, ("rename_internals: Error %s rename %s -> "
- "%s\n", nt_errstr(status), directory,
- newname));
-
- return status;
- }
-
status = can_rename(conn,directory,attrs,&sbuf1,False);
if (!NT_STATUS_IS_OK(status)) {
@@ -4740,15 +4711,19 @@ NTSTATUS rename_internals(connection_struct *conn,
return status;
}
- if (!vfs_object_exist(conn, fname, &sbuf1)) {
- status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
- DEBUG(6, ("rename %s failed. Error %s\n",
- fname, nt_errstr(status)));
- continue;
- }
+ /*
+ * can_rename does an open_file_ntcreate which needs a valid
+ * stat in case the file exists
+ */
+
+ ZERO_STRUCT(sbuf1);
+ SMB_VFS_STAT(conn, fname, &sbuf1);
+
status = can_rename(conn,fname,attrs,&sbuf1,False);
+
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(6, ("rename %s refused\n", fname));
+ DEBUG(6, ("rename %s refused: %s\n", fname,
+ nt_errstr(status)));
continue;
}
pstrcpy(destname,newname);