static bool user_can_stat_name_under_fsp(files_struct *fsp, const char *name)
{
uint32_t rights;
- struct smb_filename fname;
+ struct smb_filename *fname = NULL;
char *filepath = NULL;
NTSTATUS status;
char *p = NULL;
return false;
}
- fname = (struct smb_filename) { .base_name = filepath };
-
rights = SEC_DIR_LIST|SEC_DIR_TRAVERSE;
p = strrchr_m(filepath, '/');
/*
*/
while (p != NULL) {
*p = '\0';
- status = smbd_check_access_rights(fsp->conn,
- fsp->conn->cwd_fsp,
- &fname,
+ status = synthetic_pathref(talloc_tos(),
+ fsp->conn->cwd_fsp,
+ filepath,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ &fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_ERR("synthetic_pathref failed for %s, error %s\n",
+ filepath,
+ nt_errstr(status));
+ TALLOC_FREE(fname);
+ TALLOC_FREE(filepath);
+ return false;
+ }
+
+ status = smbd_check_access_rights_fsp(fname->fsp,
false,
rights);
if (!NT_STATUS_IS_OK(status)) {
fsp->conn->connectpath,
filepath,
nt_errstr(status));
+ TALLOC_FREE(fname);
TALLOC_FREE(filepath);
return false;
}
+ TALLOC_FREE(fname);
rights = SEC_DIR_TRAVERSE;
p = strrchr_m(filepath, '/');
}
DBG_ERR("Memory allocation failed\n");
return false;
}
- fname = (struct smb_filename) { .base_name = filepath };
- status = smbd_check_access_rights(fsp->conn,
- fsp->conn->cwd_fsp,
- &fname,
+ status = synthetic_pathref(talloc_tos(),
+ fsp->conn->cwd_fsp,
+ filepath,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ &fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_ERR("synthetic_pathref failed for %s, error %s\n",
+ filepath,
+ nt_errstr(status));
+ TALLOC_FREE(fname);
+ TALLOC_FREE(filepath);
+ return false;
+ }
+ status = smbd_check_access_rights_fsp(fname->fsp,
false,
rights);
if (!NT_STATUS_IS_OK(status)) {
- DBG_DEBUG("Access rights for %s/.: %s\n",
+ DBG_DEBUG("TRAVERSE access rights for %s failed with %s\n",
fsp->conn->connectpath,
nt_errstr(status));
+ TALLOC_FREE(fname);
TALLOC_FREE(filepath);
return false;
}
+ TALLOC_FREE(fname);
TALLOC_FREE(filepath);
return true;
}