threads / discuss / 58736

safe.directory and ACLs

Subject: safe.directory and ACLs

## tl;dr

5 messages between Nov 2, 2022 and Nov 3, 2022.

replies: 4people: 3as markdown or json

John Soo· Nov 2, 2022, 15:18 UTC · lore
Hello git!

We have some build processes that would like access to repos in /home directories that are 0700. We had done this already:

$ setfacl --recursive --modify group:<build users group>:r-X,default:group:<build users group>:r-X /home

Should this ACL be enough to consider the repos "owned" by the build users? Should *any* ACL be enough to consider the repos "owned" by the build users?

Currently: $ sudo -u <build user> git config --get safe.directory $ sudo -u <build user> git -C /home/<non build user>/repo rev-parse HEAD fatal: unsafe repository ('/home/<non build user>/repo' is owned by someone else) To add an exception for this directory, call:

        git config --global --add safe.directory /home/<non build user>
Kindly,
John Soo
brian m. carlson· Nov 2, 2022, 21:27 UTC · re: John Soo · lore

Re: safe.directory and ACLs

On 2022-11-02 at 15:18:25, John Soo wrote:
Show 20 quoted lines
> Hello git!
> 
> We have some build processes that would like access to repos in /home
> directories that are 0700. We had done this already:
> 
> $ setfacl --recursive --modify group:<build users
> group>:r-X,default:group:<build users group>:r-X /home
> 
> Should this ACL be enough to consider the repos "owned" by the build
> users? Should *any* ACL be enough to consider the repos "owned" by the
> build users?
> 
> Currently:
> $ sudo -u <build user> git config --get safe.directory
> $ sudo -u <build user> git -C /home/<non build user>/repo rev-parse HEAD
> fatal: unsafe repository ('/home/<non build user>/repo' is owned by
> someone else)
> To add an exception for this directory, call:
> 
>         git config --global --add safe.directory /home/<non build user>

No, the permissions of a repository, whether standard Unix permissions or ACLs, are not relevant to ownership. The question here is whether the owner of the .git directory (that is, the value of the `st_uid` field when calling lstat(2) on it) is equal to the effective user ID.

When you the path in `ls`, you can see the owner and group of the file specified, and that owner is what matters here.

-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
John Soo· Nov 2, 2022, 23:41 UTC · re: brian m. carlson · lore

Re: safe.directory and ACLs

Hi brian!
Show 7 quoted lines
> No, the permissions of a repository, whether standard Unix permissions
> or ACLs, are not relevant to ownership.  The question here is whether
> the owner of the .git directory (that is, the value of the `st_uid`
> field when calling lstat(2) on it) is equal to the effective user ID.
>
> When you the path in `ls`, you can see the owner and group of the file
> specified, and that owner is what matters here.
I see. Is that by design or an implementation detail?
Kindly,
John
Taylor Blau· Nov 3, 2022, 00:11 UTC · re: John Soo · lore

Re: safe.directory and ACLs

On Wed, Nov 02, 2022 at 04:41:15PM -0700, John Soo wrote:
Show 11 quoted lines
> Hi brian!
>
> > No, the permissions of a repository, whether standard Unix permissions
> > or ACLs, are not relevant to ownership.  The question here is whether
> > the owner of the .git directory (that is, the value of the `st_uid`
> > field when calling lstat(2) on it) is equal to the effective user ID.
> >
> > When you the path in `ls`, you can see the owner and group of the file
> > specified, and that owner is what matters here.
>
> I see. Is that by design or an implementation detail?

It is by design. See 8959555cee7 (setup_git_directory(): add an owner check for the top-level directory, 2022-03-02) for details.

Thanks, Taylor

← back to recent threads