From: Jeremy Allison Date: Mon, 19 May 2008 20:11:41 +0000 (-0700) Subject: Restructuring of code to fix #5460. Remove search X-Git-Tag: samba-3.0.29~6 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=e3ecb1828791e3e142dd84d7248c4ae70afe5e0c;p=samba.git Restructuring of code to fix #5460. Remove search by name code from conn, we were already doing the same check in the dfs_redirect() function, so move it into parse_dfs_path() instead. Jeremy. --- diff --git a/source/smbd/conn.c b/source/smbd/conn.c index ed8bdefe2e1..610e6419214 100644 --- a/source/smbd/conn.c +++ b/source/smbd/conn.c @@ -85,28 +85,6 @@ connection_struct *conn_find(unsigned cnum) return NULL; } -/**************************************************************************** - Find a conn given a service name. -****************************************************************************/ - -connection_struct *conn_find_byname(const char *service) -{ - connection_struct *conn; - - for (conn=Connections;conn;conn=conn->next) { - if (strequal(lp_servicename(SNUM(conn)),service)) { - if (conn != Connections) { - /* Promote if not first. */ - DLIST_PROMOTE(Connections, conn); - } - return conn; - } - } - - return NULL; -} - - /**************************************************************************** find first available connection slot, starting from a random position. The randomisation stops problems with the server dieing and clients diff --git a/source/smbd/msdfs.c b/source/smbd/msdfs.c index e89f24a28b4..19527eca058 100644 --- a/source/smbd/msdfs.c +++ b/source/smbd/msdfs.c @@ -33,6 +33,9 @@ extern uint32 global_client_caps; form /hostname/service/reqpath. We cope with either here. + If conn != NULL then ensure the provided service is + the one pointed to by the connection. + Unfortunately, due to broken clients who might set the SVAL(inbuf,smb_flg2) & FLAGS2_DFS_PATHNAMES bit and then send a local path, we have to cope with that too.... @@ -40,7 +43,8 @@ extern uint32 global_client_caps; JRA. **********************************************************************/ -static NTSTATUS parse_dfs_path(const char *pathname, +static NTSTATUS parse_dfs_path(connection_struct *conn, + const char *pathname, BOOL allow_wcards, struct dfs_path *pdp, BOOL *ppath_contains_wcard) @@ -114,7 +118,11 @@ static NTSTATUS parse_dfs_path(const char *pathname, } /* Is this really our servicename ? */ - if (NULL == conn_find_byname(servicename)) { + if (conn && !( strequal(servicename, lp_servicename(SNUM(conn))) + || (strequal(servicename, HOMES_NAME) + && strequal(lp_servicename(SNUM(conn)), + get_current_username()) )) ) { + DEBUG(10,("parse_dfs_path: %s is not our servicename\n", servicename)); @@ -507,7 +515,7 @@ static NTSTATUS dfs_redirect( connection_struct *conn, struct dfs_path dp; pstring targetpath; - status = parse_dfs_path(dfs_path, search_wcard_flag, &dp, ppath_contains_wcard); + status = parse_dfs_path(conn, dfs_path, search_wcard_flag, &dp, ppath_contains_wcard); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -534,15 +542,6 @@ static NTSTATUS dfs_redirect( connection_struct *conn, return NT_STATUS_OK; } - if (!( strequal(dp.servicename, lp_servicename(SNUM(conn))) - || (strequal(dp.servicename, HOMES_NAME) - && strequal(lp_servicename(SNUM(conn)), get_current_username()) )) ) { - - /* The given sharename doesn't match this connection. */ - - return NT_STATUS_OBJECT_PATH_NOT_FOUND; - } - status = dfs_path_lookup(conn, dfs_path, &dp, search_wcard_flag, NULL, targetpath); if (!NT_STATUS_IS_OK(status)) { @@ -616,7 +615,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx, *self_referralp = False; - status = parse_dfs_path(dfs_path, False, &dp, &dummy); + status = parse_dfs_path(NULL, dfs_path, False, &dp, &dummy); if (!NT_STATUS_IS_OK(status)) { return status; } @@ -1012,7 +1011,7 @@ BOOL create_junction(const char *dfs_path, struct junction_map *jucn) BOOL dummy; struct dfs_path dp; - NTSTATUS status = parse_dfs_path(dfs_path, False, &dp, &dummy); + NTSTATUS status = parse_dfs_path(NULL, dfs_path, False, &dp, &dummy); if (!NT_STATUS_IS_OK(status)) { return False;