summaryrefslogtreecommitdiff
path: root/source3/smbd/open.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-02-04 16:33:52 -0800
committerJeremy Allison <jra@samba.org>2009-02-04 16:33:52 -0800
commite7c09d8b105d8182e7ae3948a664169dc13198e9 (patch)
tree51c4abdd43cf4331e180c8ffbd5a4861daa4ee4d /source3/smbd/open.c
parentef098bd621b544a651636db4b7d6cdd777c83d18 (diff)
downloadsamba-e7c09d8b105d8182e7ae3948a664169dc13198e9.tar.gz
samba-e7c09d8b105d8182e7ae3948a664169dc13198e9.tar.bz2
samba-e7c09d8b105d8182e7ae3948a664169dc13198e9.zip
Fix bug #Bug 6090 renaming or deleting a "not matching/resolving" symlink is failing.
Reported by Kukks. Make sure we correctly use LSTAT in all cases where POSIX pathnames are being used. This matters when dealing with symlinks pointing to invalid paths being renamed or deleted not all deletes and renames are done via an nt_create open. Jeremy.
Diffstat (limited to 'source3/smbd/open.c')
-rw-r--r--source3/smbd/open.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index bc5107447f..f7a52d7bd2 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -432,28 +432,42 @@ static NTSTATUS open_file(files_struct *fsp,
access_mask,
&access_granted);
if (!NT_STATUS_IS_OK(status)) {
-
- /* Were we trying to do a stat open
- * for delete and didn't get DELETE
- * access (only) ? Check if the
- * directory allows DELETE_CHILD.
- * See here:
- * http://blogs.msdn.com/oldnewthing/archive/2004/06/04/148426.aspx
- * for details. */
-
- if (!(NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) &&
- (access_mask & DELETE_ACCESS) &&
- (access_granted == DELETE_ACCESS) &&
- can_delete_file_in_directory(conn, path))) {
- DEBUG(10, ("open_file: Access denied on "
- "file %s\n",
- path));
+ if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
+ if ((access_mask & DELETE_ACCESS) &&
+ (access_granted == DELETE_ACCESS) &&
+ can_delete_file_in_directory(conn, path)) {
+ /* Were we trying to do a stat open
+ * for delete and didn't get DELETE
+ * access (only) ? Check if the
+ * directory allows DELETE_CHILD.
+ * See here:
+ * http://blogs.msdn.com/oldnewthing/archive/2004/06/04/148426.aspx
+ * for details. */
+
+ DEBUG(10,("open_file: overrode ACCESS_DENIED "
+ "on file %s\n",
+ path ));
+ } else {
+ DEBUG(10, ("open_file: Access denied on "
+ "file %s\n",
+ path));
+ return status;
+ }
+ } else if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND) &&
+ fsp->posix_open &&
+ S_ISLNK(psbuf->st_mode)) {
+ /* This is a POSIX stat open for delete
+ * or rename on a symlink that points
+ * nowhere. Allow. */
+ DEBUG(10, ("open_file: allowing POSIX open "
+ "on bad symlink %s\n",
+ path ));
+ } else {
+ DEBUG(10, ("open_file: check_open_rights "
+ "on file %s returned %s\n",
+ path, nt_errstr(status) ));
return status;
}
-
- DEBUG(10,("open_file: overrode ACCESS_DENIED "
- "on file %s\n",
- path ));
}
}
}