summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-05-14 22:08:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:51:36 -0500
commit8b9a044b58cfcf070d5158ffc4533d2a27226e44 (patch)
tree1fb5d0e2dd49b3f938da8568fcaa8fc78ddf8f37 /source3
parent80f72a63009eac05a91877893a802cf1a8a62d98 (diff)
downloadsamba-8b9a044b58cfcf070d5158ffc4533d2a27226e44.tar.gz
samba-8b9a044b58cfcf070d5158ffc4533d2a27226e44.tar.bz2
samba-8b9a044b58cfcf070d5158ffc4533d2a27226e44.zip
r742: Volker discovered that we can truncate a locked file. Well I never ! :-).
Jeremy (This used to be commit 1099d60113c2d7b2e5a27a10666cdf885c668778)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/open.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 235a455f30..f072dc4be4 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -242,30 +242,10 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn,
return True;
}
-/****************************************************************************
- C. Hoch 11/22/95
- Helper for open_file_shared.
- Truncate a file after checking locking; close file if locked.
- **************************************************************************/
-
-static int truncate_unless_locked(struct connection_struct *conn, files_struct *fsp)
-{
- SMB_BIG_UINT mask = (SMB_BIG_UINT)-1;
-
- if (is_locked(fsp,fsp->conn,mask,0,WRITE_LOCK,True)){
- errno = EACCES;
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRlock;
- unix_ERR_ntstatus = dos_to_ntstatus(ERRDOS, ERRlock);
- return -1;
- } else {
- return SMB_VFS_FTRUNCATE(fsp,fsp->fd,0);
- }
-}
-
/*******************************************************************
return True if the filename is one of the special executable types
********************************************************************/
+
static BOOL is_executable(const char *fname)
{
if ((fname = strrchr_m(fname,'.'))) {
@@ -1109,7 +1089,7 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
/*
* We are modifing the file after open - update the stat struct..
*/
- if ((truncate_unless_locked(conn,fsp) == -1) || (SMB_VFS_FSTAT(fsp,fsp->fd,psbuf)==-1)) {
+ if ((SMB_VFS_FTRUNCATE(fsp,fsp->fd,0) == -1) || (SMB_VFS_FSTAT(fsp,fsp->fd,psbuf)==-1)) {
unlock_share_entry_fsp(fsp);
fd_close(conn,fsp);
file_free(fsp);