summaryrefslogtreecommitdiff
path: root/source4/ntvfs/posix
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-11-12 02:45:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:05:45 -0500
commit94c6fde541f2f8c5b93f8c779f0a1714a446e490 (patch)
treeb1103bee7133c43c68024d7118b8716e6b9bbdda /source4/ntvfs/posix
parenta20b130b5f275a264cfdd59adcb25987fba97fc2 (diff)
downloadsamba-94c6fde541f2f8c5b93f8c779f0a1714a446e490.tar.gz
samba-94c6fde541f2f8c5b93f8c779f0a1714a446e490.tar.bz2
samba-94c6fde541f2f8c5b93f8c779f0a1714a446e490.zip
r3694: added support for the RENAME_INFORMATION level of setfileinfo and
setpathinfo. pvfs now passes the RAW-SFILEINFO test. (This used to be commit 31ac31398ba52dfc554e58edaa7ae257caf5fdc6)
Diffstat (limited to 'source4/ntvfs/posix')
-rw-r--r--source4/ntvfs/posix/pvfs_resolve.c2
-rw-r--r--source4/ntvfs/posix/pvfs_setfileinfo.c58
2 files changed, 49 insertions, 11 deletions
diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c
index 5c650440c3..354cdd4bb4 100644
--- a/source4/ntvfs/posix/pvfs_resolve.c
+++ b/source4/ntvfs/posix/pvfs_resolve.c
@@ -527,7 +527,7 @@ NTSTATUS pvfs_resolve_name_fd(struct pvfs_state *pvfs, int fd,
be someone trying to exploit a race
condition. Certainly we don't want to continue
operating on this file */
- DEBUG(0,("pvfs: WARNING: file '%s' changed during resole - failing\n",
+ DEBUG(0,("pvfs: WARNING: file '%s' changed during resolve - failing\n",
name->full_name));
return NT_STATUS_UNEXPECTED_IO_ERROR;
}
diff --git a/source4/ntvfs/posix/pvfs_setfileinfo.c b/source4/ntvfs/posix/pvfs_setfileinfo.c
index a550fb03e4..391a2e9d82 100644
--- a/source4/ntvfs/posix/pvfs_setfileinfo.c
+++ b/source4/ntvfs/posix/pvfs_setfileinfo.c
@@ -34,10 +34,9 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs,
struct pvfs_filename *name,
struct smb_rename_information *r)
{
-#if 0
NTSTATUS status;
struct pvfs_filename *name2;
- char *base_dir, *p;
+ char *new_name, *p;
/* renames are only allowed within a directory */
if (strchr_m(r->new_name, '\\')) {
@@ -49,22 +48,61 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs,
return NT_STATUS_FILE_IS_A_DIRECTORY;
}
- /* work out the base directory that the source file is in */
- base_dir = talloc_strdup(name, name->full_name);
- p = strrchr(base_dir, '/');
+ /* w2k3 does not appear to allow relative rename */
+ if (r->root_fid != 0) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ /* construct the fully qualified windows name for the new file name */
+ new_name = talloc_strdup(req, name->original_name);
+ if (new_name == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ p = strrchr_m(new_name, '\\');
+ if (p == NULL) {
+ return NT_STATUS_OBJECT_NAME_INVALID;
+ }
*p = 0;
+ new_name = talloc_asprintf(req, "%s\\%s", new_name, r->new_name);
+ if (new_name == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
/* resolve the new name */
- status = pvfs_resolve_partial(pvfs, req, base_dir, r->new_name, &name2);
+ status = pvfs_resolve_name(pvfs, name, new_name, PVFS_RESOLVE_NO_WILDCARD, &name2);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- if (name2->exists && !r->overwrite) {
- return NT_STATUS_OBJECT_NAME_COLLISION;
+ /* if the destination exists, then check the rename is allowed */
+ if (name2->exists) {
+ if (strcmp(name2->full_name, name->full_name) == 0) {
+ /* rename to same name is null-op */
+ return NT_STATUS_OK;
+ }
+
+ if (!r->overwrite) {
+ return NT_STATUS_OBJECT_NAME_COLLISION;
+ }
+
+ status = pvfs_can_delete(pvfs, name2);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
+ return NT_STATUS_ACCESS_DENIED;
+ }
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ }
+
+ if (rename(name->full_name, name2->full_name) == -1) {
+ return map_nt_error_from_unix(errno);
}
-#endif
- return NT_STATUS_UNSUCCESSFUL;
+
+ name->full_name = talloc_steal(name, name2->full_name);
+ name->original_name = talloc_steal(name, name2->original_name);
+
+ return NT_STATUS_OK;
}
/*