Another attempt to fix bug #4308 - Excel save operation corrupts file ACLs.
commita0e1e76cdd4183e85ea14ce990e47bd80eedd8ef
authorJeremy Allison <jra@samba.org>
Thu, 22 Jan 2009 18:59:47 +0000 (22 10:59 -0800)
committerKarolin Seeger <kseeger@samba.org>
Wed, 28 Jan 2009 08:40:11 +0000 (28 09:40 +0100)
tree324d195e40d18064f531b616079e43437b5371f9
parent0bec8ca5044a04433aa2701fe588fc94a9dea105
Another attempt to fix bug #4308 - Excel save operation corrupts file ACLs.
Simo is completely correct. We should be doing the chown *first*, and fail the
ACL set if this fails. The long standing assumption I made when writing the
initial POSIX ACL code was that Windows didn't control who could chown a file
in the same was as POSIX. In POSIX only root can do this whereas I wasn't sure
who could do this in Windows at the time (I didn't understand the privilege
model). So the assumption was that setting the ACL was more important (early
tests showed many failed ACL set's due to inability to chown). But now we have
privileges in smbd, and we must always fail an ACL set when we can't chown
first. The key that Simo noticed is that the CREATOR_OWNER bits in the ACL
incoming are relative to the *new* owner, not the old one. This is why the old
user owner disappears on ACL set - their access was set via the USER_OBJ in the
creator POSIX ACL and when the ownership changes they lose their access.

Patch is simple - just ensure we do the chown first before evaluating the
incoming ACL re-read the owners. We already have code to do this it just wasn't
rigorously being applied.
Jeremy.
(cherry picked from commit 9c3da895e6dd5df2f4e3377e1bf562b376436081)
source/smbd/posix_acls.c