summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/include/msdfs.h16
-rw-r--r--source3/include/proto.h22
-rw-r--r--source3/msdfs/README31
-rw-r--r--source3/msdfs/msdfs.c516
-rw-r--r--source3/msdfs/msdfs_tdb.c268
-rw-r--r--source3/msdfs/parse_dfs_map.c280
-rw-r--r--source3/param/loadparm.c32
-rw-r--r--source3/rpc_server/srv_srvsvc.c2
-rw-r--r--source3/smbd/dosmode.c2
-rw-r--r--source3/smbd/server.c11
-rw-r--r--source3/smbd/trans2.c15
12 files changed, 382 insertions, 815 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 840d8c4b52..192514cf87 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -174,7 +174,7 @@ PRINTING_OBJ = printing/pcap.o printing/print_svid.o printing/print_cups.o print
PRINTBACKEND_OBJ = printing/printing.o printing/lpq_parse.o printing/nt_printing.o
-MSDFS_OBJ = msdfs/msdfs.o msdfs/msdfs_tdb.o msdfs/parse_dfs_map.o
+MSDFS_OBJ = msdfs/msdfs.o
SMBD_OBJ = $(SMBD_OBJ1) $(MSDFS_OBJ) $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) \
$(RPC_SERVER_OBJ) $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) \
diff --git a/source3/include/msdfs.h b/source3/include/msdfs.h
index 0c2e3c14df..ac054307b5 100644
--- a/source3/include/msdfs.h
+++ b/source3/include/msdfs.h
@@ -28,6 +28,13 @@
#define DFSREF_REFERRAL_SERVER 0x1
#define DFSREF_STORAGE_SERVER 0x2
+/* Referral sizes */
+#define VERSION2_REFERRAL_SIZE 0x16
+#define VERSION3_REFERRAL_SIZE 0x22
+#define REFERRAL_HEADER_SIZE 0x08
+
+/* Maximum number of referrals for each Dfs volume */
+#define MAX_REFERRAL_COUNT 256
struct referral
{
@@ -66,14 +73,9 @@ struct dfs_path
return(dfs_path_error(inbuf,outbuf)); }
#define init_dfsroot(conn, inbuf, outbuf) \
-{ if(*lp_dfsmap(SNUM(conn)) && lp_host_msdfs()) { \
+{ if(lp_msdfs_root(SNUM(conn)) && lp_host_msdfs()) \
SSVAL(outbuf, smb_vwv2, SMB_SHARE_IN_DFS | SMB_SUPPORT_SEARCH_BITS); \
- if(lp_dfsmap_loaded(SNUM(conn))) \
- msdfs_open(False); \
- else { \
- DEBUG(3,("msdfs map database not initialized!\n")); \
- pstrcpy(lp_dfsmap(SNUM(conn)),""); \
- } } }
+}
#else
/* Stub macros */
diff --git a/source3/include/proto.h b/source3/include/proto.h
index b19d3d8f5c..c96c781130 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -873,6 +873,7 @@ BOOL posix_locking_end(void);
/*The following definitions come from msdfs/msdfs.c */
+BOOL is_msdfs_volume(connection_struct* conn, char* path);
BOOL dfs_redirect(char* pathname, connection_struct* conn);
BOOL dfs_findfirst_redirect(char* pathname, connection_struct* conn);
int setup_dfs_referral(char* pathname, int max_referral_level,
@@ -880,20 +881,8 @@ int setup_dfs_referral(char* pathname, int max_referral_level,
int dfs_path_error(char* inbuf, char* outbuf);
int setup_dfs_referral(char* pathname, int max_referral_level,
char** ppdata);
-
-/*The following definitions come from msdfs/msdfs_tdb.c */
-
-BOOL msdfs_open(BOOL update);
-BOOL add_junction_entry(struct junction_map* junction);
-BOOL get_junction_entry(struct junction_map* junction);
-BOOL isDfsShare(char* svc,char* vol);
-void msdfs_close(void);
-void msdfs_end(void);
-
-/*The following definitions come from msdfs/parse_dfs_map.c */
-
-void load_dfsmaps(void);
-void load_dfsmaps(void);
+BOOL is_msdfs_volume(connection_struct* conn, char* path);
+void unistr_to_dos(char* dst,char* src) ;
/*The following definitions come from nmbd/asyncdns.c */
@@ -1408,8 +1397,8 @@ char *lp_veto_files(int );
char *lp_hide_files(int );
char *lp_veto_oplocks(int );
char *lp_driverlocation(int );
-char *lp_dfsmap(int );
-BOOL lp_dfsmap_loaded(int );
+
+BOOL lp_msdfs_root(int );
BOOL lp_autoloaded(int );
BOOL lp_preexec_close(int );
BOOL lp_rootpreexec_close(int );
@@ -1471,7 +1460,6 @@ BOOL lp_add_home(char *pszHomename, int iDefaultService, char *pszHomedir);
int lp_add_service(char *pszService, int iDefaultService);
BOOL lp_add_printer(char *pszPrintername, int iDefaultService);
BOOL lp_file_list_changed(void);
-void set_dfsmap_loaded(int i,BOOL b);
void *lp_local_ptr(int snum, void *ptr);
BOOL lp_do_parameter(int snum, char *pszParmName, char *pszParmValue);
BOOL lp_is_default(int snum, struct parm_struct *parm);
diff --git a/source3/msdfs/README b/source3/msdfs/README
index 62fded3f55..0e924b31dc 100644
--- a/source3/msdfs/README
+++ b/source3/msdfs/README
@@ -5,23 +5,28 @@ Currently, MS Dfs support is a configure time parameter (--with-msdfs). Can be c
To have a server announce itself as a Dfs server, add a "host msdfs=yes" entry to smb.conf.
-To make a share a Dfs root, add a "dfs map" entry to the share definition in the smb.conf file.
+To make a share a Dfs root, add a "msdfs root=yes" entry to the share definition
+in the smb.conf file.
e.g.
[pub]
- dfs map = /usr/local/samba/lib/pub_dfs_map
+ path = /export/publicsmb
+ msdfs root = yes
-The pub_dfs_map file would contain a list of junction points and their referral paths.
+To create dfs volumes/junctions in the share, create symbolic links of the
+format msdfs:server1\share1,server2\share2 and so on.
-In our example, if you have a directory pub_dir1/ in the pub share and want to make it a dfs junction point to \\machineX\pub, you can have an entry in the pub_dfs_map file as:
+In the above example, create a dfs volume "dfsstorage" in the [pub] share as:
+cd /export/publicsmb
+ln -s msdfs:serverA\\share dfsstorage
-pub_dir1
-\\machineX\pub:0:600
+Clicking on dfsstorage from a dfs-aware client will show you the contents of
+\\serverA\share
-where: 0 is the proximity of the server. If you have multiple referred servers for one junction point, you can set up preferences among these using this field.
-& 600 is the number of seconds the client must cache the referral. After this time period, the smb client supposedly should contact the server again for a fresh referral.
+Shares with "msdfs root = no" (which is the default) entries are served as normal
+shares and the client stops talking Dfs with Samba after a tconX.
-NOTE: You can have multiple referral paths for one junction point. Currently, the parser code depends on the leading \ to determine if the line is a referral or a new junction point.
-
-Shares with no "dfs map" entries are served as normal shares and the client stops talking Dfs with Samba after a tconX.
-
-TODO: Dynamically showing junction points to dfs clients alone,probably in the findfirst reply. Currently, you need to have directories on the samba server as token junction points.
+NOTES:
+* Windows clients need to be rebooted if a non-dfs root is made a dfs root or
+ vice versa. A better option is to introduce a new share and make it the dfs root.
+* Currently there's a restriction that msdfs symlink names should be all
+ lowercase.
diff --git a/source3/msdfs/msdfs.c b/source3/msdfs/msdfs.c
index aadc63f04e..1f39aa79fd 100644
--- a/source3/msdfs/msdfs.c
+++ b/source3/msdfs/msdfs.c
@@ -27,10 +27,6 @@ extern uint32 global_client_caps;
#ifdef MS_DFS
-#define VERSION2_REFERRAL_SIZE 0x16
-#define VERSION3_REFERRAL_SIZE 0x22
-#define REFERRAL_HEADER_SIZE 0x08
-
static void create_nondfs_path(char* pathname, struct dfs_path* pdp)
{
pstrcpy(pathname,pdp->volumename);
@@ -50,15 +46,6 @@ static BOOL parse_dfs_path(char* pathname, struct dfs_path* pdp)
ZERO_STRUCTP(pdp);
- /* strip off all \'s from the beginning */
- /* while(*temp=='\\') temp++;
-
- DEBUG(10,("temp in parse_dfs_path : .%s.\n",temp));
-
- remove any trailing \'s
- if(temp[strlen(temp)-1] == '\\') temp[strlen(temp)-1]='\0';
-*/
-
trim_string(temp,"\\","\\");
DEBUG(10,("temp in parse_dfs_path: .%s. after trimming \\'s\n",temp));
@@ -101,6 +88,120 @@ static BOOL parse_dfs_path(char* pathname, struct dfs_path* pdp)
return True;
}
+/**********************************************************************
+ Parse the contents of a symlink to verify if it is an msdfs referral
+ A valid referral is of the form: msdfs:server1\share1,server2\share2
+ **********************************************************************/
+static BOOL parse_symlink(char* buf,struct referral** preflist, int* refcount)
+{
+ pstring temp;
+ char* prot;
+ char* alt_path[MAX_REFERRAL_COUNT];
+ int count=0, i;
+ struct referral* reflist;
+
+ pstrcpy(temp,buf);
+
+ prot = strtok(temp,":");
+
+ if(!strequal(prot, "msdfs"))
+ return False;
+
+ /* It's an msdfs referral */
+ if(!preflist)
+ return True;
+
+ /* parse out the alternate paths */
+ while(((alt_path[count] = strtok(NULL,",")) != NULL)
+ && count<MAX_REFERRAL_COUNT)
+ count++;
+
+ DEBUG(10,("parse_symlink: count=%d\n", count));
+ reflist = *preflist = (struct referral*) malloc(count *
+ sizeof(struct referral));
+ if(reflist == NULL)
+ {
+ DEBUG(0,("parse_symlink: Malloc failed!\n"));
+ return False;
+ }
+
+ for(i=0;i<count;i++)
+ {
+ pstrcpy(reflist[i].alternate_path, "\\");
+ pstrcat(reflist[i].alternate_path, alt_path[i]);
+ reflist[i].proximity = 0;
+ reflist[i].ttl = REFERRAL_TTL;
+ DEBUG(10, ("parse_symlink: Created alt path: %s\n",
+ reflist[i].alternate_path));
+ }
+
+ if(refcount)
+ *refcount = count;
+
+ return True;
+}
+
+BOOL is_msdfs_volume(connection_struct* conn, char* path)
+{
+ SMB_STRUCT_STAT st;
+ pstring referral;
+
+ if(!path || !conn)
+ return False;
+
+ strlower(path);
+
+ if(conn->vfs_ops.lstat(dos_to_unix(path,False),&st) != 0)
+ {
+ DEBUG(5,("is_msdfs_volume: %s does not exist.\n",path));
+ return False;
+ }
+
+ if(st.st_mode & S_IFLNK)
+ {
+ /* open the link and read it */
+ readlink(path, referral, sizeof(pstring));
+ DEBUG(5,("is_msdfs_volume: %s -> %s\n",path,referral));
+ if(parse_symlink(referral, NULL, NULL))
+ return True;
+ }
+ return False;
+}
+
+static BOOL get_referred_path(struct junction_map* junction)
+{
+ fstring path;
+ pstring buf;
+ SMB_STRUCT_STAT st;
+ int snum = lp_servicenumber(junction->service_name);
+
+ /* form the path */
+ fstrcpy(path, lp_pathname(snum));
+ fstrcat(path, "/");
+
+ strlower(junction->volume_name);
+
+ fstrcat(path, junction->volume_name);
+
+ DEBUG(5,("get_referred_path: lstat target: %s\n", path));
+
+ if(lstat(dos_to_unix(path, False),&st) != 0)
+ {
+ DEBUG(5,("get_referred_path: %s does not exist.\n",path));
+ return False;
+ }
+
+ if(st.st_mode & S_IFLNK)
+ {
+ /* open the link and read it to get the dfs referral */
+ readlink(path, buf, sizeof(buf));
+ DEBUG(5,("get_referred_path: Referral: %s\n",buf));
+ if(parse_symlink(buf, &junction->referral_list,
+ &junction->referral_count))
+ return True;
+ }
+ return False;
+}
/**************************************************************
Decides if given pathname is Dfs and if it should be redirected
@@ -110,10 +211,11 @@ BOOL dfs_redirect(char* pathname, connection_struct* conn)
{
struct dfs_path dp;
pstring temp;
+ fstring path;
pstrcpy(temp,pathname);
- if(lp_dfsmap(SNUM(conn))==NULL || *lp_dfsmap(SNUM(conn))=='\0')
+ if(!lp_msdfs_root(SNUM(conn)) )
return False;
parse_dfs_path(pathname,&dp);
@@ -122,7 +224,10 @@ BOOL dfs_redirect(char* pathname, connection_struct* conn)
return False;
/* check if need to redirect */
- if(isDfsShare(dp.servicename,dp.volumename))
+ fstrcpy(path, conn->connectpath);
+ fstrcat(path, "/");
+ fstrcat(path, dp.volumename);
+ if(is_msdfs_volume(conn, path))
{
DEBUG(4,("dfs_redirect: Redirecting %s\n",temp));
return True;
@@ -167,6 +272,185 @@ BOOL dfs_findfirst_redirect(char* pathname, connection_struct* conn)
}
}
+static int setup_ver2_dfs_referral(char* pathname, char** ppdata,
+ struct junction_map* junction,
+ BOOL self_referral)
+{
+ char* pdata = *ppdata;
+
+ unsigned char uni_requestedpath[1024];
+ int uni_reqpathoffset1,uni_reqpathoffset2;
+ int uni_curroffset;
+ int requestedpathlen=0;
+ int offset;
+ int reply_size = 0;
+ int i=0;
+
+ DEBUG(10,("setting up version2 referral\nRequested path:\n"));
+
+ requestedpathlen = (dos_struni2(uni_requestedpath,pathname,512)+1)*2;
+
+ dump_data(10,uni_requestedpath,requestedpathlen);
+
+ DEBUG(10,("ref count = %u\n",junction->referral_count));
+
+ uni_reqpathoffset1 = REFERRAL_HEADER_SIZE +
+ VERSION2_REFERRAL_SIZE * junction->referral_count;
+
+ uni_reqpathoffset2 = uni_reqpathoffset1 + requestedpathlen;
+
+ uni_curroffset = uni_reqpathoffset2 + requestedpathlen;
+
+ reply_size = REFERRAL_HEADER_SIZE + VERSION2_REFERRAL_SIZE*junction->referral_count +
+ 2 * requestedpathlen;
+ DEBUG(10,("reply_size: %u\n",reply_size));
+
+ /* add up the unicode lengths of all the referral paths */
+ for(i=0;i<junction->referral_count;i++)
+ {
+ DEBUG(10,("referral %u : %s\n",i,junction->referral_list[i].alternate_path));
+ reply_size += (strlen(junction->referral_list[i].alternate_path)+1)*2;
+ }
+
+ DEBUG(10,("reply_size = %u\n",reply_size));
+ /* add the unexplained 0x16 bytes */
+ reply_size += 0x16;
+
+ pdata = *ppdata = Realloc(pdata,reply_size);
+ if(pdata == NULL)
+ {
+ DEBUG(0,("malloc failed for Realloc!\n"));
+ return -1;
+ }
+
+ /* copy in the dfs requested paths.. required for offset calculations */
+ memcpy(pdata+uni_reqpathoffset1,uni_requestedpath,requestedpathlen);
+ memcpy(pdata+uni_reqpathoffset2,uni_requestedpath,requestedpathlen);
+
+
+ /* create the header */
+ SSVAL(pdata,0,requestedpathlen-2); /* path consumed */
+ SSVAL(pdata,2,junction->referral_count); /* number of referral in this pkt */
+ if(self_referral)
+ SIVAL(pdata,4,DFSREF_REFERRAL_SERVER | DFSREF_STORAGE_SERVER);
+ else
+ SIVAL(pdata,4,DFSREF_STORAGE_SERVER);
+
+ offset = 8;
+ /* add the referral elements */
+ for(i=0;i<junction->referral_count;i++)
+ {
+ struct referral* ref = &(junction->referral_list[i]);
+ int unilen;
+
+ SSVAL(pdata,offset,2); /* version 2 */
+ SSVAL(pdata,offset+2,VERSION2_REFERRAL_SIZE);
+ if(self_referral)
+ SSVAL(pdata,offset+4,1);
+ else
+ SSVAL(pdata,offset+4,0);
+ SSVAL(pdata,offset+6,0); /* ref_flags :use path_consumed bytes? */
+ SIVAL(pdata,offset+8,ref->proximity);
+ SIVAL(pdata,offset+12,ref->ttl);
+
+ SSVAL(pdata,offset+16,uni_reqpathoffset1-offset);
+ SSVAL(pdata,offset+18,uni_reqpathoffset2-offset);
+ /* copy referred path into current offset */
+ unilen = (dos_struni2(pdata+uni_curroffset,ref->alternate_path,512)
+ +1)*2;
+ SSVAL(pdata,offset+20,uni_curroffset-offset);
+
+ uni_curroffset += unilen;
+ offset += VERSION2_REFERRAL_SIZE;
+ }
+ /* add in the unexplained 22 (0x16) bytes at the end */
+ memset(pdata+uni_curroffset,'\0',0x16);
+ free(junction->referral_list);
+ return reply_size;
+}
+
+static int setup_ver3_dfs_referral(char* pathname, char** ppdata,
+ struct junction_map* junction,
+ BOOL self_referral)
+{
+ char* pdata = *ppdata;
+
+ unsigned char uni_reqpath[1024];
+ int uni_reqpathoffset1, uni_reqpathoffset2;
+ int uni_curroffset;
+ int reply_size = 0;
+
+ int reqpathlen = 0;
+ int offset,i=0;
+
+ DEBUG(10,("setting up version3 referral\n"));
+
+ reqpathlen = (dos_struni2(uni_reqpath,pathname,512)+1)*2;
+
+ dump_data(10,uni_reqpath,reqpathlen);
+
+ uni_reqpathoffset1 = REFERRAL_HEADER_SIZE + VERSION3_REFERRAL_SIZE *
+ junction->referral_count;
+ uni_reqpathoffset2 = uni_reqpathoffset1 + reqpathlen;
+ reply_size = uni_curroffset = uni_reqpathoffset2 + reqpathlen;
+
+ for(i=0;i<junction->referral_count;i++)
+ {
+ DEBUG(10,("referral %u : %s\n",i,junction->referral_list[i].alternate_path));
+ reply_size += (strlen(junction->referral_list[i].alternate_path)+1)*2;
+ }
+
+ pdata = *ppdata = Realloc(pdata,reply_size);
+ if(pdata == NULL)
+ {
+ DEBUG(0,("version3 referral setup: malloc failed for Realloc!\n"));
+ return -1;
+ }
+
+ /* create the header */
+ SSVAL(pdata,0,reqpathlen-2); /* path consumed */
+ SSVAL(pdata,2,junction->referral_count); /* number of referral in this pkt */
+ if(self_referral)
+ SIVAL(pdata,4,DFSREF_REFERRAL_SERVER | DFSREF_STORAGE_SERVER);
+ else
+ SIVAL(pdata,4,DFSREF_STORAGE_SERVER);
+
+ /* copy in the reqpaths */
+ memcpy(pdata+uni_reqpathoffset1,uni_reqpath,reqpathlen);
+ memcpy(pdata+uni_reqpathoffset2,uni_reqpath,reqpathlen);
+
+ offset = 8;
+ for(i=0;i<junction->referral_count;i++)
+ {
+ struct referral* ref = &(junction->referral_list[i]);
+ int unilen;
+
+ SSVAL(pdata,offset,3); /* version 3 */
+ SSVAL(pdata,offset+2,VERSION3_REFERRAL_SIZE);
+ if(self_referral)
+ SSVAL(pdata,offset+4,1);
+ else
+ SSVAL(pdata,offset+4,0);
+
+ SSVAL(pdata,offset+6,0); /* ref_flags :use path_consumed bytes? */
+ SIVAL(pdata,offset+8,ref->ttl);
+
+ SSVAL(pdata,offset+12,uni_reqpathoffset1-offset);
+ SSVAL(pdata,offset+14,uni_reqpathoffset2-offset);
+ /* copy referred path into current offset */
+ unilen = (dos_struni2(pdata+uni_curroffset,ref->alternate_path,512)
+ +1)*2;
+ SSVAL(pdata,offset+16,uni_curroffset-offset);
+ /* copy 0x10 bytes of 00's in the ServiceSite GUID */
+ memset(pdata+offset+18,'\0',16);
+
+ uni_curroffset += unilen;
+ offset += VERSION3_REFERRAL_SIZE;
+ }
+ free(junction->referral_list);
+ return reply_size;
+}
+
/******************************************************************
* Set up the Dfs referral for the dfs pathname
******************************************************************/
@@ -179,7 +463,6 @@ int setup_dfs_referral(char* pathname, int max_referral_level,
BOOL self_referral;
- char* pdata = *ppdata;
int reply_size = 0;
ZERO_STRUCT(junction);
@@ -189,24 +472,24 @@ int setup_dfs_referral(char* pathname, int max_referral_level,
/* check if path is dfs : check hostname is the first token */
if(global_myname && (strcasecmp(global_myname,dp.hostname)!=0))
{
- DEBUG(4,("Invalid DFS referral request for %s\n",pathname));
+ DEBUG(4,("setup_dfs_referral: Invalid DFS referral request for %s\n",
+ pathname));
return -1;
}
/* Check for a non-DFS share */
- {
- char* map = lp_dfsmap(lp_servicenumber(dp.servicename));
- DEBUG(10,("lp_dfsmap in setup dfs referral: .%s.\n",map ));
-
- if(map == NULL || (*map == '\0'))
- return -1;
- }
+ if(!lp_msdfs_root(lp_servicenumber(dp.servicename)))
+ {
+ DEBUG(4,("setup_dfs_referral: %s is not an msdfs root.\n",
+ dp.servicename));
+ return -1;
+ }
pstrcpy(junction.service_name,dp.servicename);
pstrcpy(junction.volume_name,dp.volumename);
/* get the junction entry */
- if(!get_junction_entry(&junction))
+ if(!get_referred_path(&junction))
{
/* refer the same pathname, create a standard referral struct */
@@ -230,7 +513,7 @@ int setup_dfs_referral(char* pathname, int max_referral_level,
if( DEBUGLVL( 3 ) )
{
int i=0;
- dbgtext("setup_dfs_referral: Referring client request for %s to alternate path(s):",pathname);
+ dbgtext("setup_dfs_referral: Path %s to alternate path(s):",pathname);
for(i=0;i<junction.referral_count;i++)
dbgtext(" %s",junction.referral_list[i].alternate_path);
dbgtext(".\n");
@@ -238,185 +521,37 @@ int setup_dfs_referral(char* pathname, int max_referral_level,
}
/* create the referral depeding on version */
- DEBUG(10,("MAX_REFERRAL_LEVEL :%d\n",max_referral_level));
+ DEBUG(10,("max_referral_level :%d\n",max_referral_level));
if(max_referral_level<2 || max_referral_level>3) max_referral_level = 2;
switch(max_referral_level)
{
case 2:
{
- unsigned char uni_requestedpath[1024];
- int uni_reqpathoffset1,uni_reqpathoffset2;
- int uni_curroffset;
- int requestedpathlen=0;
- int offset;
- int i=0;
-
- DEBUG(10,("setting up version2 referral\nRequested path:\n"));
-
- requestedpathlen = (dos_struni2(uni_requestedpath,pathname,512)+1)*2;
-
- dump_data(10,uni_requestedpath,requestedpathlen);
-
- DEBUG(10,("ref count = %u\n",junction.referral_count));
-
- uni_reqpathoffset1 = REFERRAL_HEADER_SIZE +
- VERSION2_REFERRAL_SIZE * junction.referral_count;
-
- uni_reqpathoffset2 = uni_reqpathoffset1 + requestedpathlen;
-
- uni_curroffset = uni_reqpathoffset2 + requestedpathlen;
-
- reply_size = REFERRAL_HEADER_SIZE + VERSION2_REFERRAL_SIZE*junction.referral_count +
- 2 * requestedpathlen;
- DEBUG(10,("reply_size: %u\n",reply_size));
-
- /* add up the unicode lengths of all the referral paths */
- for(i=0;i<junction.referral_count;i++)
- {
- DEBUG(10,("referral %u : %s\n",i,junction.referral_list[i].alternate_path));
- reply_size += (strlen(junction.referral_list[i].alternate_path)+1)*2;
- }
-
- DEBUG(10,("reply_size = %u\n",reply_size));
- /* add the unexplained 0x16 bytes */
- reply_size += 0x16;
-
- pdata = *ppdata = Realloc(pdata,reply_size);
- if(pdata == NULL)
- {
- DEBUG(0,("malloc failed for Realloc!\n"));
- return -1;
- }
-
- /* copy in the dfs requested paths.. required for offset calculations */
- memcpy(pdata+uni_reqpathoffset1,uni_requestedpath,requestedpathlen);
- memcpy(pdata+uni_reqpathoffset2,uni_requestedpath,requestedpathlen);
-
-
- /* create the header */
- SSVAL(pdata,0,requestedpathlen-2); /* path consumed */
- SSVAL(pdata,2,junction.referral_count); /* number of referral in this pkt */
- if(self_referral)
- SIVAL(pdata,4,DFSREF_REFERRAL_SERVER | DFSREF_STORAGE_SERVER);
- else
- SIVAL(pdata,4,DFSREF_STORAGE_SERVER);
-
- offset = 8;
- /* add the referral elements */
- for(i=0;i<junction.referral_count;i++)
- {
- struct referral* ref = &(junction.referral_list[i]);
- int unilen;
-
- SSVAL(pdata,offset,2); /* version 2 */
- SSVAL(pdata,offset+2,VERSION2_REFERRAL_SIZE);
- if(self_referral)
- SSVAL(pdata,offset+4,1);
- else
- SSVAL(pdata,offset+4,0);
- SSVAL(pdata,offset+6,0); /* ref_flags :use path_consumed bytes? */
- SIVAL(pdata,offset+8,ref->proximity);
- SIVAL(pdata,offset+12,ref->ttl);
-
- SSVAL(pdata,offset+16,uni_reqpathoffset1-offset);
- SSVAL(pdata,offset+18,uni_reqpathoffset2-offset);
- /* copy referred path into current offset */
- unilen = (dos_struni2(pdata+uni_curroffset,ref->alternate_path,512)
- +1)*2;
- SSVAL(pdata,offset+20,uni_curroffset-offset);
-
- uni_curroffset += unilen;
- offset += VERSION2_REFERRAL_SIZE;
- }
- /* add in the unexplained 22 (0x16) bytes at the end */
- memset(pdata+uni_curroffset,'\0',0x16);
- free(junction.referral_list);
+ reply_size = setup_ver2_dfs_referral(pathname, ppdata, &junction,
+ self_referral);
break;
}
-
case 3:
{
- unsigned char uni_reqpath[1024];
- int uni_reqpathoffset1, uni_reqpathoffset2;
- int uni_curroffset;
-
- int reqpathlen = 0;
- int offset,i=0;
-
- DEBUG(10,("setting up version3 referral\n"));
-
- reqpathlen = (dos_struni2(uni_reqpath,pathname,512)+1)*2;
-
- dump_data(10,uni_reqpath,reqpathlen);
-
- uni_reqpathoffset1 = REFERRAL_HEADER_SIZE + VERSION3_REFERRAL_SIZE *
- junction.referral_count;
- uni_reqpathoffset2 = uni_reqpathoffset1 + reqpathlen;
- reply_size = uni_curroffset = uni_reqpathoffset2 + reqpathlen;
-
- for(i=0;i<junction.referral_count;i++)
- {
- DEBUG(10,("referral %u : %s\n",i,junction.referral_list[i].alternate_path));
- reply_size += (strlen(junction.referral_list[i].alternate_path)+1)*2;
- }
-
- pdata = *ppdata = Realloc(pdata,reply_size);
- if(pdata == NULL)
- {
- DEBUG(0,("version3 referral setup: malloc failed for Realloc!\n"));
- return -1;
- }
-
- /* create the header */
- SSVAL(pdata,0,reqpathlen-2); /* path consumed */
- SSVAL(pdata,2,junction.referral_count); /* number of referral in this pkt */
- if(self_referral)
- SIVAL(pdata,4,DFSREF_REFERRAL_SERVER | DFSREF_STORAGE_SERVER);
- else
- SIVAL(pdata,4,DFSREF_STORAGE_SERVER);
-
- /* copy in the reqpaths */
- memcpy(pdata+uni_reqpathoffset1,uni_reqpath,reqpathlen);
- memcpy(pdata+uni_reqpathoffset2,uni_reqpath,reqpathlen);
-
- offset = 8;
- for(i=0;i<junction.referral_count;i++)
- {
- struct referral* ref = &(junction.referral_list[i]);
- int unilen;
-
- SSVAL(pdata,offset,3); /* version 3 */
- SSVAL(pdata,offset+2,VERSION3_REFERRAL_SIZE);
- if(self_referral)
- SSVAL(pdata,offset+4,1);
- else
- SSVAL(pdata,offset+4,0);
-
- SSVAL(pdata,offset+6,0); /* ref_flags :use path_consumed bytes? */
- SIVAL(pdata,offset+8,ref->ttl);
-
- SSVAL(pdata,offset+12,uni_reqpathoffset1-offset);
- SSVAL(pdata,offset+14,uni_reqpathoffset2-offset);
- /* copy referred path into current offset */
- unilen = (dos_struni2(pdata+uni_curroffset,ref->alternate_path,512)
- +1)*2;
- SSVAL(pdata,offset+16,uni_curroffset-offset);
- /* copy 0x10 bytes of 00's in the ServiceSite GUID */
- memset(pdata+offset+18,'\0',16);
-
- uni_curroffset += unilen;
- offset += VERSION3_REFERRAL_SIZE;
- }
- free(junction.referral_list);
+ reply_size = setup_ver3_dfs_referral(pathname, ppdata, &junction,
+ self_referral);
break;
}
+ default:
+ {
+ DEBUG(0,("setup_dfs_referral: Invalid dfs referral version: %d\n",
+ max_referral_level));
+ return -1;
+ }
}
+
DEBUG(10,("DFS Referral pdata:\n"));
- dump_data(10,pdata,reply_size);
+ dump_data(10,*ppdata,reply_size);
return reply_size;
}
+
int dfs_path_error(char* inbuf, char* outbuf)
{
enum remote_arch_types ra_type = get_remote_arch();
@@ -437,4 +572,9 @@ int setup_dfs_referral(char* pathname, int max_referral_level,
return -1;
}
+BOOL is_msdfs_volume(connection_struct* conn, char* path)
+{
+ return False;
+}
+
#endif
diff --git a/source3/msdfs/msdfs_tdb.c b/source3/msdfs/msdfs_tdb.c
deleted file mode 100644
index 2435d7ade7..0000000000
--- a/source3/msdfs/msdfs_tdb.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 3.0
- MSDfs services for Samba
- Copyright (C) Shirish Kalele 2000
- Copyright (C) Samba Team 2000
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include "includes.h"
-
-extern int DEBUGLEVEL;
-
-#ifdef MS_DFS
-
-#define MSDFS_TDB "msdfs.tdb"
-
-/* structures for msdfs.tdb */
-struct tdb_junction_key
-{
- pstring service_name;
- pstring volume_name;
-};
-
-struct tdb_junction_data
-{
- int referral_count;
- struct referral first_referral;
-};
-
-static TDB_CONTEXT* msdfs_map = NULL;
-
-/*
- * Open the msdfs tdb map. Called once for update when parsing the dfsmap file
- * and then subsequently at tconX for reading
- */
-BOOL msdfs_open(BOOL update)
-{
- pstring fname;
- int oflags = (update)?O_RDWR|O_CREAT:O_RDONLY;
-
- /* close any open TDB contexts before opening */
- if(msdfs_map != NULL)
- {
- DEBUG(10,("msdfs_open: Closing existing TDB_CONTEXT msdfs_map: name: %s, fd: %d\n",
- msdfs_map->name,msdfs_map->fd));
- tdb_close(msdfs_map);
- }
-
- pstrcpy(fname,lock_path(MSDFS_TDB));
- DEBUG(10,("opening msdfs tdb : .%s.\n",fname));
- if((msdfs_map = tdb_open(fname,0,0,oflags,0644)) == NULL)
- {
- DEBUG(1,("Couldn't open Dfs tdb map %s %s.\nError was %s\n",fname,
- (update?"for update":"for reading"),strerror(errno) ));
- return False;
- }
- DEBUG(10,("TDB_CONTEXT msdfs_map opened: name: %s, fd: %d\n",msdfs_map->name,msdfs_map->fd));
-
- return True;
-}
-
-BOOL add_junction_entry(struct junction_map* junction)
-{
- struct tdb_junction_key* tlk;
- struct tdb_junction_data* tld;
-
- TDB_DATA key,data;
- uint16 data_size;
-
- int i=0;
-
- if(msdfs_map == NULL)
- {
- DEBUG(4,("Attempt to add junction entry to unopened %s\n",MSDFS_TDB));
- return False;
- }
-
- /* create the key */
- if((tlk = (struct tdb_junction_key*) malloc(sizeof(struct tdb_junction_key))) == NULL)
- {
- DEBUG(0,("malloc failed for tdb junction key\n"));
- return False;
- }
-
- ZERO_STRUCTP(tlk);
-
- pstrcpy(tlk->service_name,junction->service_name);
- pstrcpy(tlk->volume_name,junction->volume_name);
- strupper(tlk->service_name);
- strupper(tlk->volume_name);
-
- key.dptr = (char*) tlk;
- key.dsize = sizeof(struct tdb_junction_key);
-
-
- /* create the data */
- data_size = sizeof(struct tdb_junction_data) +
- ((junction->referral_count-1)*sizeof(struct referral));
-
- if( (tld = (struct tdb_junction_data*) malloc(data_size)) == NULL)
- {
- DEBUG(0,("malloc failed for tdb junction data\n"));
- return False;
- }
-
- tld->referral_count = junction->referral_count;
- memcpy(&tld->first_referral,junction->referral_list,junction->referral_count * sizeof(struct referral));
-
- data.dptr = (char*) tld;
- data.dsize = data_size;
-
- DEBUG(10,("Storing key: .%s:%s.\n",tlk->service_name,tlk->volume_name));
- DEBUG(10,("Data: referral_count : %u\n",tld->referral_count));
- for(i=0;i<tld->referral_count;i++)
- {
- struct referral* ref = &(junction->referral_list[i]);
- DEBUG(10,("Path %d: %s, proximity: %u, ttl: %u\n",i+1,
- ref->alternate_path,ref->proximity,ref->ttl));
- }
-
- if( tdb_store(msdfs_map,key,data,TDB_REPLACE) != 0)
- {
- DEBUG(10,("Could not store referral for %s:%s \n",
- junction->service_name, junction->volume_name));
- free(key.dptr);
- free(data.dptr);
- return False;
- }
-
- free(key.dptr);
- free(data.dptr);
- return True;
-}
-
-BOOL get_junction_entry(struct junction_map* junction)
-{
- struct tdb_junction_key* tlk;
- struct tdb_junction_data* tld;
-
- uint16 reflistsize=0;
-
- TDB_DATA key,data;
-
- if(msdfs_map == NULL)
- {
- DEBUG(4,("Attempt to get junction entry from unopened %s\n",MSDFS_TDB));
- return False;
- }
-
- if( (tlk=(struct tdb_junction_key*) malloc(sizeof(struct tdb_junction_key))) == NULL)
- {
- DEBUG(0,("couldn't malloc for tdb junction key\n"));
- return False;
- }
-
- ZERO_STRUCTP(tlk);
-
- pstrcpy(tlk->service_name,junction->service_name);
- pstrcpy(tlk->volume_name,junction->volume_name);
- strupper(tlk->service_name);
- strupper(tlk->volume_name);
-
- key.dptr = (char*) tlk;
- key.dsize = sizeof(struct tdb_junction_key);
-
- data = tdb_fetch(msdfs_map,key);
-
- if(data.dptr == NULL)
- {
- DEBUG(8,("No data found for key %s:%s\n",junction->service_name,junction->volume_name));
- DEBUG(8,("Error was %s\n",strerror(errno)));
- free(key.dptr);
- return False;
- }
-
- tld = (struct tdb_junction_data*) data.dptr;
-
- junction->referral_count = tld->referral_count;
- reflistsize = junction->referral_count * sizeof(struct referral);
-
- if((junction->referral_list = (struct referral*) malloc(reflistsize) ) == NULL)
- {
- DEBUG(0,("malloc failed for referral list\n"));
- free(key.dptr);
- free(data.dptr);
- return False;
- }
-
- memcpy(junction->referral_list,&(tld->first_referral),reflistsize);
- free(key.dptr);
- free(data.dptr);
-
- return True;
-}
-
-BOOL isDfsShare(char* svc,char* vol)
-{
- TDB_DATA key;
- struct tdb_junction_key tlk;
-
- ZERO_STRUCT(tlk);
-
- if(msdfs_map == NULL)
- {
- DEBUG(4,("Attempt to check junction existence in unopened %s\n",MSDFS_TDB));
- return False;
- }
-
- pstrcpy(tlk.service_name,svc);
- pstrcpy(tlk.volume_name,vol);
-
- strupper(tlk.service_name);
- strupper(tlk.volume_name);
-
- key.dptr = (char*) &tlk;
- key.dsize = sizeof(struct tdb_junction_key);
-
- DEBUG(10,("tdb_exists for key %s:%s returns %d\n",tlk.service_name,tlk.volume_name,
- tdb_exists(msdfs_map,key)));
-
- if(tdb_exists(msdfs_map,key))
- return True;
- else
- {
- DEBUG(10,("error was %s\n",strerror(errno)));
- return False;
- }
-
-}
-
-void msdfs_close(void)
-{
- if(msdfs_map != NULL)
- tdb_close(msdfs_map);
-
- msdfs_map = NULL;
-}
-
-void msdfs_end(void)
-{
- /* pstring fname; */
- msdfs_close();
-
- /* pstrcpy(fname,lock_path(MSDFS_TDB));
- unlink(fname); */
-}
-#endif
-
-
-
-
-
-
-
diff --git a/source3/msdfs/parse_dfs_map.c b/source3/msdfs/parse_dfs_map.c
deleted file mode 100644
index df6b89bbfa..0000000000
--- a/source3/msdfs/parse_dfs_map.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 3.0
- MSDfs services for Samba
- Copyright (C) Shirish Kalele 2000
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-/***********************************************************************
- * Parses the per-service Dfs map file which is of the form:
- * junction_point1
- * alternate_path1:proximity:ttl
- * alternate_path2:proximity:ttl
- * junction_point2
- * ...
- *
- * Junction points are directories in the service (upon encountering which
- * Samba redirects the client to the servers hosting the underlying share)
- *
- * Alternate paths are of the form: \\smbserver\share
- * Currently, the parser detects alternate paths by the leading \'s
- *
- ***********************************************************************/
-
-#include "includes.h"
-
-#ifdef MS_DFS
-
-#define MAX_ALTERNATE_PATHS 256
-
-extern int DEBUGLEVEL;
-
-static char* Dfs_Crop_Whitespace(char* line)
-{
- int i=0;
- int len = strlen(line);
-
- if(line[0]=='#' || line[0]==';') return NULL;
-
- for(i=0;i<len && isspace(line[i]);i++);
-
- if(i>=len) return NULL;
-
- line = &line[i];
-
- /* crop off the newline at the end, if present */
- /* if(line[len-1]=='\n') line[len-1]='\0'; */
-
- /* remove white sace from the end */
- for(i=strlen(line)-1;i>=0 && isspace(line[i]);i--);
-
- if(i<0) return NULL;
-
- line[i]='\0';
-
- if(line[0] == '\0') return NULL;
-
- return line;
-}
-
-static BOOL parse_referral(char* s, struct referral* ref)
-{
-#define MAXTOK_IN_REFERRAL 3
- char *tok[MAXTOK_IN_REFERRAL+1];
- int count=0;
- int i=0;
-
- if(s[1]=='\\') s = &s[1]; /* skip one backslash
- if there are two */
-
- tok[count++] = strtok(s,":");
-
- while( ((tok[count]=strtok(NULL,":")) != NULL) && count<MAXTOK_IN_REFERRAL)
- count++;
-
- DEBUG(10,("parse_referral: Tokens"));
- for(i=0;i<count;i++)
- DEBUG(10,(" %s",tok[i]));
- DEBUG(10,(".\n"));
- if(count > 0)
- pstrcpy(ref->alternate_path,tok[0]);
- else
- {
- DEBUG(6,("Invalid referral line: %s\n",s));
- return False;
- }
-
- if(count > 1)
- ref->proximity = atoi(tok[1]);
- else
- ref->proximity = 0;
-
- if(count > 2)
- ref->ttl = atoi(tok[2]);
- else
- ref->ttl = REFERRAL_TTL;
-
- return True;
-}
-
-static void create_mount_point(int snum, struct junction_map *jn)
-{
- fstring dfsvolumepath;
-
- fstrcpy(dfsvolumepath, lp_pathname(snum));
- fstrcat(dfsvolumepath, "/");
- fstrcat(dfsvolumepath, jn->volume_name);
-
- if(!directory_exist(dfsvolumepath, NULL))
- {
- DEBUG(10,("create_mount_point: creating msdfs mntpt %s\n",
- dfsvolumepath));
- become_root(False);
- mkdir(dfsvolumepath, 0700);
- unbecome_root(False);
- }
-}
-static BOOL load_dfsmap(char* fname, int snum)
-{
- struct junction_map* junction = NULL;
- struct referral tmp_ref_array[MAX_ALTERNATE_PATHS];
- int ref_count = 0;
- FILE* fp;
- int line_cnt = 0;
-
- if(lp_dfsmap_loaded(snum))
- return True;
-
- if((fp = sys_fopen(fname,"r")) == NULL)
- {
- DEBUG(1,("can't open dfs map file %s for service [%s]\nError was %s",fname,
- lp_servicename(snum), strerror(errno)));
- return False;
- }
-
- if(!msdfs_open(True))
- return False;
-
- while(!feof(fp))
- {
- pstring rawline;
- char* line;
-
- line_cnt++;
- if(!fgets(rawline,PSTRING_LEN,fp))
- continue;
-
- if((line = Dfs_Crop_Whitespace(rawline)) == NULL)
- continue;
-
- DEBUG(6,("load_dfsmap: Cropped line: %s\n",line));
-
- /* the line contains a new junction or
- an alternate path to current junction */
-
- if(line[0]!='\\')
- {
- /* a new junction definition encountered */
-
- /* add the current junction if it has any referrals defined */
- if(junction && ref_count!=0)
- {
- junction->referral_count = ref_count;
- junction->referral_list = tmp_ref_array;
- DEBUG(4,("Adding Dfs junction: %s\\%s Referrals: %u First referral path: %s\n",
- junction->service_name,junction->volume_name,
- junction->referral_count, junction->referral_list[0].alternate_path));
-
- if(!add_junction_entry(junction))
- {
- DEBUG(6,("Unable to add junction entry %s:%s after parsing\n",
- junction->service_name,junction->volume_name));
- }
-
- /* create a unix directory as a junction/mount point. */
- create_mount_point(snum, junction);
- free(junction);
- }
-
- /* then, create a new junction_map node */
- if((junction = (struct junction_map*) malloc(sizeof(struct junction_map))) == NULL)
- {
- DEBUG(0,("Couldn't malloc for Dfs junction_map node\n"));
- return False;
- }
- pstrcpy(junction->service_name,lp_servicename(snum));
- pstrcpy(junction->volume_name,line);
- ref_count = 0;
- }
- else
- {
- /* referral encountered. add to current junction */
- if(!junction)
- {
- DEBUG(4,("Invalid entry in Dfs map file.\nAlternate path defined outside of a junction in %s\nline %d: %s\n",fname, line_cnt, line));
- return False;
- }
-
- /* parse the referral */
- if(!parse_referral(line,&tmp_ref_array[ref_count]))
- continue;
- ref_count++;
-
- }
- }
-
- /* End of file. Add the current junction and return */
- if(junction)
- {
- junction->referral_count = ref_count;
- junction->referral_list = tmp_ref_array;
- DEBUG(4,("Adding Dfs junction: %s\\%s Referrals: %u First referral path: %s\n",
- junction->service_name,junction->volume_name,
- junction->referral_count, junction->referral_list[0].alternate_path));
- if(!add_junction_entry(junction))
- {
- DEBUG(6,("Unable to add junction entry %s:%s after parsing\n",
- junction->service_name,junction->volume_name));
- }
- create_mount_point(snum, junction);
- free(junction);
- }
-
- fclose(fp);
- msdfs_close();
- return True;
-}
-
-void load_dfsmaps(void)
-{
- int i=0;
- if(!lp_host_msdfs())
- return;
-
- for(i=0;*lp_servicename(i) && *lp_dfsmap(i)
- && !lp_dfsmap_loaded(i);i++)
- {
- char* dfsmapfile = lp_dfsmap(i);
- DEBUG(4,("loading dfsmap for servicename: %s\n",lp_servicename(i)));
- if(load_dfsmap(dfsmapfile,i))
- {
- set_dfsmap_loaded(i,True);
- }
- else
- {
- DEBUG(0,("handle_dfsmap: Unable to load Dfs map file %s.\nService %s not using MS Dfs\n",dfsmapfile,lp_servicename(i)));
- set_dfsmap_loaded(i,False);
- }
-
- }
-}
-
-#else
-/* Stub function if MS_DFS is not defined */
-
-void load_dfsmaps(void)
-{}
-
-#endif
-
-
-
-
-
-
-
-
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 9acfd5c170..afb3774a54 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -371,10 +371,8 @@ typedef struct
BOOL bFakeDirCreateTimes;
BOOL bBlockingLocks;
BOOL bInheritPerms;
-#ifdef MS_DFS
- char *szDfsMap;
- BOOL bDfsMapLoaded;
-#endif
+ BOOL bMSDfsRoot;
+
char dummy[3]; /* for alignment */
} service;
@@ -485,10 +483,8 @@ static service sDefault =
False, /* bFakeDirCreateTimes */
True, /* bBlockingLocks */
False, /* bInheritPerms */
-#ifdef MS_DFS
- NULL, /* MS Dfs map path */
- False, /* bDfsMapLoaded */
-#endif
+ False, /* bMSDfsRoot */
+
"" /* dummy */
};
@@ -893,10 +889,8 @@ static struct parm_struct parm_table[] =
{"vfs object", P_STRING, P_LOCAL, &sDefault.szVfsObjectFile, handle_vfs_object, NULL, 0},
{"vfs options", P_STRING, P_LOCAL, &sDefault.szVfsOptions, NULL, NULL, 0},
-#ifdef MS_DFS
- {"dfs map", P_STRING, P_LOCAL, &sDefault.szDfsMap, NULL, NULL, FLAG_SHARE},
+ {"msdfs root", P_BOOL, P_LOCAL, &sDefault.bMSDfsRoot, NULL, NULL, FLAG_SHARE},
{"host msdfs", P_BOOL, P_GLOBAL, &Globals.bHostMSDfs, NULL, NULL, FLAG_GLOBAL},
-#endif
{"Winbind options", P_SEP, P_SEPARATOR},
@@ -1422,11 +1416,7 @@ FN_LOCAL_STRING(lp_veto_files,szVetoFiles)
FN_LOCAL_STRING(lp_hide_files,szHideFiles)
FN_LOCAL_STRING(lp_veto_oplocks,szVetoOplockFiles)
FN_LOCAL_STRING(lp_driverlocation,szPrinterDriverLocation)
-
-#ifdef MS_DFS
-FN_LOCAL_STRING(lp_dfsmap,szDfsMap)
-FN_LOCAL_BOOL(lp_dfsmap_loaded,bDfsMapLoaded)
-#endif
+FN_LOCAL_BOOL(lp_msdfs_root, bMSDfsRoot)
FN_LOCAL_BOOL(lp_autoloaded,autoloaded)
FN_LOCAL_BOOL(lp_preexec_close,bPreexecClose)
@@ -2087,16 +2077,6 @@ static BOOL handle_source_env(char *pszParmValue,char **ptr)
return(result);
}
-
-
-#ifdef MS_DFS
-void set_dfsmap_loaded(int i,BOOL b)
-{
- pSERVICE(i)->bDfsMapLoaded = b;
-}
-
-#endif
-
/***************************************************************************
handle the interpretation of the vfs object parameter
*************************************************************************/
diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c
index 853aa0e2f6..44c4f5569d 100644
--- a/source3/rpc_server/srv_srvsvc.c
+++ b/source3/rpc_server/srv_srvsvc.c
@@ -99,7 +99,7 @@ static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum)
sh1005->dfs_root_flag = 0;
#ifdef MS_DFS
- if(lp_host_msdfs() && *lp_dfsmap(snum) && lp_dfsmap_loaded(snum))
+ if(lp_host_msdfs() && lp_msdfs_root(snum))
sh1005->dfs_root_flag = 3;
#endif
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 26fd2aff14..5b077110bb 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -138,7 +138,7 @@ int dos_mode(connection_struct *conn,char *path,SMB_STRUCT_STAT *sbuf)
if (S_ISDIR(sbuf->st_mode))
result = aDIR | (result & aRONLY);
-
+
#ifdef S_ISLNK
#if LINKS_READ_ONLY
if (S_ISLNK(sbuf->st_mode) && S_ISDIR(sbuf->st_mode))
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 622251b375..a8e7540d28 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -318,14 +318,6 @@ BOOL reload_services(BOOL test)
ret = lp_load(servicesf,False,False,True);
-#ifdef MS_DFS
- /* load the dfs maps of all the services having
- a dfs_map parameter
- we don't want to do this in lp_load because we want just the smbd
- server to load up the dfs maps into msdfs.tdb. not nmbd, swat etc*/
- load_dfsmaps();
-#endif
-
load_printers();
/* perhaps the config filename is now set */
@@ -455,9 +447,6 @@ void exit_server(char *reason)
}
locking_end();
-#ifdef MS_DFS
- msdfs_end();
-#endif
DEBUG(3,("Server exit (%s)\n", (reason ? reason : "")));
exit(0);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index e0156c083d..18452158c8 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -405,8 +405,19 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
pstrcat(pathreal,dname);
if (conn->vfs_ops.stat(dos_to_unix(pathreal,False),&sbuf) != 0)
{
- DEBUG(5,("get_lanman2_dir_entry:Couldn't stat [%s] (%s)\n",pathreal,strerror(errno)));
- continue;
+ /* Needed to show the msdfs symlinks as directories */
+ if(!lp_host_msdfs() || !lp_msdfs_root(SNUM(conn))
+ || !is_msdfs_volume(conn, pathreal))
+ {
+ DEBUG(5,("get_lanman2_dir_entry:Couldn't stat [%s] (%s)\n",
+ pathreal,strerror(errno)));
+ continue;
+ }
+ else
+ {
+ DEBUG(5,("get_lanman2_dir_entry: Masquerading msdfs link %s as a directory\n", pathreal));
+ sbuf.st_mode = (sbuf.st_mode & 0xFFF) | S_IFDIR;
+ }
}
mode = dos_mode(conn,pathreal,&sbuf);