Samba MSDFS and tree structure problem

Shirish Kalele kalele at veritas.com
Mon Aug 20 23:22:14 GMT 2001


Hi,

Here's a patch (against 2.2) that will allow dfs links at any level under
the DFS root.

Let me know if you have any issues with it..

Cheers,
Shirish

Index: include/msdfs.h
===================================================================
RCS file: /data/cvs/samba/source/include/msdfs.h,v
retrieving revision 1.5
diff -u -r1.5 msdfs.h
--- include/msdfs.h	26 May 2000 17:10:38 -0000	1.5
+++ include/msdfs.h	20 Aug 2001 23:15:00 -0000
@@ -53,10 +53,9 @@
 
 struct dfs_path
 {
-  pstring hostname;
-  pstring servicename;
-  pstring volumename;
-  pstring restofthepath;
+	pstring hostname;
+	pstring servicename;
+	pstring reqpath;
 };
 
 #ifdef WITH_MSDFS
Index: msdfs/msdfs.c
===================================================================
RCS file: /data/cvs/samba/source/msdfs/msdfs.c,v
retrieving revision 1.10.4.6
diff -u -r1.10.4.6 msdfs.c
--- msdfs/msdfs.c	19 Aug 2001 17:21:02 -0000	1.10.4.6
+++ msdfs/msdfs.c	20 Aug 2001 23:15:00 -0000
@@ -33,13 +33,11 @@
 
 static void create_nondfs_path(char* pathname, struct dfs_path* pdp)
 {
-	pstrcpy(pathname,pdp->volumename); 
-	pstrcat(pathname,"\\"); 
-	pstrcat(pathname,pdp->restofthepath); 
+	pstrcpy(pathname,pdp->reqpath); 
 }
 
 /**********************************************************************
-  Parse the pathname  of the form \hostname\service\volume\restofthepath
+  Parse the pathname  of the form \hostname\service\reqpath
   into the dfs_path structure 
  **********************************************************************/
 
@@ -76,20 +74,15 @@
 	pstrcpy(pdp->servicename,temp);
 	DEBUG(10,("servicename: %s\n",pdp->servicename));
 
-	/* parse out volumename */
-	temp = p+1;
-	p = strchr(temp,'\\');
-	if(p == NULL) {
-		pstrcpy(pdp->volumename,temp);
-		return True;
+	/* rest is reqpath */
+	pstrcpy(pdp->reqpath, p+1);
+	p = pdp->reqpath;
+	while (*p) {
+		if (*p == '\\') *p = '/';
+		p++;
 	}
-	*p = '\0';
-	pstrcpy(pdp->volumename,temp);
-	DEBUG(10,("volumename: %s\n",pdp->volumename));
 
-	/* remaining path .. */
-	pstrcpy(pdp->restofthepath,p+1);
-	DEBUG(10,("rest of the path: %s\n",pdp->restofthepath));
+	DEBUG(10,("rest of the path: %s\n",pdp->reqpath));
 	return True;
 }
 
@@ -160,7 +153,7 @@
 	}
 
 	pstrcpy(jn->service_name,dp.servicename);
-	pstrcpy(jn->volume_name,dp.volumename);
+	pstrcpy(jn->volume_name,dp.reqpath);
 	return True;
 }
 
@@ -312,7 +305,7 @@
 	/* check if need to redirect */
 	fstrcpy(path, conn->connectpath);
 	fstrcat(path, "/");
-	fstrcat(path, dp.volumename);
+	fstrcat(path, dp.reqpath);
 	if(is_msdfs_link(conn, path)) {
 		DEBUG(4,("dfs_redirect: Redirecting %s\n",temp));
 		return True;
@@ -346,8 +339,8 @@
 
 	parse_dfs_path(pathname,&dp);
 	DEBUG(8,("dfs_findfirst_redirect: path %s is in Dfs. dp.restofthepath=.%s.\n",
-				pathname,dp.restofthepath));
-	if(!(*(dp.restofthepath))) {
+				pathname,dp.reqpath));
+	if(!(*(dp.reqpath))) {
 		create_nondfs_path(pathname,&dp);
 		return False;
 	}
Index: rpc_server/srv_dfs_nt.c
===================================================================
RCS file: /data/cvs/samba/source/rpc_server/srv_dfs_nt.c,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 srv_dfs_nt.c
--- rpc_server/srv_dfs_nt.c	13 Jun 2001 00:41:44 -0000	1.1.2.4
+++ rpc_server/srv_dfs_nt.c	20 Aug 2001 23:15:00 -0000
@@ -56,7 +56,7 @@
 
   if (user.uid != 0) {
 	DEBUG(10,("_dfs_add: uid != 0. Access denied.\n"));
-	return ERROR_ACCESS_DENIED;
+	return NT_STATUS_ACCESS_DENIED;
   }
 
   unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1);
@@ -122,7 +122,7 @@
 
   if (user.uid != 0) {
 	DEBUG(10,("_dfs_remove: uid != 0. Access denied.\n"));
-	return ERROR_ACCESS_DENIED;
+	return NT_STATUS_ACCESS_DENIED;
   }
 
   unistr2_to_ascii(dfspath, &q_u->DfsEntryPath, sizeof(dfspath)-1);

On Mon, 20 Aug 2001, Shirish Kalele wrote:

>Hi,
>
>Samba doesn't handle dfs links in subdirectories of dfs roots as yet. It
>shouldn't be very difficult to do, and I've been meaning to do it, but
>have been distracted with other stuff. Look for it in the next release.
>
>- Shirish
>
>On Mon, 20 Aug 2001, [iso-8859-2] Michal Ambroz wrote:
>
>>   Hello,
>>   please was there anyone successfull on making ms-dfs links in
>>directories in ms-dfs root directory? Situation is this, I have some
>>hierarchical structure in ms-dfs.
>>
>>/
>> |... ORG1               -> \\server1\org1_share
>> |... ORG2               -> \\server2\org2_share
>> |... ORG3/
>> |        |... DIVISION1 -> \\server1\org3_div1_share
>> |        |... DIVISION2 -> \\server3\org3_div2_share
>> |... ORG4               -> \\server4\org4_share
>>
>>
>>    I am able to set properly links in directory of dfs-root (ORG1,
>>ORG2, ORG4) without problems and it is working on WinXX, Win NT, Win
>>2000. But links in ORG3 directory are not working.
>>
>>
>>    I have followed the debug logs and it seems that when it cames to
>>windows to see what is in directory of ORG3 samba correctly detects
>>that DIVISION1 and DIVISION2 are not common files, but dfs links and
>>it masquerades them as directories. But when you try to enter that
>>directory, it is treated as common unix file (nonexisting) and it
>>ends with and error "Wrong disc or directory
>>(\\DFSServer\dfsroot\ORG3\DIVISION1)".
>>
>>    Please has anyone faced this problem? Have you any hint where to
>>look for and posibly which function has to be hacked and how?
>>
>>                            thank you very much
>>
>>                                        Michal Ambroz
>>(O_O)
>>
>>______________________________________________________________________
>>Vylepsete svuj prohlizec Internetu na http://software.seznam.cz/listicka
>>
>
>





More information about the samba-technical mailing list