Error messages in log.smb

Jeremy Allison jallison at whistle.com
Wed Apr 15 16:42:30 GMT 1998


Jan Mostert wrote:
> 
> Last friday we upgraded from 1.9.17p4 to version 1.9.18p3 on a HP-UX 9.04
> machine. Now we get lots of entries in the log.smb file like:
> 
> ERROR: del_share_mode: failed to ftruncate share mode file
> /programs/samba/var/locks/share.1073807365.8199 to size 42 (Permission denied)

Jan,

	It seems that some UNIXs have a bug in their
ftruncate where the permissions for the truncate are
checked at truncate time, not at open time (as on most
systems). Samba is running as root when it opens the
share file, but as the user when it is doing the truncate.

Try adding the following patch (this is now in the
master sources) and recompile, adding the flag
-DFTRUNCATE_NEEDS_ROOT to the CFLAGS line in your
makefile. If people could let me know which UNIXs
have this problem, I can turn it on by default for
them in their section in the Makefile.

Alternatively, if you are now on 1.9.18 you should
try turning on fast share modes, this should now
work on HPUX9.x (due to Andrews' sysV shared memory
work).

Hope this helps,

	Jeremy Allison.
	Samba Team.

------------------cut here-----------------------------------
--- /home/jallison/tmp/samba-1.9.18p4/source/locking_slow.c	Mon Jan 26 12:05:40 1998
+++ locking_slow.c	Thu Apr  9 15:39:19 1998
@@ -502,8 +502,17 @@
       return 0;
     }
     /* Now truncate the file at this point. */
+#ifdef FTRUNCATE_NEEDS_ROOT
+    become_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
     if(ftruncate(fd, newsize)!= 0)
     {
+
+#ifdef FTRUNCATE_NEEDS_ROOT
+      unbecome_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
       DEBUG(0,("ERROR: get_share_modes: failed to ftruncate share \
 mode file %s to size %d (%s)\n", fname, newsize, strerror(errno)));
       if(*old_shares)
@@ -515,6 +524,10 @@
     }
   }
 
+#ifdef FTRUNCATE_NEEDS_ROOT
+      unbecome_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
   if(buf)
     free(buf);
 
@@ -653,15 +666,29 @@
       free(buf);
     return;
   }
+
   /* Now truncate the file at this point. */
+#ifdef FTRUNCATE_NEEDS_ROOT
+  become_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
   if(ftruncate(fd, newsize) != 0)
   {
+
+#ifdef FTRUNCATE_NEEDS_ROOT
+    unbecome_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
     DEBUG(0,("ERROR: del_share_mode: failed to ftruncate share \
 mode file %s to size %d (%s)\n", fname, newsize, strerror(errno)));
     if(buf)
       free(buf);
     return;
   }
+
+#ifdef FTRUNCATE_NEEDS_ROOT
+  unbecome_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
 }
   
 /*******************************************************************
@@ -795,8 +822,18 @@
   }
 
   /* Now truncate the file at this point - just for safety. */
+
+#ifdef FTRUNCATE_NEEDS_ROOT
+  become_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
   if(ftruncate(fd, header_size + (SMF_ENTRY_LENGTH*num_entries))!= 0)
   {
+
+#ifdef FTRUNCATE_NEEDS_ROOT
+    unbecome_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
+
     DEBUG(0,("ERROR: set_share_mode: failed to ftruncate share \
 mode file %s to size %d (%s)\n", fname, header_size + (SMF_ENTRY_LENGTH*num_entries), 
                 strerror(errno)));
@@ -804,6 +841,10 @@
       free(buf);
     return False;
   }
+
+#ifdef FTRUNCATE_NEEDS_ROOT
+  unbecome_root(False);
+#endif /* FTRUNCATE_NEEDS_ROOT */
 
   if(buf)
     free(buf);
-----------------end patch---------------------------
-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------


More information about the samba mailing list