Author: jra
Date: 2007-03-07 19:43:00 +0000 (Wed, 07 Mar 2007)
New Revision: 21749

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21749

Log:
Merge from SAMBA_3_0 to fix dfs referrel link problems.
Sync up with 3.0.
Jeremy.

Modified:
   branches/SAMBA_3_0_25/source/libsmb/clidfs.c
   branches/SAMBA_3_0_25/source/libsmb/errormap.c


Changeset:
Modified: branches/SAMBA_3_0_25/source/libsmb/clidfs.c
===================================================================
--- branches/SAMBA_3_0_25/source/libsmb/clidfs.c        2007-03-07 14:25:07 UTC 
(rev 21748)
+++ branches/SAMBA_3_0_25/source/libsmb/clidfs.c        2007-03-07 19:43:00 UTC 
(rev 21749)
@@ -354,13 +354,13 @@
        have_ip = True;
 }
 
-/********************************************************************
- split a dfs path into the server and share name components
-********************************************************************/
+/**********************************************************************
+ split a dfs path into the server, share name, and extrapath components
+**********************************************************************/
 
-static void split_dfs_path( const char *nodepath, fstring server, fstring 
share )
+static void split_dfs_path( const char *nodepath, fstring server, fstring 
share, fstring extrapath )
 {
-       char *p;
+       char *p, *q;
        pstring path;
 
        pstrcpy( path, nodepath );
@@ -368,7 +368,7 @@
        if ( path[0] != '\\' )
                return;
 
-       p = strrchr_m( path, '\\' );
+       p = strchr_m( path + 1, '\\' );
 
        if ( !p )
                return;
@@ -376,6 +376,16 @@
        *p = '\0';
        p++;
 
+       /* Look for any extra/deep path */
+       q = strchr_m(p, '\\');
+       if (q != NULL) {
+               *q = '\0';
+               q++;
+               fstrcpy( extrapath, q );
+       } else {
+               fstrcpy( extrapath, '\0' );
+       }
+       
        fstrcpy( share, p );
        fstrcpy( server, &path[1] );
 }
@@ -576,13 +586,13 @@
        size_t num_refs;
        uint16 consumed;
        struct cli_state *cli_ipc;
-       pstring fullpath, cleanpath;
+       pstring fullpath, cleanpath, extrapath;
        int pathlen;
        fstring server, share;
        struct cli_state *newcli;
        pstring newpath;
        pstring newmount;
-       char *ppath;
+       char *ppath, *temppath = NULL;
        
        SMB_STRUCT_STAT sbuf;
        uint32 attributes;
@@ -637,8 +647,14 @@
        consumed = MIN(pathlen, consumed );
        pstrcpy( targetpath, &fullpath[consumed/2] );
 
-       split_dfs_path( refs[0].dfspath, server, share );
+       split_dfs_path( refs[0].dfspath, server, share, extrapath );
        SAFE_FREE( refs );
+
+       if (strlen(extrapath) > 0) {
+               string_append(&temppath, extrapath);
+               string_append(&temppath, targetpath);
+               pstrcpy( targetpath, temppath );
+       }
        
        /* open the connection to the target path */
        
@@ -690,6 +706,7 @@
        pstring fullpath;
        BOOL res;
        uint16 cnum;
+       fstring newextrapath;
        
        if ( !cli || !sharename )
                return False;
@@ -725,7 +742,7 @@
                return False;
        }
        
-       split_dfs_path( refs[0].dfspath, newserver, newshare );
+       split_dfs_path( refs[0].dfspath, newserver, newshare, newextrapath );
 
        /* check that this is not a self-referral */
 

Modified: branches/SAMBA_3_0_25/source/libsmb/errormap.c
===================================================================
--- branches/SAMBA_3_0_25/source/libsmb/errormap.c      2007-03-07 14:25:07 UTC 
(rev 21748)
+++ branches/SAMBA_3_0_25/source/libsmb/errormap.c      2007-03-07 19:43:00 UTC 
(rev 21749)
@@ -1511,7 +1511,6 @@
        { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED },
        { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND },
        { ENOTDIR, ERRDOS, ERRbadpath,  NT_STATUS_NOT_A_DIRECTORY },
-       { ENAMETOOLONG, ERRDOS, 206, NT_STATUS_OBJECT_NAME_INVALID },
        { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR },
        { EBADF, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE },
        { EINVAL, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE },
@@ -1534,6 +1533,9 @@
 #ifdef EROFS
        { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED },
 #endif
+#ifdef ENAMETOOLONG
+       { ENAMETOOLONG, ERRDOS, 206, NT_STATUS_OBJECT_NAME_INVALID },
+#endif
 #ifdef EFBIG
        { EFBIG, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL },
 #endif

Reply via email to