1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

dded Microsoft Dfs services.

* added a new msdfs/ directory under source/
* added msdfs sources under this directory.
* modified configure setup to add a --with-msdfs configure time option

 Modified Files:
 	Makefile.in acconfig.h configure configure.in
 	include/config.h.in include/includes.h include/proto.h
 	include/smb.h include/smb_macros.h param/loadparm.c
 	smbd/negprot.c smbd/nttrans.c smbd/process.c smbd/reply.c
 	smbd/server.c smbd/trans2.c
 Added Files:
 	include/msdfs.h msdfs/README msdfs/msdfs.c msdfs/msdfs_tdb.c
 	msdfs/parse_dfs_map.c
 ----------------------------------------------------------------------
This commit is contained in:
Shirish Kalele -
parent f8d3ce0419
commit 4684b4a188
21 changed files with 2045 additions and 662 deletions

View File

@ -160,7 +160,9 @@ SMBD_OBJ1 = smbd/server.o smbd/files.o smbd/chgpasswd.o smbd/connection.o \
PRINTING_OBJ = printing/pcap.o printing/print_svid.o printing/printing.o \
printing/print_cups.o
SMBD_OBJ = $(SMBD_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) \
MSDFS_OBJ = msdfs/msdfs.o msdfs/msdfs_tdb.o msdfs/parse_dfs_map.o
SMBD_OBJ = $(SMBD_OBJ1) $(MSDFS_OBJ) $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) \
$(RPC_SERVER_OBJ) $(RPC_CLIENT_OBJ) $(RPC_PARSE_OBJ) \
$(LOCKING_OBJ) $(PASSDB_OBJ) $(PRINTING_OBJ) $(PROFILE_OBJ) $(LIB_OBJ)

View File

@ -75,6 +75,7 @@
#undef HAVE_SETRESUID
#undef WITH_NETATALK
#undef WITH_UTMP
#undef MS_DFS
#undef HAVE_INO64_T
#undef HAVE_STRUCT_FLOCK64
#undef SIZEOF_INO_T

1417
source/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1423,6 +1423,25 @@ AC_ARG_WITH(utmp,
AC_MSG_RESULT(no)
)
#################################################
# check for MS Dfs support
AC_MSG_CHECKING(whether to support MS Dfs)
AC_ARG_WITH(msdfs,
[ --with-msdfs Include MS Dfs support
--without-msdfs Don't include MS Dfs support (default)],
[ case "$withval" in
yes)
AC_MSG_RESULT(yes)
AC_DEFINE(MS_DFS)
;;
*)
AC_MSG_RESULT(no)
;;
esac ],
AC_MSG_RESULT(no)
)
#################################################
# set private directory location
AC_ARG_WITH(privatedir,

View File

@ -141,6 +141,7 @@
#undef HAVE_SETRESUID
#undef WITH_NETATALK
#undef WITH_UTMP
#undef MS_DFS
#undef HAVE_INO64_T
#undef HAVE_STRUCT_FLOCK64
#undef SIZEOF_INO_T

View File

@ -914,4 +914,6 @@ int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
#include <dlfcn.h>
#endif
#include "msdfs.h"
#endif /* _INCLUDES_H */

78
source/include/msdfs.h Normal file
View File

@ -0,0 +1,78 @@
/*
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.
*/
#ifndef _MSDFS_H
#define _MSDFS_H
#ifdef MS_DFS
#define REFERRAL_TTL 600
/* Flags used in trans2 Get Referral reply */
#define DFSREF_REFERRAL_SERVER 0x1
#define DFSREF_STORAGE_SERVER 0x2
struct referral
{
pstring alternate_path; /* contains the path referred (UNICODE?) */
uint32 proximity;
uint32 ttl; /* how long should client cache referral */
};
struct junction_map
{
pstring service_name;
pstring volume_name;
int referral_count;
struct referral* referral_list;
};
#define RESOLVE_DFSPATH(name, conn, inbuf, outbuf) \
{ if(((SVAL(inbuf,smb_flg2) & FLAGS2_DFS_PATHNAMES)) && \
dfs_redirect(name,conn)) \
return(dfs_path_error(inbuf,outbuf)); }
#define RESOLVE_FINDFIRST_DFSPATH(name, conn, inbuf, outbuf) \
{ if((SVAL(inbuf,smb_flg2) & FLAGS2_DFS_PATHNAMES) || \
get_remote_arch()==RA_WIN95) \
if(dfs_findfirst_redirect(directory,conn)) \
return(dfs_path_error(inbuf,outbuf)); }
#define init_dfsroot(conn, inbuf, outbuf) \
{ if(*lp_dfsmap(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 */
#define RESOLVE_DFSPATH(name, conn, inbuf, outbuf) ;
#define RESOLVE_FINDFIRST_DFSPATH(name, conn, inbuf, outbuf) ;
#define init_dfsroot(conn, inbuf, outbuf) ;
#endif
#endif /* _MSDFS_H */

View File

@ -24,7 +24,6 @@ BOOL allow_access(char *deny_list,char *allow_list,
BOOL check_access(int sock, char *allow_list, char *deny_list);
/*The following definitions come from lib/bitmap.c */
struct bitmap *bitmap_allocate(int n);
BOOL bitmap_set(struct bitmap *bm, unsigned i);
BOOL bitmap_clear(struct bitmap *bm, unsigned i);
@ -1305,6 +1304,7 @@ char *lp_readlist(int );
char *lp_writelist(int );
char *lp_fstype(int );
char *lp_vfsobj(int );
char *lp_dfsmap(int );
char *lp_mangled_map(int );
char *lp_veto_files(int );
char *lp_hide_files(int );

View File

@ -1143,6 +1143,7 @@ struct bitmap {
/* this is used on a TConX. I'm not sure the name is very helpful though */
#define SMB_SUPPORT_SEARCH_BITS 0x0001
#define SMB_SHARE_IN_DFS 0x0002
/* these are the constants used in the above call. */
/* DesiredAccess */

View File

@ -233,4 +233,5 @@ copy an IP address from one buffer to another
#define dos_format(fname) string_replace(fname,'/','\\')
#endif /* _SMB_MACROS_H */

27
source/msdfs/README Normal file
View File

@ -0,0 +1,27 @@
Setting up MS Dfs in Samba
kalele@veritas.com March 2000
Currently, MS Dfs support is a configure time parameter (--with-msdfs). Can be changed later to always compile it in..
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.
e.g.
[pub]
dfs map = /usr/local/samba/lib/pub_dfs_map
The pub_dfs_map file would contain a list of junction points and their referral paths.
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:
pub_dir1
\\machineX\pub:0:600
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.
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.

466
source/msdfs/msdfs.c Normal file
View File

@ -0,0 +1,466 @@
/*
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.
*/
#include "includes.h"
extern int DEBUGLEVEL;
extern pstring global_myname;
extern global_client_caps;
#ifdef MS_DFS
#define VERSION2_REFERRAL_SIZE 0x16
#define VERSION3_REFERRAL_SIZE 0x22
#define REFERRAL_HEADER_SIZE 0x08
struct dfs_path
{
pstring hostname;
pstring servicename;
pstring volumename;
pstring restofthepath;
};
void create_nondfs_path(char* pathname, struct dfs_path* pdp)
{
pstrcpy(pathname,pdp->volumename);
pstrcat(pathname,"\\");
pstrcat(pathname,pdp->restofthepath);
}
/* Parse the pathname of the form \hostname\service\volume\restofthepath
into the dfs_path structure */
BOOL parse_dfs_path(char* pathname, struct dfs_path* pdp)
{
pstring pathname_local;
char* p,*temp;
pstrcpy(pathname_local,pathname);
p = temp = pathname_local;
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));
/* now tokenize */
/* parse out hostname */
p = strchr(temp,'\\');
if(p == NULL)
return False;
*p = '\0';
pstrcpy(pdp->hostname,temp);
DEBUG(10,("hostname: %s\n",pdp->hostname));
/* parse out servicename */
temp = p+1;
p = strchr(temp,'\\');
if(p == NULL)
{
pstrcpy(pdp->servicename,temp);
return True;
}
*p = '\0';
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;
}
*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));
return True;
}
/**************************************************************
Decides if given pathname is Dfs and if it should be redirected
Converts pathname to non-dfs format if Dfs redirection not required
**************************************************************/
BOOL dfs_redirect(char* pathname, connection_struct* conn)
{
struct dfs_path dp;
pstring temp;
pstrcpy(temp,pathname);
if(lp_dfsmap(SNUM(conn))==NULL || *lp_dfsmap(SNUM(conn))=='\0')
return False;
parse_dfs_path(pathname,&dp);
if(global_myname && (strcasecmp(global_myname,dp.hostname)!=0))
return False;
/* check if need to redirect */
if(isDfsShare(dp.servicename,dp.volumename))
{
DEBUG(4,("dfs_redirect: Redirecting %s\n",temp));
return True;
}
else
{
create_nondfs_path(pathname,&dp);
DEBUG(4,("dfs_redirect: Not redirecting %s. Converted to non-dfs pathname \'%s\'\n",
temp,pathname));
return False;
}
}
/*
Special DFS redirect call for findfirst's.
If the findfirst is for the dfs junction, then no redirection,
if it is for the underlying directory contents, redirect.
*/
BOOL dfs_findfirst_redirect(char* pathname, connection_struct* conn)
{
struct dfs_path dp;
pstring temp;
pstrcpy(temp,pathname);
/* Is the path Dfs-redirectable? */
if(!dfs_redirect(temp,conn))
{
pstrcpy(pathname,temp);
return False;
}
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))
return True;
else
{
create_nondfs_path(pathname,&dp);
return False;
}
}
/******************************************************************
* Set up the Dfs referral for the dfs pathname
******************************************************************/
int setup_dfs_referral(char* pathname, int max_referral_level,
char** ppdata)
{
struct dfs_path dp;
struct junction_map junction;
BOOL self_referral;
char* pdata = *ppdata;
int reply_size = 0;
ZERO_STRUCT(junction);
parse_dfs_path(pathname,&dp);
/* 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));
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;
}
pstrcpy(junction.service_name,dp.servicename);
pstrcpy(junction.volume_name,dp.volumename);
/* get the junction entry */
if(!get_junction_entry(&junction))
{
/* refer the same pathname, create a standard referral struct */
struct referral* ref;
self_referral = True;
junction.referral_count = 1;
if((ref = (struct referral*) malloc(sizeof(struct referral))) == NULL)
{
DEBUG(0,("malloc failed for referral\n"));
return -1;
}
pstrcpy(ref->alternate_path,pathname);
ref->proximity = 0;
ref->ttl = REFERRAL_TTL;
junction.referral_list = ref;
}
else
{
self_referral = False;
if( DEBUGLVL( 3 ) )
{
int i=0;
dbgtext("setup_dfs_referral: Referring client request for %s to alternate path(s):",pathname);
for(i=0;i<junction.referral_count;i++)
dbgtext(" %s",junction.referral_list[i].alternate_path);
dbgtext(".\n");
}
}
/* create the referral depeding on version */
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];
unsigned char uni_altpath[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);
break;
}
case 3:
{
unsigned char uni_reqpath[1024];
unsigned char uni_altpath[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);
break;
}
}
DEBUG(10,("DFS Referral pdata:\n"));
dump_data(10,pdata,reply_size);
return reply_size;
}
int dfs_path_error(char* inbuf, char* outbuf)
{
enum remote_arch_types ra_type = get_remote_arch();
BOOL NT_arch = ((ra_type==RA_WINNT) || (ra_type == RA_WIN2K));
if(NT_arch && (global_client_caps & (CAP_NT_SMBS | CAP_STATUS32)) )
{
SSVAL(outbuf,smb_flg2,SVAL(outbuf,smb_flg2) | FLAGS2_32_BIT_ERROR_CODES);
return(ERROR(0,0xc0000000|NT_STATUS_PATH_NOT_COVERED));
}
return(ERROR(ERRSRV,ERRbadpath));
}
#else
/* Stub functions if MS_DFS not defined */
int setup_dfs_referral(char* pathname, int max_referral_level,
char** ppdata)
{
return -1;
}
#endif
/* Trivial fn that chops off upper bytes to convert unicode to dos */
int unistr_to_dos(char* dst,uint16* src)
{
pstring s;
int i=0;
for(i=0;SVAL(src,i*2) && i<1024;i++)
{
s[i]= SVAL(src,i*2) & 0xff;
}
s[i]=0;
safe_strcpy(dst,s,1024);
DEBUG(10,("converted unistring to %s\n",s));
}

264
source/msdfs/msdfs_tdb.c Normal file
View File

@ -0,0 +1,264 @@
/*
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++)
DEBUG(10,("Path %d: %s, proximity: %u, ttl: %u\n",junction->referral_list[i].alternate_path));
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()
{
if(msdfs_map != NULL)
tdb_close(msdfs_map);
msdfs_map = NULL;
}
void msdfs_end()
{
pstring fname;
msdfs_close();
/* pstrcpy(fname,lock_path(MSDFS_TDB));
unlink(fname); */
}
#endif

View File

@ -0,0 +1,261 @@
/*
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<PSTRING_LEN && line[i]==' ';i++);
if(i>=PSTRING_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;
}
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\n"));
for(i=0;i<count;i++)
DEBUG(10,("\t%s\n",tok[i]));
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[1]);
else
ref->ttl = REFERRAL_TTL;
return True;
}
void load_dfsmaps()
{
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",dfsmapfile,lp_servicename(i)));
set_dfsmap_loaded(i,False);
}
}
}
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;
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;
int i;
struct referral* curr_referral_list = NULL;
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 junction encountered. add the current junction first */
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));
}
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;
}
pstrcpy(junction->service_name,lp_servicename(snum));
pstrcpy(junction->volume_name,line);
ref_count = 0;
}
else
{
/* referral encountered. add to current junction */
int j=0;
char* tok;
if(!junction)
{
DEBUG(4,("Invalid entry in Dfs map file.\nAlternate path defined outside of a junction in line:\n%s\n",line));
return;
}
/* 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));
}
free(junction);
}
fclose(fp);
msdfs_close();
return True;
}
#else
/* Stub function if MS_DFS is not defined */
void load_dfsmaps()
{}
#endif

View File

@ -251,6 +251,9 @@ typedef struct
BOOL bDebugHiresTimestamp;
BOOL bDebugPid;
BOOL bDebugUid;
#ifdef MS_DFS
BOOL bHostMSDfs;
#endif
} global;
static global Globals;
@ -363,6 +366,10 @@ typedef struct
BOOL bFakeDirCreateTimes;
BOOL bBlockingLocks;
BOOL bInheritPerms;
#ifdef MS_DFS
char *szDfsMap;
BOOL bDfsMapLoaded;
#endif
char dummy[3]; /* for alignment */
} service;
@ -471,6 +478,10 @@ static service sDefault =
False, /* bFakeDirCreateTimes */
True, /* bBlockingLocks */
False, /* bInheritPerms */
#ifdef MS_DFS
NULL, /* MS Dfs map path */
False, /* bDfsMapLoaded */
#endif
"" /* dummy */
};
@ -873,6 +884,12 @@ 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},
{"host msdfs", P_BOOL, P_GLOBAL, &Globals.bHostMSDfs, NULL, NULL, FLAG_GLOBAL},
#endif
{NULL, P_BOOL, P_NONE, NULL, NULL, NULL, 0}
};
@ -1298,7 +1315,9 @@ FN_GLOBAL_BOOL(lp_nt_acl_support,&Globals.bNTAclSupport)
FN_GLOBAL_BOOL(lp_stat_cache,&Globals.bStatCache)
FN_GLOBAL_BOOL(lp_allow_trusted_domains,&Globals.bAllowTrustedDomains)
FN_GLOBAL_BOOL(lp_restrict_anonymous,&Globals.bRestrictAnonymous)
#ifdef MS_DFS
FN_GLOBAL_BOOL(lp_host_msdfs,&Globals.bHostMSDfs)
#endif
FN_GLOBAL_INTEGER(lp_os_level,&Globals.os_level)
FN_GLOBAL_INTEGER(lp_max_ttl,&Globals.max_ttl)
FN_GLOBAL_INTEGER(lp_max_wins_ttl,&Globals.max_wins_ttl)
@ -1371,6 +1390,11 @@ 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_preexec_close,bPreexecClose)
FN_LOCAL_BOOL(lp_rootpreexec_close,bRootpreexecClose)
FN_LOCAL_BOOL(lp_revalidate,bRevalidate)
@ -2041,6 +2065,16 @@ 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
*************************************************************************/
@ -2183,7 +2217,6 @@ static BOOL handle_copy(char *pszParmValue,char **ptr)
return (bRetval);
}
/***************************************************************************
initialise a copymap
***************************************************************************/
@ -3079,3 +3112,5 @@ int lp_force_dir_security_mode(int snum)
return lp_force_dir_mode(snum);
return val;
}

View File

@ -199,6 +199,11 @@ static int reply_nt1(char *outbuf)
capabilities |= CAP_RAW_MODE;
}
#ifdef MS_DFS
if(lp_host_msdfs())
capabilities |= CAP_DFS;
#endif
if (lp_security() >= SEC_USER) secword |= 1;
if (doencrypt) secword |= 2;

View File

@ -692,7 +692,8 @@ int reply_ntcreate_and_X(connection_struct *conn,
* Now contruct the smb_open_mode value from the filename,
* desired access and the share access.
*/
RESOLVE_DFSPATH(fname, conn, inbuf, outbuf);
if((smb_open_mode = map_share_mode(&stat_open_only, fname, desired_access,
share_access,
file_attributes)) == -1)
@ -1059,6 +1060,8 @@ static int call_nt_transact_create(connection_struct *conn,
*/
set_posix_case_semantics(file_attributes);
RESOLVE_DFSPATH(fname, conn, inbuf, outbuf);
unix_convert(fname,conn,0,&bad_path,NULL);

View File

@ -385,7 +385,7 @@ struct smb_message_struct
/* LANMAN2.0 PROTOCOL FOLLOWS */
{SMBfindnclose, "SMBfindnclose", reply_findnclose, AS_USER},
{SMBfindclose, "SMBfindclose", reply_findclose,AS_USER},
{SMBtrans2, "SMBtrans2", reply_trans2, AS_USER | QUEUE_IN_OPLOCK },
{SMBtrans2, "SMBtrans2", reply_trans2, AS_USER | QUEUE_IN_OPLOCK | CAN_IPC },
{SMBtranss2, "SMBtranss2", reply_transs2, AS_USER},
/* NT PROTOCOL FOLLOWS */
@ -704,7 +704,9 @@ void construct_reply_common(char *inbuf,char *outbuf)
CVAL(outbuf,smb_reh) = 0;
SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES)); /* bit 7 set
means a reply */
SSVAL(outbuf,smb_flg2,FLAGS2_LONG_PATH_COMPONENTS); /* say we support long filenames */
SSVAL(outbuf,smb_flg2,FLAGS2_LONG_PATH_COMPONENTS);
/* say we support long filenames */
SSVAL(outbuf,smb_err,SMB_SUCCESS);
SSVAL(outbuf,smb_tid,SVAL(inbuf,smb_tid));
SSVAL(outbuf,smb_pid,SVAL(inbuf,smb_pid));

View File

@ -352,7 +352,10 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
/* what does setting this bit do? It is set by NT4 and
may affect the ability to autorun mounted cdroms */
SSVAL(outbuf, smb_vwv2, SMB_SUPPORT_SEARCH_BITS);
init_dfsroot(conn, inbuf, outbuf);
}
DEBUG(3,("tconX service=%s user=%s\n",
service, user));
@ -1024,6 +1027,9 @@ int reply_chkpth(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
SMB_STRUCT_STAT st;
pstrcpy(name,smb_buf(inbuf) + 1);
RESOLVE_DFSPATH(name, conn, inbuf, outbuf);
unix_convert(name,conn,0,&bad_path,&st);
mode = SVAL(inbuf,smb_vwv0);
@ -1085,6 +1091,10 @@ int reply_getatr(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
pstrcpy(fname,smb_buf(inbuf) + 1);
RESOLVE_DFSPATH(fname, conn, inbuf, outbuf);
/* if((SVAL(inbuf,smb_flg2) & FLAGS2_DFS_PATHNAMES) && dfs_redirect(fname,conn)) return(dfs_path_error(inbuf,outbuf));
*/
/* dos smetimes asks for a stat of "" - it returns a "hidden directory"
under WfWg - weird! */
if (! (*fname))
@ -1530,6 +1540,9 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
share_mode = SVAL(inbuf,smb_vwv0);
pstrcpy(fname,smb_buf(inbuf)+1);
RESOLVE_DFSPATH(fname, conn, inbuf, outbuf);
unix_convert(fname,conn,0,&bad_path,NULL);
fsp = file_new();
@ -1632,6 +1645,9 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
/* XXXX we need to handle passed times, sattr and flags */
pstrcpy(fname,smb_buf(inbuf));
RESOLVE_DFSPATH(fname, conn, inbuf, outbuf);
unix_convert(fname,conn,0,&bad_path,NULL);
fsp = file_new();
@ -1766,6 +1782,9 @@ int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
createmode = SVAL(inbuf,smb_vwv0);
pstrcpy(fname,smb_buf(inbuf)+1);
RESOLVE_DFSPATH(fname, conn, inbuf, outbuf);
unix_convert(fname,conn,0,&bad_path,NULL);
if (createmode & aVOLID)
@ -1851,6 +1870,9 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
createmode = SVAL(inbuf,smb_vwv0);
pstrcpy(fname,smb_buf(inbuf)+1);
pstrcat(fname,"/TMXXXXXX");
RESOLVE_DFSPATH(fname, conn, inbuf, outbuf);
unix_convert(fname,conn,0,&bad_path,NULL);
unixmode = unix_mode(conn,createmode,fname);
@ -1955,6 +1977,8 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
pstrcpy(name,smb_buf(inbuf) + 1);
RESOLVE_DFSPATH(name, conn, inbuf, outbuf);
DEBUG(3,("reply_unlink : %s\n",name));
rc = unix_convert(name,conn,0,&bad_path,NULL);
@ -3419,6 +3443,9 @@ int reply_rmdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
BOOL bad_path = False;
pstrcpy(directory,smb_buf(inbuf) + 1);
RESOLVE_DFSPATH(directory, conn, inbuf, outbuf)
unix_convert(directory,conn, NULL,&bad_path,NULL);
if (check_name(directory,conn))
@ -3749,7 +3776,10 @@ int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, in
pstrcpy(name,smb_buf(inbuf) + 1);
pstrcpy(newname,smb_buf(inbuf) + 3 + strlen(name));
RESOLVE_DFSPATH(name, conn, inbuf, outbuf);
RESOLVE_DFSPATH(newname, conn, inbuf, outbuf);
DEBUG(3,("reply_mv : %s -> %s\n",name,newname));
outsize = rename_internals(conn, inbuf, outbuf, name, newname, False);
@ -3882,6 +3912,9 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
return(ERROR(ERRSRV,ERRinvdevice));
}
RESOLVE_DFSPATH(name, conn, inbuf, outbuf);
RESOLVE_DFSPATH(newname, conn, inbuf, outbuf);
rc = unix_convert(name,conn,0,&bad_path1,NULL);
unix_convert(newname,conn,0,&bad_path2,NULL);

View File

@ -282,7 +282,8 @@ max can be %d\n",
BOOL reload_services(BOOL test)
{
BOOL ret;
int i=0;
if (lp_loaded()) {
pstring fname;
pstrcpy(fname,lp_configfile());
@ -298,9 +299,15 @@ BOOL reload_services(BOOL test)
return(True);
lp_killunused(conn_snum_used);
ret = lp_load(servicesf,False,False,True);
/* 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 msdfds.tdb. not nmbd, swat etc*/
load_dfsmaps();
load_printers();
/* perhaps the config filename is now set */
@ -431,6 +438,9 @@ void exit_server(char *reason)
}
locking_end();
#ifdef MS_DFS
msdfs_end();
#endif
DEBUG(3,("Server exit (%s)\n", (reason ? reason : "")));
exit(0);

View File

@ -101,8 +101,8 @@ static int send_trans2_replies(char *outbuf, int bufsize, char *params,
* the length of the data we send over the wire, as the alignment offsets
* are sent here. Fix from Marc_Jacobsen@hp.com.
*/
total_sent_thistime = MIN(total_sent_thistime, useable_space +
alignment_offset + data_alignment_offset);
total_sent_thistime = MIN(total_sent_thistime, useable_space+
alignment_offset + data_alignment_offset);
set_message(outbuf, 10, total_sent_thistime, True);
@ -120,7 +120,7 @@ static int send_trans2_replies(char *outbuf, int bufsize, char *params,
SSVAL(outbuf,smb_prcnt, params_sent_thistime);
if(params_sent_thistime == 0)
{
SSVAL(outbuf,smb_proff,0);
SSVAL(outbuf,smb_proff,((smb_buf(outbuf)+alignment_offset) - smb_base(outbuf)));
SSVAL(outbuf,smb_prdisp,0);
}
else
@ -693,6 +693,8 @@ static int call_trans2findfirst(connection_struct *conn,
pstrcpy(directory, params + 12); /* Complete directory path with
wildcard mask appended */
RESOLVE_FINDFIRST_DFSPATH(directory, conn, inbuf, outbuf);
DEBUG(5,("path=%s\n",directory));
unix_convert(directory,conn,0,&bad_path,NULL);
@ -1354,6 +1356,9 @@ static int call_trans2qfilepathinfo(connection_struct *conn,
fname = &fname1[0];
pstrcpy(fname,&params[6]);
RESOLVE_DFSPATH(fname, conn, inbuf, outbuf);
unix_convert(fname,conn,0,&bad_path,&sbuf);
if (!check_name(fname,conn) ||
(!VALID_STAT(sbuf) && conn->vfs_ops.stat(dos_to_unix(fname,False),&sbuf))) {
@ -2120,6 +2125,49 @@ static int call_trans2findnotifynext(connection_struct *conn,
return(-1);
}
/****************************************************************************
reply to a TRANS2_GET_DFS_REFERRAL - Shirish Kalele <kalele@veritas.com>
****************************************************************************/
static int call_trans2getdfsreferral(connection_struct *conn, char* inbuf,
char* outbuf, int length, int bufsize,
char** pparams, char** ppdata)
{
char *params = *pparams;
enum remote_arch_types ra_type = get_remote_arch();
BOOL NT_arch = ((ra_type == RA_WINNT) || (ra_type == RA_WIN2K));
pstring pathname;
int reply_size = 0;
char* dfs_referral = NULL;
int max_referral_level = SVAL(params,0);
DEBUG(10,("call_trans2getdfsreferral\n"));
#ifdef MS_DFS
if(!lp_host_msdfs())
return(ERROR(ERRDOS,ERRbadfunc));
/* if pathname is in UNICODE, convert to DOS */
/* NT always sends in UNICODE, may not set UNICODE flag */
if(NT_arch || (SVAL(inbuf,smb_flg2) & FLAGS2_UNICODE_STRINGS))
{
unistr_to_dos(pathname, &params[2]);
DEBUG(10,("UNICODE referral for %s\n",pathname));
}
else
pstrcpy(pathname,&params[2]);
if((reply_size = setup_dfs_referral(pathname,max_referral_level,ppdata)) < 0)
return(ERROR(ERRDOS,ERRbadfile));
SSVAL(outbuf,smb_flg2,SVAL(outbuf,smb_flg2) | FLAGS2_UNICODE_STRINGS |
FLAGS2_DFS_PATHNAMES);
send_trans2_replies(outbuf,bufsize,0,0,*ppdata,reply_size);
#else
DEBUG(0,("Unexpected DFS referral request!\n"));
return(ERROR(ERRDOS,ERRbadfunc));
#endif
}
/****************************************************************************
reply to a SMBfindclose (stop trans2 directory search)
****************************************************************************/
@ -2353,6 +2401,11 @@ int reply_trans2(connection_struct *conn,
outsize = call_trans2mkdir(conn, inbuf, outbuf, length,
bufsize, &params, &data);
break;
case TRANSACT2_GET_DFS_REFERRAL:
outsize = call_trans2getdfsreferral(conn,inbuf,outbuf,length,
bufsize, &params, &data);
break;
default:
/* Error in request */
DEBUG(2,("Unknown request %d in trans2 call\n", tran_call));