[PATCH] Prevent the overwriting of global errno in set file info code path.

Jeremy Allison jra at samba.org
Wed Mar 17 11:58:39 MDT 2010


On Wed, Mar 17, 2010 at 10:34:51AM +0200, Surbhi Palande wrote:
> 
> Thats correct. I did a saving of the errno in the
> posixacl_sys_acl_set_file() as a safety check, since our intention is to
> have the errno from the acl_set_file(). Normally speaking this should
> not get overwritten at this point. The actual overwriting of errno is
> done by the call to SMB_VFS_SYS_ACL_FREE_ACL() (called from
> set_unix_posix_default_acl)

Can you explain this clearer please ? I don't understand.
What is the exact case where errno gets overwritten ?

> The -EINVAL setting/overwriting takes place by the call to
> SMB_VFS_SYS_ACL_FREE_ACL() (which does a free of an acl entry which is
> already freed by acl_free() called previously). 

Again, I don't understand this. I presume you're talking about
this code:

        if (SMB_VFS_SYS_ACL_SET_FILE(conn, fname, SMB_ACL_TYPE_DEFAULT, def_acl) == -1) {
                DEBUG(5,("set_unix_posix_default_acl: acl_set_file failed on directory %s (%s)\n",
                        fname, strerror(errno) ));
                SMB_VFS_SYS_ACL_FREE_ACL(conn, def_acl);
                return False;
        }

Under what circumstances has def_acl already been freed ?
I really need to understand your issue completely before
correcting this code.

> This is something that happens every single time when you do a cp -p
> file1 file2. cp -p calls a fgetxattr() with a 
> "system.posix_acl_access" which should be returning to the client an
> "Operation not supported" on an underneath extended fs (on the server
> side). But instead the error returned is a "Permission denied" to the
> client side. 

Yes, I understand this.

> Ideally speaking, should not posixacl_sys_acl_set_file() be returning
> the errno (or or errno) that its interested in? However doing so,
> requires changes at quiet a few places and thats why I took the lesser
> affecting path in this patch.

Why ? posixacl_sys_acl_set_file() should be returning the
correct errno when returning -1. Can you explain when this
is not happening and the case where this happens ?

Jeremy.


More information about the samba-technical mailing list