summaryrefslogtreecommitdiffstats
path: root/source3/smbd/files.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-02-26 11:42:23 -0800
committerJeremy Allison <jra@samba.org>2009-02-26 11:42:23 -0800
commit3121249243f52dcbf8083f5ff137bd580515efa7 (patch)
treebe0a48eb0ff6293a96312e275e263e95fb7f3be7 /source3/smbd/files.c
parentbcadb77c18f9ed9be22762871617f1a12294e88c (diff)
downloadsamba-3121249243f52dcbf8083f5ff137bd580515efa7.tar.gz
samba-3121249243f52dcbf8083f5ff137bd580515efa7.tar.xz
samba-3121249243f52dcbf8083f5ff137bd580515efa7.zip
Make us pass the RAW-RENAME torture test I just added.
Inside a directory, keep a file open and then renaming the directory should fail with ACCESS_DENIED. Jeremy.
Diffstat (limited to 'source3/smbd/files.c')
-rw-r--r--source3/smbd/files.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index efaadffc061..36e80a086ac 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -356,6 +356,49 @@ files_struct *file_find_print(void)
}
/****************************************************************************
+ Find any fsp open with a pathname below that of an already open path.
+****************************************************************************/
+
+bool file_find_subpath(files_struct *dir_fsp)
+{
+ files_struct *fsp;
+ size_t dlen;
+ char *d_fullname = talloc_asprintf(talloc_tos(),
+ "%s/%s",
+ dir_fsp->conn->connectpath,
+ dir_fsp->fsp_name);
+
+ if (!d_fullname) {
+ return false;
+ }
+
+ dlen = strlen(d_fullname);
+
+ for (fsp=Files;fsp;fsp=fsp->next) {
+ char *d1_fullname;
+
+ if (fsp == dir_fsp) {
+ continue;
+ }
+
+ d1_fullname = talloc_asprintf(talloc_tos(),
+ "%s/%s",
+ fsp->conn->connectpath,
+ fsp->fsp_name);
+
+ if (strnequal(d_fullname, d1_fullname, dlen)) {
+ TALLOC_FREE(d_fullname);
+ TALLOC_FREE(d1_fullname);
+ return true;
+ }
+ TALLOC_FREE(d1_fullname);
+ }
+
+ TALLOC_FREE(d_fullname);
+ return false;
+}
+
+/****************************************************************************
Sync open files on a connection.
****************************************************************************/