char *fname = NULL;
NTSTATUS status;
- if (!*lp_magicscript(SNUM(conn))) {
+ if (!*lp_magicscript(talloc_tos(), SNUM(conn))) {
return NT_STATUS_OK;
}
p++;
}
- if (!strequal(lp_magicscript(SNUM(conn)),p)) {
+ if (!strequal(lp_magicscript(talloc_tos(), SNUM(conn)),p)) {
status = NT_STATUS_OK;
goto out;
}
- if (*lp_magicoutput(SNUM(conn))) {
- magic_output = lp_magicoutput(SNUM(conn));
+ if (*lp_magicoutput(talloc_tos(), SNUM(conn))) {
+ magic_output = lp_magicoutput(talloc_tos(), SNUM(conn));
} else {
magic_output = talloc_asprintf(ctx,
"%s.out",
for (i=0; i<num_deferred; i++) {
struct share_mode_entry *e = &deferred[i];
- if (procid_equal(&self, &e->pid)) {
+ if (serverid_equal(&self, &e->pid)) {
/*
* We need to notify ourself to retry the open. Do
* this by finding the queued SMB record, moving it to
enum file_close_type close_type)
{
connection_struct *conn = fsp->conn;
+ struct server_id self = messaging_server_id(conn->sconn->msg_ctx);
bool delete_file = false;
bool changed_user = false;
struct share_mode_lock *lck = NULL;
const struct security_unix_token *del_token = NULL;
const struct security_token *del_nt_token = NULL;
bool got_tokens = false;
+ bool normal_close;
/* Ensure any pending write time updates are done. */
if (fsp->update_write_time_event) {
if (lck == NULL) {
DEBUG(0, ("close_remove_share_mode: Could not get share mode "
"lock for file %s\n", fsp_str_dbg(fsp)));
- status = NT_STATUS_INVALID_PARAMETER;
- goto done;
+ return NT_STATUS_INVALID_PARAMETER;
}
if (fsp->write_time_forced) {
}
}
- if (!del_share_mode(lck, fsp)) {
- DEBUG(0, ("close_remove_share_mode: Could not delete share "
- "entry for file %s\n",
- fsp_str_dbg(fsp)));
- }
-
if (fsp->initial_delete_on_close &&
!is_delete_on_close_set(lck, fsp->name_hash)) {
bool became_user = False;
POSIX delete now. */
for (i=0; i<lck->data->num_share_modes; i++) {
struct share_mode_entry *e = &lck->data->share_modes[i];
- if (is_valid_share_mode_entry(e) &&
- e->name_hash == fsp->name_hash) {
- if (fsp->posix_open && (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) {
- continue;
- }
- if (share_mode_stale_pid(lck->data, i)) {
- continue;
- }
- delete_file = False;
- break;
+
+ if (!is_valid_share_mode_entry(e)) {
+ continue;
+ }
+ if (e->name_hash != fsp->name_hash) {
+ continue;
+ }
+ if (fsp->posix_open
+ && (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) {
+ continue;
+ }
+ if (serverid_equal(&self, &e->pid) &&
+ (e->share_file_id == fsp->fh->gen_id)) {
+ continue;
+ }
+ if (share_mode_stale_pid(lck->data, i)) {
+ continue;
}
+ delete_file = False;
+ break;
}
}
* reference to a file.
*/
- if (!(close_type == NORMAL_CLOSE || close_type == SHUTDOWN_CLOSE) ||
- !delete_file) {
+ normal_close = (close_type == NORMAL_CLOSE || close_type == SHUTDOWN_CLOSE);
+
+ if (!normal_close || !delete_file) {
+
+ if (!del_share_mode(lck, fsp)) {
+ DEBUG(0, ("close_remove_share_mode: Could not delete "
+ "share entry for file %s\n",
+ fsp_str_dbg(fsp)));
+ }
+
TALLOC_FREE(lck);
return NT_STATUS_OK;
}
pop_sec_ctx();
}
+ if (!del_share_mode(lck, fsp)) {
+ DEBUG(0, ("close_remove_share_mode: Could not delete share "
+ "entry for file %s\n", fsp_str_dbg(fsp)));
+ }
+
TALLOC_FREE(lck);
if (delete_file) {
return NT_STATUS_OK;
}
- if(((errno == ENOTEMPTY)||(errno == EEXIST)) && *lp_veto_files(SNUM(conn))) {
+ if(((errno == ENOTEMPTY)||(errno == EEXIST)) && *lp_veto_files(talloc_tos(), SNUM(conn))) {
/*
* Check to see if the only thing in this directory are
* vetoed files/directories. If so then delete them and
static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
enum file_close_type close_type)
{
+ struct server_id self = messaging_server_id(fsp->conn->sconn->msg_ctx);
struct share_mode_lock *lck = NULL;
bool delete_dir = False;
NTSTATUS status = NT_STATUS_OK;
if (lck == NULL) {
DEBUG(0, ("close_directory: Could not get share mode lock for "
"%s\n", fsp_str_dbg(fsp)));
- status = NT_STATUS_INVALID_PARAMETER;
- goto out;
- }
-
- if (!del_share_mode(lck, fsp)) {
- DEBUG(0, ("close_directory: Could not delete share entry for "
- "%s\n", fsp_str_dbg(fsp)));
+ return NT_STATUS_INVALID_PARAMETER;
}
if (fsp->initial_delete_on_close) {
if (fsp->posix_open && (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) {
continue;
}
+ if (serverid_equal(&self, &e->pid) &&
+ (e->share_file_id == fsp->fh->gen_id)) {
+ continue;
+ }
if (share_mode_stale_pid(lck->data, i)) {
continue;
}
del_token->groups,
del_nt_token);
+ if (!del_share_mode(lck, fsp)) {
+ DEBUG(0, ("close_directory: Could not delete share entry for "
+ "%s\n", fsp_str_dbg(fsp)));
+ }
+
TALLOC_FREE(lck);
if ((fsp->conn->fs_capabilities & FILE_NAMED_STREAMS)
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("delete_all_streams failed: %s\n",
nt_errstr(status)));
- goto out;
+ return status;
}
}
remove_pending_change_notify_requests_by_fid(fsp, NT_STATUS_DELETE_PENDING);
}
} else {
+ if (!del_share_mode(lck, fsp)) {
+ DEBUG(0, ("close_directory: Could not delete share entry for "
+ "%s\n", fsp_str_dbg(fsp)));
+ }
+
TALLOC_FREE(lck);
remove_pending_change_notify_requests_by_fid(
fsp, NT_STATUS_OK);
close_filestruct(fsp);
file_free(req, fsp);
- out:
- TALLOC_FREE(lck);
if (NT_STATUS_IS_OK(status) && !NT_STATUS_IS_OK(status1)) {
status = status1;
}