samba (spuriously?) resetting write permissions on SMBwriteX;
Was: Re: samba resetting permissions on extant files on NT_TRANSACT_CREATE
Buck Huppmann
cjh at frb.gov
Mon Dec 31 11:05:46 GMT 2001
i wrote:
> testing has turned up yet another vagary of samba behavior with
> ``inherit permissions'' set, although i leave it to you all to discern
> whether it's a bug or not
>
> sort of the same scenario as previously, but instead of a SMBntcreateX
> even a subsequent SMBwriteX to an existing file will reset the mode *if*
> ``map archive'' is set and the archive-bit hack hasn't previously been
> applied to the file. seems (as excerpted below) file_chmod() will get
> called in such a case, and then inherited permissions will override
> permissions on the extant file.
FWIW--patch for this is included below, again, if anybody thinks it advis-
able (besides me)
--- samba-2.2.2/source/smbd/dosmode.c.orig Fri Apr 13 19:24:46 2001
+++ samba-2.2.2/source/smbd/dosmode.c Mon Dec 31 13:55:39 2001
@@ -228,9 +228,17 @@
unixmode |= tmp;
}
- /* if we previously had any w bits set then leave them alone
- whilst adding in the new w bits, if the new mode is not rdonly */
+ /* if the new mode is not aRONLY, reset write bits (presumably
+ * including owner-write, but maybe not) per the config IFF the
+ * current UNIX mode doesn't already grant owner write access.
+ * this is the conservative heuristic for not resetting write bits
+ * on files if we're called and the desired change is only from
+ * non-archive to archive, say, and not a change in writability,
+ * as it accords with dos_mode()'s mapping of S_IWUSR to DOS
+ * ~aRONLY, at present */
if (!IS_DOS_READONLY(dosmode)) {
+ if (st->st_mode & S_IWUSR)
+ unixmode &= ~(S_IWUSR|S_IWGRP|S_IWOTH);
unixmode |= (st->st_mode & (S_IWUSR|S_IWGRP|S_IWOTH));
}
...
More information about the samba-technical
mailing list