return NT_STATUS_OK;
}
-/*****************************************************************
- Decides if a dfs pathname should be redirected or not.
- If not, the pathname is converted to a tcon-relative local unix path
-
- search_wcard_flag: this flag performs 2 functions both related
- to searches. See resolve_dfs_path() and parse_dfs_path_XX()
- for details.
-
- This function can return NT_STATUS_OK, meaning use the returned path as-is
- (mapped into a local path).
- or NT_STATUS_NOT_COVERED meaning return a DFS redirect, or
- any other NT_STATUS error which is a genuine error to be
- returned to the client.
-*****************************************************************/
-
-NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
- connection_struct *conn,
- const char *path_in,
- uint32_t ucf_flags,
- bool allow_broken_path,
- NTTIME *_twrp,
- char **pp_path_out)
-{
- char *hostname = NULL;
- char *servicename = NULL;
- char *reqpath = NULL;
- bool servicename_matches = false;
- NTSTATUS status;
-
- status = parse_dfs_path(ctx,
- conn,
- path_in,
- allow_broken_path,
- &hostname,
- &servicename,
- &reqpath);
- if (!NT_STATUS_IS_OK(status)) {
- return status;
- }
-
- if (reqpath[0] == '\0') {
- *pp_path_out = talloc_strdup(ctx, "");
- if (!*pp_path_out) {
- return NT_STATUS_NO_MEMORY;
- }
- DEBUG(5,("dfs_redirect: self-referral.\n"));
- return NT_STATUS_OK;
- }
-
- /* If dfs pathname for a non-dfs share, convert to tcon-relative
- path and return OK */
-
- if (!lp_msdfs_root(SNUM(conn))) {
- *pp_path_out = talloc_strdup(ctx, reqpath);
- if (!*pp_path_out) {
- return NT_STATUS_NO_MEMORY;
- }
- return NT_STATUS_OK;
- }
-
- /* If it looked like a local path (zero hostname/servicename)
- * just treat as a tcon-relative path. */
-
- if (hostname[0] == '\0' && servicename[0] == '\0') {
- *pp_path_out = talloc_strdup(ctx, reqpath);
- if (!*pp_path_out) {
- return NT_STATUS_NO_MEMORY;
- }
- return NT_STATUS_OK;
- }
-
- servicename_matches = msdfs_servicename_matches_connection(
- conn,
- servicename,
- conn->session_info->unix_info->sanitized_username);
- if (!servicename_matches) {
- /* The given sharename doesn't match this connection. */
- return NT_STATUS_OBJECT_PATH_NOT_FOUND;
- }
-
- status = dfs_path_lookup(ctx,
- conn,
- path_in,
- reqpath,
- ucf_flags,
- _twrp, /* twrp. */
- NULL, /* size_t *consumedcntp */
- NULL, /* struct referral **ppreflist */
- NULL); /* size_t *preferral_count */
- if (!NT_STATUS_IS_OK(status)) {
- if (NT_STATUS_EQUAL(status, NT_STATUS_PATH_NOT_COVERED)) {
- DEBUG(3,("dfs_redirect: Redirecting %s\n", path_in));
- } else {
- DEBUG(10,("dfs_redirect: dfs_path_lookup "
- "failed for %s with %s\n",
- path_in, nt_errstr(status) ));
- }
- return status;
- }
-
- DEBUG(3,("dfs_redirect: Not redirecting %s.\n", path_in));
-
- /* Form non-dfs tcon-relative path */
- *pp_path_out = talloc_strdup(ctx, reqpath);
- if (!*pp_path_out) {
- return NT_STATUS_NO_MEMORY;
- }
-
- DEBUG(3,("dfs_redirect: Path %s converted to non-dfs path %s\n",
- path_in,
- *pp_path_out));
-
- return NT_STATUS_OK;
-}
-
/**********************************************************************
Return a self referral.
**********************************************************************/