struct file_id file_id;
NTSTATUS status;
enum ndr_err_code ndr_err;
+ bool ok;
*result = NULL;
*new_cookie = data_blob_null;
state.fsp->fnum = op->local_id;
fh_set_gen_id(state.fsp->fh, op->global->open_global_id);
- status = fsp_set_smb_fname(state.fsp, smb_fname);
- if (!NT_STATUS_IS_OK(status)) {
- DBG_ERR("fsp_set_smb_fname failed: %s\n",
- nt_errstr(status));
+ ok = fsp_set_smb_fname(state.fsp, smb_fname);
+ if (!ok) {
+ DBG_ERR("fsp_set_smb_fname failed\n");
file_free(smb1req, state.fsp);
- return status;
+ return NT_STATUS_NO_MEMORY;
}
/*
loadparm_s3_global_substitution();
files_struct *fsp = NULL;
NTSTATUS status;
+ bool ok;
/* access check */
if (geteuid() != sec_initial_uid()) {
fh_set_pos(fsp->fh, -1);
fsp->fsp_flags.can_lock = false; /* Should this be true ? - No, JRA */
fsp->access_mask = access_mask;
- status = fsp_set_smb_fname(fsp, smb_fname);
- if (!NT_STATUS_IS_OK(status)) {
+ ok = fsp_set_smb_fname(fsp, smb_fname);
+ if (!ok) {
file_free(req, fsp);
return NT_STATUS_NO_MEMORY;
}
{
struct files_struct *fsp = NULL;
NTSTATUS status;
+ bool ok;
status = file_new(NULL, conn, &fsp);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- status = fsp_set_smb_fname(fsp, smb_fname);
- if (!NT_STATUS_IS_OK(status)) {
+ ok = fsp_set_smb_fname(fsp, smb_fname);
+ if (!ok) {
file_free(NULL, fsp);
- return status;
+ return NT_STATUS_NO_MEMORY;
}
*_fsp = fsp;
struct files_struct *fsp = NULL;
NTSTATUS status;
int fd;
+ bool ok;
status = fsp_new(conn, conn, &fsp);
if (!NT_STATUS_IS_OK(status)) {
ZERO_STRUCT(conn->sconn->fsp_fi_cache);
fsp->fsp_flags.is_pathref = true;
- status = fsp_set_smb_fname(fsp, &slash);
- if (!NT_STATUS_IS_OK(status)) {
+ ok = fsp_set_smb_fname(fsp, &slash);
+ if (!ok) {
+ status = NT_STATUS_NO_MEMORY;
goto fail;
}
fsp->fsp_flags.is_pathref = true;
fsp->fsp_name = NULL;
- status = fsp_set_smb_fname(fsp, &full_fname);
- if (!NT_STATUS_IS_OK(status)) {
- DBG_DEBUG("fsp_set_smb_fname() failed: %s\n",
- nt_errstr(status));
- goto fail;
+ ok = fsp_set_smb_fname(fsp, &full_fname);
+ if (!ok) {
+ DBG_DEBUG("fsp_set_smb_fname() failed\n");
+ goto nomem;
}
status = vfs_stat_fsp(fsp);
return NT_STATUS_NO_MEMORY;
}
- status = fsp_set_smb_fname(fsp, &new_fullname);
- if (!NT_STATUS_IS_OK(status)) {
+ ok = fsp_set_smb_fname(fsp, &new_fullname);
+ if (!ok) {
fd_close(fsp);
file_free(NULL, fsp);
- return status;
+ return NT_STATUS_NO_MEMORY;
}
}
/**
* The only way that the fsp->fsp_name field should ever be set.
*/
-NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
- const struct smb_filename *smb_fname_in)
+bool fsp_set_smb_fname(struct files_struct *fsp,
+ const struct smb_filename *smb_fname_in)
{
struct smb_filename *smb_fname_old = fsp->fsp_name;
struct smb_filename *smb_fname_new = NULL;
smb_fname_new = cp_smb_filename(fsp, smb_fname_in);
if (smb_fname_new == NULL) {
- return NT_STATUS_NO_MEMORY;
+ return false;
}
ok = fsp_attach_smb_fname(fsp, &smb_fname_new);
if (!ok) {
TALLOC_FREE(smb_fname_new);
- return NT_STATUS_NO_MEMORY;
+ return false;
}
if (smb_fname_old != NULL) {
TALLOC_FREE(smb_fname_old);
}
- return NT_STATUS_OK;
+ return true;
}
size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen)
if (strcmp(fsp->conn->connectpath, msg->servicepath) == 0) {
SMB_STRUCT_STAT fsp_orig_sbuf;
- NTSTATUS status;
+ bool ok;
+
DBG_DEBUG("renaming file %s from %s -> %s\n",
fsp_fnum_dbg(fsp),
fsp_str_dbg(fsp),
* any of this metadata to the client anyway.
*/
fsp_orig_sbuf = fsp->fsp_name->st;
- status = fsp_set_smb_fname(fsp, smb_fname);
- if (!NT_STATUS_IS_OK(status)) {
- DBG_DEBUG("fsp_set_smb_fname failed: %s\n",
- nt_errstr(status));
+ ok = fsp_set_smb_fname(fsp, smb_fname);
+ if (!ok) {
+ DBG_DEBUG("fsp_set_smb_fname failed\n");
}
fsp->fsp_name->st = fsp_orig_sbuf;
} else {
file_free(NULL, tmp_base_fsp);
}
} else {
+ bool ok;
+
/*
* No fsp passed in that we can use, create one
*/
}
free_fsp_on_error = true;
- status = fsp_set_smb_fname(fsp, smb_fname);
- if (!NT_STATUS_IS_OK(status)) {
- goto fail;
+ ok = fsp_set_smb_fname(fsp, smb_fname);
+ if (!ok) {
+ goto nomem;
}
}
goto fail;
}
} else {
+ bool ok;
+
/*
* Get a pathref on the parent. We can re-use this for
* multiple calls to check parent ACLs etc. to avoid
}
dirfsp = parent_dir_fname->fsp;
- status = fsp_set_smb_fname(dirfsp, parent_dir_fname);
- if (!NT_STATUS_IS_OK(status)) {
- goto fail;
+ ok = fsp_set_smb_fname(dirfsp, parent_dir_fname);
+ if (!ok) {
+ goto nomem;
}
}
return NT_STATUS_OK;
- fail:
+nomem:
+ status = NT_STATUS_NO_MEMORY;
+fail:
DEBUG(10, ("create_file_unixpath: %s\n", nt_errstr(status)));
if (fsp != NULL) {
struct files_struct *file_fsp_smb2(struct smbd_smb2_request *smb2req,
uint64_t persistent_id,
uint64_t volatile_id);
-NTSTATUS fsp_set_smb_fname(struct files_struct *fsp,
- const struct smb_filename *smb_fname_in);
+bool fsp_set_smb_fname(struct files_struct *fsp,
+ const struct smb_filename *smb_fname_in);
size_t fsp_fullbasepath(struct files_struct *fsp, char *buf, size_t buflen);
void fsp_set_base_fsp(struct files_struct *fsp, struct files_struct *base_fsp);
bool fsp_is_alternate_stream(const struct files_struct *fsp);
struct files_struct *fsp = NULL, *new_fsp = NULL;
size_t new_refcount;
NTSTATUS status;
+ bool ok;
if ((private_flags &
(NTCREATEX_FLAG_DENY_DOS|
new_fsp->fsp_flags.can_write = false;
}
- status = fsp_set_smb_fname(new_fsp, fsp->fsp_name);
+ ok = fsp_set_smb_fname(new_fsp, fsp->fsp_name);
- if (!NT_STATUS_IS_OK(status)) {
- DBG_DEBUG("fsp_set_smb_fname failed: %s\n", nt_errstr(status));
+ if (!ok) {
+ DBG_DEBUG("fsp_set_smb_fname failed\n");
file_free(req, new_fsp);
return NULL;
}
struct smb_filename *smb_fname = NULL;
struct auth_session_info *session_info = conn->session_info;
NTSTATUS status;
+ bool ok;
status = file_new(smb_req, conn, &fsp);
if (!NT_STATUS_IS_OK(status)) {
file_free(smb_req, fsp);
return NT_STATUS_NO_MEMORY;
}
- status = fsp_set_smb_fname(fsp, smb_fname);
+ ok = fsp_set_smb_fname(fsp, smb_fname);
TALLOC_FREE(smb_fname);
- if (!NT_STATUS_IS_OK(status)) {
+ if (!ok) {
file_free(smb_req, fsp);
- return status;
+ return NT_STATUS_NO_MEMORY;
}
if (smb_req->smb2req != NULL && smb_req->smb2req->was_encrypted) {
uint16_t cipher = xconn->smb2.server.cipher;
struct dom_sid smb3_sid = global_sid_Samba_SMB3;
size_t num_smb3_sids;
- bool ok;
session_info = copy_session_info(fsp, conn->session_info);
if (session_info == NULL) {
{
files_struct *fsp;
bool did_rename = False;
- NTSTATUS status;
uint32_t new_name_hash = 0;
for(fsp = file_find_di_first(conn->sconn, id, false); fsp;
fsp = file_find_di_next(fsp, false)) {
SMB_STRUCT_STAT fsp_orig_sbuf;
struct file_id_buf idbuf;
+ bool ok;
+
/* fsp_name is a relative path under the fsp. To change this for other
sharepaths we need to manipulate relative paths. */
/* TODO - create the absolute path and manipulate the newname
* any of this metadata to the client anyway.
*/
fsp_orig_sbuf = fsp->fsp_name->st;
- status = fsp_set_smb_fname(fsp, smb_fname_dst);
- if (NT_STATUS_IS_OK(status)) {
+ ok = fsp_set_smb_fname(fsp, smb_fname_dst);
+ if (ok) {
did_rename = True;
new_name_hash = fsp->name_hash;
/* Restore existing stat. */