struct files_struct *root_fsp,
const char *connectpath)
{
- errno = ENOSYS;
- return -1;
+ struct smb_filename fname = {
+ .base_name = discard_const_p(char, connectpath),
+ };
+ int ret;
+ bool ok;
+
+ ret = sys_stat(connectpath,
+ &fname.st,
+ lp_fake_directory_create_times(SNUM(handle->conn)));
+ if (ret == -1) {
+ return ret;
+ }
+
+ ok = fsp_set_smb_fname(root_fsp, &fname);
+ if (!ok) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ fsp_set_fd(root_fsp, AT_FDCWD);
+
+ return 0;
}
/* Disk operations */
struct smbd_server_connection *sconn = xconn->client->sconn;
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
- struct smb_filename *smb_fname_cpath = NULL;
fstring dev;
int ret;
bool on_err_call_dis_hook = false;
goto err_root_exit;
}
}
- smb_fname_cpath = synthetic_smb_fname(talloc_tos(),
- conn->connectpath,
- NULL,
- NULL,
- 0,
- 0);
- if (smb_fname_cpath == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto err_root_exit;
- }
/* win2000 does not check the permissions on the directory
during the tree connect, instead relying on permission
I have disabled this chdir check (tridge) */
/* the alternative is just to check the directory exists */
- ret = SMB_VFS_STAT(conn, smb_fname_cpath);
+ ret = SMB_VFS_OPEN_SHARE_ROOT(conn, conn->cwd_fsp, conn->connectpath);
if (ret != 0) {
DBG_ERR("'%s' does not exist or permission denied "
"when connecting to [%s] Error was %s\n",
goto err_root_exit;
}
- if (!S_ISDIR(smb_fname_cpath->st.st_ex_mode)) {
+ if (!S_ISDIR(conn->cwd_fsp->fsp_name->st.st_ex_mode)) {
DBG_ERR("'%s' is not a directory, when connecting to "
"[%s]\n",
conn->connectpath,
goto err_root_exit;
}
- conn->base_share_dev = smb_fname_cpath->st.st_ex_dev;
+ conn->base_share_dev = conn->cwd_fsp->fsp_name->st.st_ex_dev;
/* Figure out the characteristics of the underlying filesystem. This
* assumes that all the filesystem mounted within a share path have
err_root_exit:
- TALLOC_FREE(smb_fname_cpath);
/* We must exit this function as root. */
if (geteuid() != 0) {
change_to_root_user();