From 35b7dfaa203689f761d38d7d243b4f335543bf4c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 30 Aug 2002 19:29:59 +0000 Subject: Fix bug with stat mode open being done on read-only open with truncate. Jeremy. (This used to be commit 18b9cbd857177a911ef95c9322bdf0709161cd84) --- source3/smbd/open.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'source3/smbd/open.c') diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 47e859d04b..8cc73a681d 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -139,18 +139,20 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn, * as we always opened files read-write in that release. JRA. */ - if ((accmode == O_RDONLY) && ((flags & O_TRUNC) == O_TRUNC)) + if ((accmode == O_RDONLY) && ((flags & O_TRUNC) == O_TRUNC)) { + DEBUG(10,("open_file: truncate requested on read-only open for file %s\n",fname )); local_flags = (flags & ~O_ACCMODE)|O_RDWR; + } - /* - * We can't actually truncate here as the file may be locked. - * open_file_shared will take care of the truncate later. JRA. - */ + if ((desired_access & (FILE_READ_DATA|FILE_WRITE_DATA|FILE_APPEND_DATA|FILE_EXECUTE)) || + (local_flags & O_CREAT) || ((local_flags & O_TRUNC) == O_TRUNC) ) { - local_flags &= ~O_TRUNC; + /* + * We can't actually truncate here as the file may be locked. + * open_file_shared will take care of the truncate later. JRA. + */ - if ((desired_access & (FILE_READ_DATA|FILE_WRITE_DATA|FILE_APPEND_DATA|FILE_EXECUTE)) || - (local_flags & O_CREAT)) { + local_flags &= ~O_TRUNC; /* actually do the open */ fsp->fd = fd_open(conn, fname, local_flags, mode); -- cgit