Changed MS_DFS to WITH_MSDFS throughout.
authorShirish Kalele <kalele@samba.org>
Fri, 26 May 2000 17:10:40 +0000 (17:10 +0000)
committerShirish Kalele <kalele@samba.org>
Fri, 26 May 2000 17:10:40 +0000 (17:10 +0000)
Fixed trans2 calls on IPC$ to let dfs referral calls through.
(This used to be commit e0965a80bdca5239886b11ef55dc29fed261bfc0)

12 files changed:
source3/configure
source3/configure.in
source3/include/config.h.in
source3/include/msdfs.h
source3/include/proto.h
source3/msdfs/msdfs.c
source3/rpc_server/srv_dfs.c
source3/rpc_server/srv_pipe.c
source3/rpc_server/srv_srvsvc.c
source3/smbd/negprot.c
source3/smbd/nttrans.c
source3/smbd/trans2.c

index 2a79536510273af3d27b4db1777d33f78186c3ae..5477527f5ccf8c96a25d06afff2578f100443eee 100755 (executable)
@@ -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
 
      ;;
index d0061ecf62eeeaebeb6a841ee3f331597b692bb5..742d50da49b13b08527f28c3a5e21df031cf3d1c 100644 (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)
index dc5932b9beee5e8b8aea95a8326d7588f148e340..ed74b6e5560fa76a9917de254643401816521e76 100644 (file)
 #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
index 5323b8749ac5f219775d7a6d02dc2f810c2a238f..2c0f9a19bac1e115a72914713030f9967c8d0b05 100644 (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)) && \
index 69f8e8790b1506d59f58611fc2c7d9b4cb07824b..a8608c47b58bf3d54eafe3fa9a0ab165f3ff2b20 100644 (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  */
 
index 25bc5cc17f74a4a35553106d70cb8240bdad14f2..0101b9e0669a0fb0d8f943438f1a7950249bed7a 100644 (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)
-{
-  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;
-  
-  return True;
-}
-
-BOOL create_msdfs_link(struct junction_map* jn, BOOL exists)
+/**********************************************************************
+ 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;
+  struct dfs_path dp;
   
-  /* 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);
-    }
+  parse_dfs_path(pathname,&dp);
 
-  DEBUG(5,("create_msdfs_link: Creating new msdfs link: %s -> %s\n",
-          path, msdfs_link));
+  /* 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(exists)
-    if(unlink(path)!=0)
-      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;
+      }
 
-  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;
 }
index 9f78b7db37627d7e04f531c247b44a901a9d62c6..2a8bb71604843e8cc2ab1bb69fef251d1d0a1a44 100644 (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));
index aef0c9d23b348d9764e4a70e2ebbcbb12a9c1a3f..11dc5a2f8967ce1aa1cfc125cf68674c41b32eeb 100644 (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 }
index 44c4f5569d4368bb83ef083b9d00a612e412f71e..2e8d33d4d2754ea050b3ed893a9cad5d6363d847 100644 (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
index 60af2924b289031766d6dd5128b95038b79390c8..362d571ff1229536170d505cac6a37f5b58d361e 100644 (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
index 27635cae253f3c4fae07ed249bc753f33bbb8c08..f64ca386f84248b181822c803999950e88a44d3f 100644 (file)
@@ -44,7 +44,7 @@ static char *known_nt_pipes[] = {
   "\\lsarpc",
   "\\winreg",
   "\\spoolss",
-#ifdef MS_DFS
+#ifdef WITH_MSDFS
   "\\netdfs",
 #endif
   NULL
index cc3261a479dcabdac7d2feb0f22e40de0cc2e6f6..900a87e32bbd4794dfa66bad48f30f45e5c33293 100644 (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);