Makefile: Added cleandir target.
authorSamba Release Account <samba-bugs@samba.org>
Sun, 23 Feb 1997 05:18:09 +0000 (05:18 +0000)
committerSamba Release Account <samba-bugs@samba.org>
Sun, 23 Feb 1997 05:18:09 +0000 (05:18 +0000)
chgpasswd.c: Added patch from Roland Haag <haag@think.de> to allow
             password changes to be done more than once.
loadparm.c: Added entries for the "directory mode/directory mask parameters".
            Changed default file mode to 644.
proto.h: Added sys_gethostbyname.
server.c: Added directory mode changes.
system.c: Added sys_gethostbyname.
trans2.c: Added NT_FILE_ATTRIBUTE_NORMAL patch from Roger Orr
          <rorr@csfp.csfb.com>
trans2.h: Defined NT_FILE_ATTRIBUTE_NORMAL for above patch.
util.c: Changes calls to gethostbyname to sys_gethostbyname.
jra@cygnus.com
(This used to be commit d8d8a7ee00971fca7a8d079bfb547af107df35a4)

source3/include/proto.h
source3/include/trans2.h
source3/lib/system.c
source3/lib/util.c
source3/param/loadparm.c
source3/smbd/chgpasswd.c
source3/smbd/server.c
source3/smbd/trans2.c

index 5993e1d67bcadf5162408e38cf1e7740f37949e8..2cd8cfe2a80fe4a20c88166293d852d5521db2e4 100644 (file)
@@ -238,6 +238,7 @@ BOOL lp_map_system(int );
 BOOL lp_delete_readonly(int );
 BOOL lp_fake_oplocks(int );
 int lp_create_mode(int );
+int lp_dir_mode(int );
 int lp_max_connections(int );
 int lp_defaultcase(int );
 int lp_minprintspace(int );
@@ -762,6 +763,7 @@ int sys_rename(char *from, char *to);
 int sys_chmod(char *fname,int mode);
 int sys_chown(char *fname,int uid,int gid);
 int sys_chroot(char *dname);
+struct hostent *sys_gethostbyname(char *name);
 
 /*The following definitions come from  testparm.c  */
 
index cc366ccaea09506a559dd6dde696b6870f93ed76..b99f1e6028d3432cefdd83b2ada6133a26bf9274 100644 (file)
@@ -228,6 +228,11 @@ Byte offset   Type     name                description
 
 #define DIRLEN_GUESS (45+MAX(l1_achName,l2_achName))
 
+/* NT uses a FILE_ATTRIBUTE_NORMAL when no other attributes
+   are set. */
+
+#define NT_FILE_ATTRIBUTE_NORMAL        0x80
+
 /* Function prototypes */
 
 
index ac97449da253cccf4f3eb79804106fb27e5c3554..86c4c28a593e54c857ebb20c5971db9bf8199e09 100644 (file)
@@ -146,7 +146,11 @@ The wait() calls vary between systems
 ********************************************************************/
 int sys_waitpid(pid_t pid,int *status,int options)
 {
+#ifdef USE_WAITPID
   return waitpid(pid,status,options);
+#else /* USE_WAITPID */
+  return wait4(pid, status, options, NULL);
+#endif /* USE_WAITPID */
 }
 
 /*******************************************************************
@@ -235,3 +239,41 @@ int sys_chroot(char *dname)
   return(chroot(dname));
 #endif
 }
+
+/**************************************************************************
+A wrapper for gethostbyname() that tries avoids looking up hostnames 
+in the root domain, which can cause dial-on-demand links to come up for no
+apparent reason.
+****************************************************************************/
+struct hostent *sys_gethostbyname(char *name)
+{
+  char query[256], hostname[256];
+  char *domain;
+
+  /* Does this name have any dots in it? If so, make no change */
+
+  if (strchr(name, '.'))
+    return(gethostbyname(name));
+
+  /* Get my hostname, which should have domain name 
+     attached. If not, just do the gethostname on the
+     original string. 
+  */
+
+  gethostname(hostname, sizeof(hostname) - 1);
+  hostname[sizeof(hostname) - 1] = 0;
+  if ((domain = strchr(hostname, '.')) == NULL)
+    return(gethostbyname(name));
+
+  /* Attach domain name to query and do modified query.
+     If names too large, just do gethostname on the
+     original string.
+  */
+
+  if((strlen(name) + strlen(domain)) >= sizeof(query))
+    return(gethostbyname(name));
+
+  sprintf(query, "%s%s", name, domain);
+  return(gethostbyname(query));
+}
+
index a43de46c511cceefa96ae2a5075046e497dbfedf..643c2fb7a501c0bb3c82066ccc225d1d02e08198 100644 (file)
@@ -3238,7 +3238,7 @@ struct hostent *Get_Hostbyname(char *name)
       return(NULL);
     }
 
-  ret = gethostbyname(name2);
+  ret = sys_gethostbyname(name2);
   if (ret != NULL)
     {
       free(name2);
@@ -3247,7 +3247,7 @@ struct hostent *Get_Hostbyname(char *name)
 
   /* try with all lowercase */
   strlower(name2);
-  ret = gethostbyname(name2);
+  ret = sys_gethostbyname(name2);
   if (ret != NULL)
     {
       free(name2);
@@ -3256,7 +3256,7 @@ struct hostent *Get_Hostbyname(char *name)
 
   /* try with all uppercase */
   strupper(name2);
-  ret = gethostbyname(name2);
+  ret = sys_gethostbyname(name2);
   if (ret != NULL)
     {
       free(name2);
index 67e799a84ddc9e32cab18c8b2ee615991257b31c..672f1fe5483160c3b62e2a612d72e2157d5c9a7b 100644 (file)
@@ -213,6 +213,7 @@ typedef struct
   char *volume;
   int  iMinPrintSpace;
   int  iCreate_mode;
+  int  iDir_mode;
   int  iMaxConnections;
   int  iDefaultCase;
   BOOL bAlternatePerm;
@@ -286,7 +287,8 @@ static service sDefault =
   NULL,    /* writelist */
   NULL,    /* volume */
   0,       /* iMinPrintSpace */
-  0755,    /* iCreate_mode */
+  0644,    /* iCreate_mode */
+  0755,    /* iDir_mode */
   0,       /* iMaxConnections */
   CASE_LOWER, /* iDefaultCase */
   False,   /* bAlternatePerm */
@@ -479,6 +481,8 @@ struct parm_struct
   {"min print space",  P_INTEGER, P_LOCAL,  &sDefault.iMinPrintSpace,   NULL},
   {"create mask",      P_OCTAL,   P_LOCAL,  &sDefault.iCreate_mode,     NULL},
   {"create mode",      P_OCTAL,   P_LOCAL,  &sDefault.iCreate_mode,     NULL},
+  {"directory mask",   P_OCTAL,   P_LOCAL,  &sDefault.iDir_mode,        NULL},
+  {"directory mode",   P_OCTAL,   P_LOCAL,  &sDefault.iDir_mode,        NULL},
   {"set directory",    P_BOOLREV, P_LOCAL,  &sDefault.bNo_set_dir,      NULL},
   {"status",           P_BOOL,    P_LOCAL,  &sDefault.status,           NULL},
   {"hide dot files",   P_BOOL,    P_LOCAL,  &sDefault.bHideDotFiles,    NULL},
@@ -851,6 +855,7 @@ FN_LOCAL_BOOL(lp_delete_readonly,bDeleteReadonly)
 FN_LOCAL_BOOL(lp_fake_oplocks,bFakeOplocks)
 
 FN_LOCAL_INTEGER(lp_create_mode,iCreate_mode)
+FN_LOCAL_INTEGER(lp_dir_mode,iDir_mode)
 FN_LOCAL_INTEGER(lp_max_connections,iMaxConnections)
 FN_LOCAL_INTEGER(lp_defaultcase,iDefaultCase)
 FN_LOCAL_INTEGER(lp_minprintspace,iMinPrintSpace)
index 54b49edf13bce44728fc78adf1dd97af2ec156f8..883ad5214a8c64a4090f91c8a2b16130fa976993 100644 (file)
@@ -41,7 +41,7 @@ static int findpty(char **slave)
 #ifdef SVR4
   extern char *ptsname();
 #else
-  static char line[12] = "/dev/ptyXX";
+  static char line[12];
   void *dirp;
   char *dpname;
 #endif
@@ -54,13 +54,17 @@ static int findpty(char **slave)
     return (master);
   }
 #else
+  strcpy( line, "/dev/ptyXX" );
+
   dirp = OpenDir("/dev");
   if (!dirp) return(-1);
   while ((dpname = ReadDirName(dirp)) != NULL) {
     if (strncmp(dpname, "pty", 3) == 0 && strlen(dpname) == 5) {
+      DEBUG(3,("pty: try to open %s, line was %s\n", dpname, line ) );
       line[8] = dpname[3];
       line[9] = dpname[4];
       if ((master = open(line, O_RDWR)) >= 0) {
+        DEBUG(3,("pty: opened %s\n", line ) );
        line[5] = 't';
        *slave = line;
        CloseDir(dirp);
@@ -280,7 +284,7 @@ BOOL chat_with_program(char *passwordprogram,char *name,char *chatsequence)
       kill(pid, SIGKILL); /* be sure to end this process */
       return(False);
     }
-    if ((wpid = waitpid(pid, &wstat, 0)) < 0) {
+    if ((wpid = sys_waitpid(pid, &wstat, 0)) < 0) {
       DEBUG(3,("The process is no longer waiting!\n\n"));
       return(False);
     }
index 4f3ee0fd0bfff560747f1c35cdc1d2387516e845..09c8fccb5c4fa4dac836cb9b9ce4c38c009eafc9 100644 (file)
@@ -130,19 +130,21 @@ mode_t unix_mode(int cnum,int dosmode)
   if ( !IS_DOS_READONLY(dosmode) )
     result |= (S_IWUSR | S_IWGRP | S_IWOTH);
  
-  if (IS_DOS_DIR(dosmode))
+  if (IS_DOS_DIR(dosmode)) {
     result |= (S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH | S_IWUSR);
-  if (MAP_ARCHIVE(cnum) && IS_DOS_ARCHIVE(dosmode))
-    result |= S_IXUSR;
+    result &= (lp_dir_mode(SNUM(cnum)) | 0700);
+  } else { 
+    if (MAP_ARCHIVE(cnum) && IS_DOS_ARCHIVE(dosmode))
+      result |= S_IXUSR;
 
-  if (MAP_SYSTEM(cnum) && IS_DOS_SYSTEM(dosmode))
-    result |= S_IXGRP;
+    if (MAP_SYSTEM(cnum) && IS_DOS_SYSTEM(dosmode))
+      result |= S_IXGRP;
  
-  if (MAP_HIDDEN(cnum) && IS_DOS_HIDDEN(dosmode))
-    result |= S_IXOTH;  
+    if (MAP_HIDDEN(cnum) && IS_DOS_HIDDEN(dosmode))
+      result |= S_IXOTH;  
  
-  result &= CREATE_MODE(cnum);
+    result &= CREATE_MODE(cnum);
+  }
   return(result);
 }
 
index d489978ab869428d77e7dad32681ef0e7aab0431..ab2fe8853645f149bc6d13ca183e2b3d43e3c606 100644 (file)
@@ -276,6 +276,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
                    strequal(Connections[cnum].dirpath,".") ||
                    strequal(Connections[cnum].dirpath,"/"));
   BOOL was_8_3;
+  int nt_extmode; /* Used for NT connections instead of mode */
 
   *fname = 0;
   *out_of_space = False;
@@ -357,6 +358,8 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
 
   name_map_mangle(fname,False,SNUM(cnum));
 
+  nt_extmode = mode ? mode : NT_FILE_ATTRIBUTE_NORMAL;
+
   switch (info_level)
     {
     case 1:
@@ -440,7 +443,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
       put_long_date(p,mdate); p += 8;
       SIVAL(p,0,size); p += 8;
       SIVAL(p,0,size); p += 8;
-      SIVAL(p,0,mode); p += 4;
+      SIVAL(p,0,nt_extmode); p += 4;
       SIVAL(p,0,strlen(fname)); p += 4;
       SIVAL(p,0,0); p += 4;
       if (!was_8_3) {
@@ -468,7 +471,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
       put_long_date(p,mdate); p += 8;
       SIVAL(p,0,size); p += 8;
       SIVAL(p,0,size); p += 8;
-      SIVAL(p,0,mode); p += 4;
+      SIVAL(p,0,nt_extmode); p += 4;
       SIVAL(p,0,strlen(fname)); p += 4;
       strcpy(p,fname);
       p = pdata + len;
@@ -486,7 +489,7 @@ static int get_lanman2_dir_entry(int cnum,char *path_mask,int dirtype,int info_l
       put_long_date(p,mdate); p += 8;
       SIVAL(p,0,size); p += 8;
       SIVAL(p,0,size); p += 8;
-      SIVAL(p,0,mode); p += 4;
+      SIVAL(p,0,nt_extmode); p += 4;
       SIVAL(p,0,strlen(fname)); p += 4;
       SIVAL(p,0,0); p += 4;
       strcpy(p,fname);