charset.c: Split charset_initialise() into 2 - a charset_initialise() and
[jra/samba/.git] / source3 / smbd / server.c
index 528e4769ea42df64c94e9c0dfddc827a2c286c41..5f5404bcc27e77076350aa00e14c7d07aacef558 100644 (file)
@@ -817,6 +817,22 @@ BOOL check_name(char *name,int cnum)
     }
 
   ret = reduce_name(name,Connections[cnum].connectpath,lp_widelinks(SNUM(cnum)));
+
+  /* Check if we are allowing users to follow symlinks */
+  /* Patch from David Clerc <David.Clerc@cui.unige.ch>
+     University of Geneva */
+
+  if (!lp_symlinks(SNUM(cnum)))
+    {
+      struct stat statbuf;
+      if ( (sys_lstat(name,&statbuf) != -1) &&
+          (S_ISLNK(statbuf.st_mode)) )
+        {
+          DEBUG(3,("check_name: denied: file path name %s is a symlink\n",name));
+          ret=0; 
+        }
+    }
+
   if (!ret)
     DEBUG(5,("check_name on %s failed\n",name));
 
@@ -1577,9 +1593,9 @@ void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,
       int old_open_mode = old_shares[i].share_mode &0xF;
       int old_deny_mode = (old_shares[i].share_mode >>4)&7;
 
-      if (deny_mode > 4 || old_deny_mode > 4 || old_open_mode > 2) 
+      if (old_deny_mode > 4 || old_open_mode > 2) 
       {
-       DEBUG(2,("Invalid share mode (%d,%d,%d) on file %s\n",
+       DEBUG(0,("Invalid share mode found (%d,%d,%d) on file %s\n",
                 deny_mode,old_deny_mode,old_open_mode,fname));
         free((char *)old_shares);
         if(share_locked)
@@ -3886,6 +3902,7 @@ static void process(void)
       int deadtime = lp_deadtime()*60;
       int counter;
       int last_keepalive=0;
+      int service_load_counter = 0;
 
       if (deadtime <= 0)
        deadtime = DEFAULT_SMBD_TIMEOUT;
@@ -3904,6 +3921,12 @@ static void process(void)
          BOOL allidle = True;
          extern int keepalive;
 
+      if (counter > 365 * 3600) /* big number of seconds. */
+      {
+        counter = 0;
+        service_load_counter = 0;
+      }
+
          if (smb_read_error == READ_EOF) {
            DEBUG(3,("end of file from client\n"));
            return;
@@ -3921,18 +3944,16 @@ static void process(void)
          unbecome_user();
 
          /* check for smb.conf reload */
-         if (!(counter%SMBD_RELOAD_CHECK))
-           reload_services(True);
+         if (counter >= service_load_counter + SMBD_RELOAD_CHECK)
+      {
+        service_load_counter = counter;
 
-#if 0 /* JRA */
-         /* check the share modes every 10 secs */
-         if (!(counter%SHARE_MODES_CHECK))
-           check_share_modes();
+        /* remove all unused services.  reduce some of that memory overhead. */
+        lp_killunused(snum_used);
 
-         /* clean the share modes every 5 minutes */
-         if (!(counter%SHARE_MODES_CLEAN))
-           clean_share_modes();
-#endif /* JRA */
+        /* reload services, if files have changed. */
+           reload_services(True);
+      }
 
          /* automatic timeout if all connections are closed */      
          if (num_connections_open==0 && counter >= IDLE_CLOSED_TIMEOUT) {
@@ -4106,7 +4127,7 @@ static void usage(char *pname)
 
   setup_logging(argv[0],False);
 
-  charset_initialise(-1);
+  charset_initialise();
 
   /* make absolutely sure we run as root - to handle cases whre people
      are crazy enough to have it setuid */
@@ -4221,7 +4242,7 @@ static void usage(char *pname)
   if (!reload_services(False))
     return(-1);        
 
-  charset_initialise(lp_client_code_page());
+  codepage_initialise(lp_client_code_page());
 
   strcpy(myworkgroup, lp_workgroup());