file_chmod() patch

Francois Gouget fgouget at
Sun Feb 14 05:56:00 GMT 1999

	file_chmod() currently fails to make a file user writable if the
unix permissions already had the group or other write bit set. This
caused the 'setmode' smbclient command and the 'attrib' dos command to
be ineffective on such files.
	This was because in attempting to preserve the existing write
bits we in fact preserved the state of all three write bits, whether set
or not. With this patch we just 'OR' the computed mode with the existing
write bits to preserve the ones that are already set. 
	See my message "Unix permission problems with 'attrib'" in the
samba mailing list for a more detailed description of the symptoms. 

--- samba-2.0.2/source/smbd/dosmode.c   Thu Sep 17 16:06:56 1998
+++ samba/source/smbd/dosmode.c   Sat Feb 13 21:29:07 1999
@@ -180,10 +180,8 @@
   /* if we previously had any w bits set then leave them alone 
    if the new mode is not rdonly */
-  if (!IS_DOS_READONLY(dosmode) &&
-      (tmp = st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH))) {
-    unixmode &= ~(S_IWUSR|S_IWGRP|S_IWOTH);
-    unixmode |= tmp;
+  if (!IS_DOS_READONLY(dosmode)) {
+    unixmode |= (st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH));

Francois Gouget
fgouget at

More information about the samba-technical mailing list