diff options
Diffstat (limited to 'source/smbd/close.c')
-rw-r--r-- | source/smbd/close.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/source/smbd/close.c b/source/smbd/close.c index 38270fbfe31..ca030ed1404 100644 --- a/source/smbd/close.c +++ b/source/smbd/close.c @@ -91,14 +91,13 @@ static int close_filestruct(files_struct *fsp) connection_struct *conn = fsp->conn; int ret = 0; - if (fsp->fd != -1) { - if(flush_write_cache(fsp, CLOSE_FLUSH) == -1) - ret = -1; + if(flush_write_cache(fsp, CLOSE_FLUSH) == -1) + ret = -1; - delete_write_cache(fsp); - } + delete_write_cache(fsp); fsp->is_directory = False; + fsp->stat_open = False; conn->num_files_open--; SAFE_FREE(fsp->wbmpx_ptr); @@ -161,7 +160,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close) GET_DELETE_ON_CLOSE_FLAG(share_entry->share_mode) ) delete_on_close = True; - SAFE_FREE(share_entry); + safe_free(share_entry); /* * NT can set delete_on_close of the last open @@ -171,7 +170,7 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close) if (normal_close && delete_on_close) { DEBUG(5,("close_file: file %s. Delete on close was set - deleting file.\n", fsp->fsp_name)); - if(fsp->conn->vfs_ops.unlink(conn,dos_to_unix_static(fsp->fsp_name)) != 0) { + if(fsp->conn->vfs_ops.unlink(conn,dos_to_unix(fsp->fsp_name, False)) != 0) { /* * This call can potentially fail as another smbd may have * had the file open with delete on close set and deleted @@ -264,6 +263,22 @@ static int close_directory(files_struct *fsp, BOOL normal_close) } /**************************************************************************** + Close a file opened with null permissions in order to read permissions. +****************************************************************************/ + +static int close_statfile(files_struct *fsp, BOOL normal_close) +{ + close_filestruct(fsp); + + if (fsp->fsp_name) + string_free(&fsp->fsp_name); + + file_free(fsp); + + return 0; +} + +/**************************************************************************** Close a directory opened by an NT SMB call. ****************************************************************************/ @@ -271,5 +286,7 @@ int close_file(files_struct *fsp, BOOL normal_close) { if(fsp->is_directory) return close_directory(fsp, normal_close); + else if(fsp->stat_open) + return close_statfile(fsp, normal_close); return close_normal_file(fsp, normal_close); } |