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

Changed MS_DFS to WITH_MSDFS throughout.

Fixed trans2 calls on IPC$ to let dfs referral calls through.
This commit is contained in:
Shirish Kalele -
parent 07872298e3
commit e0965a80bd
12 changed files with 139 additions and 120 deletions

8
source/configure vendored
View File

@ -917,7 +917,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
for ac_prog in gawk mawk nawk awk
for ac_prog in mawk gawk nawk awk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@ -10254,8 +10254,8 @@ fi
#################################################
# check for MS Dfs support
echo $ac_n "checking whether to support MS Dfs""... $ac_c" 1>&6
echo "configure:10259: checking whether to support MS Dfs" >&5
echo $ac_n "checking whether to support Microsoft Dfs""... $ac_c" 1>&6
echo "configure:10259: checking whether to support Microsoft Dfs" >&5
# Check whether --with-msdfs or --without-msdfs was given.
if test "${with_msdfs+set}" = set; then
withval="$with_msdfs"
@ -10263,7 +10263,7 @@ if test "${with_msdfs+set}" = set; then
yes)
echo "$ac_t""yes" 1>&6
cat >> confdefs.h <<\EOF
#define MS_DFS 1
#define WITH_MSDFS 1
EOF
;;

View File

@ -1421,14 +1421,14 @@ AC_ARG_WITH(utmp,
#################################################
# check for MS Dfs support
AC_MSG_CHECKING(whether to support MS Dfs)
AC_MSG_CHECKING(whether to support Microsoft 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_DEFINE(WITH_MSDFS)
;;
*)
AC_MSG_RESULT(no)

View File

@ -135,7 +135,7 @@
#undef HAVE_SETRESUID
#undef WITH_NETATALK
#undef WITH_UTMP
#undef MS_DFS
#undef WITH_MSDFS
#undef HAVE_INO64_T
#undef HAVE_STRUCT_FLOCK64
#undef SIZEOF_INO_T

View File

@ -59,7 +59,7 @@ struct dfs_path
pstring restofthepath;
};
#ifdef MS_DFS
#ifdef WITH_MSDFS
#define RESOLVE_DFSPATH(name, conn, inbuf, outbuf) \
{ if(((SVAL(inbuf,smb_flg2) & FLAGS2_DFS_PATHNAMES)) && \

View File

@ -357,7 +357,7 @@ char *myhostname(void);
char *lock_path(char *name);
char *parent_dirname(const char *path);
BOOL ms_has_wild(char *s);
BOOL mask_match(char *string, char *pattern, BOOL case_sensitive);
BOOL mask_match(char *string, char *pattern, BOOL is_case_sensitive);
int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6);
/*The following definitions come from lib/util_array.c */
@ -873,20 +873,20 @@ BOOL posix_locking_end(void);
/*The following definitions come from msdfs/msdfs.c */
BOOL remove_msdfs_link(struct junction_map* jn);
BOOL create_msdfs_link(struct junction_map* jn, BOOL exists);
BOOL is_msdfs_volume(connection_struct* conn, char* path);
BOOL create_junction(char* pathname, struct junction_map* jn);
BOOL is_msdfs_link(connection_struct* conn, char* path);
BOOL get_referred_path(struct junction_map* junction);
BOOL dfs_redirect(char* pathname, connection_struct* conn);
BOOL dfs_findfirst_redirect(char* pathname, connection_struct* conn);
BOOL create_junction(char* pathname, struct junction_map* jn);
int setup_dfs_referral(char* pathname, int max_referral_level,
char** ppdata);
int enum_msdfs_junctions(struct junction_map* jn);
int dfs_path_error(char* inbuf, char* outbuf);
BOOL create_msdfs_link(struct junction_map* jn, BOOL exists);
BOOL remove_msdfs_link(struct junction_map* jn);
int enum_msdfs_links(struct junction_map* jn);
int setup_dfs_referral(char* pathname, int max_referral_level,
char** ppdata);
BOOL is_msdfs_volume(connection_struct* conn, char* path);
BOOL is_msdfs_link(connection_struct* conn, char* path);
/*The following definitions come from nmbd/asyncdns.c */

View File

@ -25,7 +25,7 @@ extern int DEBUGLEVEL;
extern pstring global_myname;
extern uint32 global_client_caps;
#ifdef MS_DFS
#ifdef WITH_MSDFS
/**********************************************************************
Create a tcon relative path from a dfs_path structure
@ -93,7 +93,9 @@ static BOOL parse_dfs_path(char* pathname, struct dfs_path* pdp)
return True;
}
/**********************************************************************
Forms a valid Unix pathname from the junction
**********************************************************************/
static BOOL form_path_from_junction(struct junction_map* jn, char* path,
int max_pathlen)
{
@ -113,59 +115,33 @@ static BOOL form_path_from_junction(struct junction_map* jn, char* path,
return True;
}
BOOL remove_msdfs_link(struct junction_map* jn)
/**********************************************************************
Creates a junction structure from the Dfs pathname
**********************************************************************/
BOOL create_junction(char* pathname, struct junction_map* jn)
{
pstring path;
pstring msdfs_link;
int i=0;
if(!form_path_from_junction(jn, path, sizeof(path)))
return False;
if(unlink(path)!=0)
return False;
struct dfs_path dp;
return True;
}
parse_dfs_path(pathname,&dp);
BOOL create_msdfs_link(struct junction_map* jn, BOOL exists)
{
pstring path;
pstring msdfs_link;
int i=0;
/* check if path is dfs : check hostname is the first token */
if(global_myname && (strcasecmp(global_myname,dp.hostname)!=0))
{
DEBUG(4,("create_junction: Invalid hostname %s in dfs path %s\n",
dp.hostname, pathname));
return False;
}
if(!form_path_from_junction(jn, path, sizeof(path)))
return False;
/* form the msdfs_link contents */
pstrcpy(msdfs_link, "msdfs:");
for(i=0; i<jn->referral_count; i++)
{
char* refpath = jn->referral_list[i].alternate_path;
trim_string(refpath, "\\", "\\");
if(*refpath == '\0')
continue;
if(i>0)
pstrcat(msdfs_link, ",");
pstrcat(msdfs_link, refpath);
}
/* Check for a non-DFS share */
if(!lp_msdfs_root(lp_servicenumber(dp.servicename)))
{
DEBUG(4,("create_junction: %s is not an msdfs root.\n",
dp.servicename));
return False;
}
DEBUG(5,("create_msdfs_link: Creating new msdfs link: %s -> %s\n",
path, msdfs_link));
if(exists)
if(unlink(path)!=0)
return False;
if(symlink(msdfs_link, path) < 0)
{
DEBUG(1,("create_msdfs_link: symlink failed %s -> %s\nError: %s\n",
path, msdfs_link, strerror(errno)));
return False;
}
pstrcpy(jn->service_name,dp.servicename);
pstrcpy(jn->volume_name,dp.volumename);
return True;
}
@ -226,10 +202,14 @@ static BOOL parse_symlink(char* buf,struct referral** preflist, int* refcount)
return True;
}
BOOL is_msdfs_volume(connection_struct* conn, char* path)
/**********************************************************************
Returns true if the unix path is a valid msdfs symlink
**********************************************************************/
BOOL is_msdfs_link(connection_struct* conn, char* path)
{
SMB_STRUCT_STAT st;
pstring referral;
int referral_len = 0;
if(!path || !conn)
return False;
@ -238,21 +218,30 @@ BOOL is_msdfs_volume(connection_struct* conn, char* path)
if(conn->vfs_ops.lstat(dos_to_unix(path,False),&st) != 0)
{
DEBUG(5,("is_msdfs_volume: %s does not exist.\n",path));
DEBUG(5,("is_msdfs_link: %s does not exist.\n",path));
return False;
}
if(S_ISLNK(st.st_mode))
{
/* open the link and read it */
readlink(path, referral, sizeof(pstring));
DEBUG(5,("is_msdfs_volume: %s -> %s\n",path,referral));
referral_len = readlink(path, referral, sizeof(pstring));
if(referral_len == -1)
DEBUG(0,("is_msdfs_link: Error reading msdfs link %s: %s\n",
path, strerror(errno)));
referral[referral_len] = '\0';
DEBUG(5,("is_msdfs_link: %s -> %s\n",path,referral));
if(parse_symlink(referral, NULL, NULL))
return True;
}
return False;
}
/**********************************************************************
Fills in the junction_map struct with the referrals from the
symbolic link
**********************************************************************/
BOOL get_referred_path(struct junction_map* junction)
{
fstring path;
@ -306,7 +295,7 @@ BOOL dfs_redirect(char* pathname, connection_struct* conn)
fstrcpy(path, conn->connectpath);
fstrcat(path, "/");
fstrcat(path, dp.volumename);
if(is_msdfs_volume(conn, path))
if(is_msdfs_link(conn, path))
{
DEBUG(4,("dfs_redirect: Redirecting %s\n",temp));
return True;
@ -530,35 +519,7 @@ static int setup_ver3_dfs_referral(char* pathname, char** ppdata,
return reply_size;
}
/**********************************************************************
Creates a junction structure from the Dfs pathname
**********************************************************************/
BOOL create_junction(char* pathname, struct junction_map* jn)
{
struct dfs_path dp;
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,("create_junction: Invalid hostname %s in dfs path %s\n",
dp.hostname, pathname));
return False;
}
/* Check for a non-DFS share */
if(!lp_msdfs_root(lp_servicenumber(dp.servicename)))
{
DEBUG(4,("create_junction: %s is not an msdfs root.\n",
dp.servicename));
return False;
}
pstrcpy(jn->service_name,dp.servicename);
pstrcpy(jn->volume_name,dp.volumename);
return True;
}
/******************************************************************
* Set up the Dfs referral for the dfs pathname
@ -640,6 +601,74 @@ int setup_dfs_referral(char* pathname, int max_referral_level,
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));
}
/**********************************************************************
The following functions are called by the NETDFS RPC pipe functions
**********************************************************************/
BOOL create_msdfs_link(struct junction_map* jn, BOOL exists)
{
pstring path;
pstring msdfs_link;
int i=0;
if(!form_path_from_junction(jn, path, sizeof(path)))
return False;
/* form the msdfs_link contents */
pstrcpy(msdfs_link, "msdfs:");
for(i=0; i<jn->referral_count; i++)
{
char* refpath = jn->referral_list[i].alternate_path;
trim_string(refpath, "\\", "\\");
if(*refpath == '\0')
continue;
if(i>0)
pstrcat(msdfs_link, ",");
pstrcat(msdfs_link, refpath);
}
DEBUG(5,("create_msdfs_link: Creating new msdfs link: %s -> %s\n",
path, msdfs_link));
if(exists)
if(unlink(path)!=0)
return False;
if(symlink(msdfs_link, path) < 0)
{
DEBUG(1,("create_msdfs_link: symlink failed %s -> %s\nError: %s\n",
path, msdfs_link, strerror(errno)));
return False;
}
return True;
}
BOOL remove_msdfs_link(struct junction_map* jn)
{
pstring path;
if(!form_path_from_junction(jn, path, sizeof(path)))
return False;
if(unlink(path)!=0)
return False;
return True;
}
static BOOL form_junctions(int snum, struct junction_map* jn, int* jn_count)
{
@ -701,7 +730,7 @@ static BOOL form_junctions(int snum, struct junction_map* jn, int* jn_count)
return True;
}
int enum_msdfs_junctions(struct junction_map* jn)
int enum_msdfs_links(struct junction_map* jn)
{
int i=0;
int jn_count = 0;
@ -717,27 +746,16 @@ int enum_msdfs_junctions(struct junction_map* jn)
return jn_count;
}
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 */
/* Stub functions if WITH_MSDFS not defined */
int setup_dfs_referral(char* pathname, int max_referral_level,
char** ppdata)
{
return -1;
}
BOOL is_msdfs_volume(connection_struct* conn, char* path)
BOOL is_msdfs_link(connection_struct* conn, char* path)
{
return False;
}

View File

@ -30,7 +30,7 @@
extern int DEBUGLEVEL;
extern pstring global_myname;
#ifdef MS_DFS
#ifdef WITH_MSDFS
/**********************************************************************
api_dfs_exist
@ -329,7 +329,7 @@ static uint32 init_reply_dfs_enum(uint32 level, DFS_R_DFS_ENUM *q_r)
int num_jn = 0;
int i=0;
num_jn = enum_msdfs_junctions(jn);
num_jn = enum_msdfs_links(jn);
DEBUG(5,("make_reply_dfs_enum: %d junctions found in Dfs, doing level %d\n",
num_jn, level));

View File

@ -474,7 +474,7 @@ static struct api_cmd api_fd_commands[] =
{ "NETLOGON", "lsass", api_netlog_rpc },
{ "winreg", "winreg", api_reg_rpc },
{ "spoolss", "spoolss", api_spoolss_rpc },
#ifdef MS_DFS
#ifdef WITH_MSDFS
{ "netdfs", "netdfs" , api_netdfs_rpc },
#endif
{ NULL, NULL, NULL }

View File

@ -98,7 +98,7 @@ static void init_srv_share_info_1005(SRV_SHARE_INFO_1005* sh1005, int snum)
{
sh1005->dfs_root_flag = 0;
#ifdef MS_DFS
#ifdef WITH_MSDFS
if(lp_host_msdfs() && lp_msdfs_root(snum))
sh1005->dfs_root_flag = 3;
#endif

View File

@ -201,7 +201,7 @@ static int reply_nt1(char *outbuf)
capabilities |= CAP_RAW_MODE;
}
#ifdef MS_DFS
#ifdef WITH_MSDFS
if(lp_host_msdfs())
capabilities |= CAP_DFS;
#endif

View File

@ -44,7 +44,7 @@ static char *known_nt_pipes[] = {
"\\lsarpc",
"\\winreg",
"\\spoolss",
#ifdef MS_DFS
#ifdef WITH_MSDFS
"\\netdfs",
#endif
NULL

View File

@ -411,7 +411,7 @@ static BOOL get_lanman2_dir_entry(connection_struct *conn,
{
/* Needed to show the msdfs symlinks as directories */
if(!lp_host_msdfs() || !lp_msdfs_root(SNUM(conn))
|| !is_msdfs_volume(conn, pathreal))
|| !is_msdfs_link(conn, pathreal))
{
DEBUG(5,("get_lanman2_dir_entry:Couldn't stat [%s] (%s)\n",
pathreal,strerror(errno)));
@ -2238,7 +2238,8 @@ int reply_trans2(connection_struct *conn,
return -1;
}
if (IS_IPC(conn) && (tran_call != TRANSACT2_OPEN))
if (IS_IPC(conn) && (tran_call != TRANSACT2_OPEN)
&& (tran_call != TRANSACT2_GET_DFS_REFERRAL))
return(ERROR(ERRSRV,ERRaccess));
outsize = set_message(outbuf,0,0,True);