summaryrefslogtreecommitdiff
path: root/source3/smbd/reply.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/reply.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/reply.c')
-rw-r--r--source3/smbd/reply.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index f2d4ff78a7..bb5fadd465 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -5616,7 +5616,13 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
return map_nt_error_from_unix(errno);
}
} else {
- if (SMB_VFS_STAT(conn,fsp->fsp_name,&sbuf) == -1) {
+ int ret = -1;
+ if (fsp->posix_open) {
+ ret = SMB_VFS_LSTAT(conn,fsp->fsp_name,&sbuf);
+ } else {
+ ret = SMB_VFS_STAT(conn,fsp->fsp_name,&sbuf);
+ }
+ if (ret == -1) {
return map_nt_error_from_unix(errno);
}
}
@@ -5721,6 +5727,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
const char *dname;
long offset = 0;
int create_options = 0;
+ bool posix_pathnames = lp_posix_pathnames();
ZERO_STRUCT(sbuf1);
ZERO_STRUCT(sbuf2);
@@ -5832,7 +5839,11 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
}
ZERO_STRUCT(sbuf1);
- SMB_VFS_STAT(conn, directory, &sbuf1);
+ if (posix_pathnames) {
+ SMB_VFS_LSTAT(conn, directory, &sbuf1);
+ } else {
+ SMB_VFS_STAT(conn, directory, &sbuf1);
+ }
if (S_ISDIR(sbuf1.st_mode)) {
create_options |= FILE_DIRECTORY_FILE;
@@ -5849,7 +5860,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
FILE_SHARE_WRITE),
FILE_OPEN, /* create_disposition*/
create_options, /* create_options */
- 0, /* file_attributes */
+ posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0, /* file_attributes */
0, /* oplock_request */
0, /* allocation_size */
NULL, /* sd */
@@ -5948,7 +5959,11 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
}
ZERO_STRUCT(sbuf1);
- SMB_VFS_STAT(conn, fname, &sbuf1);
+ if (posix_pathnames) {
+ SMB_VFS_LSTAT(conn, fname, &sbuf1);
+ } else {
+ SMB_VFS_STAT(conn, fname, &sbuf1);
+ }
create_options = 0;
@@ -5967,7 +5982,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
FILE_SHARE_WRITE),
FILE_OPEN, /* create_disposition*/
create_options, /* create_options */
- 0, /* file_attributes */
+ posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0, /* file_attributes */
0, /* oplock_request */
0, /* allocation_size */
NULL, /* sd */
@@ -7167,7 +7182,14 @@ void reply_setattrE(struct smb_request *req)
return;
}
} else {
- if (SMB_VFS_STAT(conn, fsp->fsp_name, &sbuf) == -1) {
+ int ret = -1;
+
+ if (fsp->posix_open) {
+ ret = SMB_VFS_LSTAT(conn, fsp->fsp_name, &sbuf);
+ } else {
+ ret = SMB_VFS_STAT(conn, fsp->fsp_name, &sbuf);
+ }
+ if (ret == -1) {
status = map_nt_error_from_unix(errno);
reply_nterror(req, status);
END_PROFILE(SMBsetattrE);