libgit2 / libgit2/pygit2

Group permissions not respected

未关闭
#1,153 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
1.7k
派生
408
平均合并
2 天 57 分钟
30 天内合并 PR
7

描述

I ran into a strange behavior when trying to read a bare repo on my FreeBSD machine with pygit2:

Info:

  • FreeBSD: 13.1
  • libgit2-1.3.2
  • pygit2: 1.10.0
> whoami 
www

> git init --bare testrepo.git
Initialized empty Git repository in /example/testrepo.git/

> chmod -R 770 testrepo.git 
> ls -lah
[...]
drwxrwx---  7 www   www      10B Jul 28 08:48 testrepo.git

> python3 -c "import pygit2;path = pygit2.discover_repository('testrepo.git');print(path);print(pygit2.Repository(path))"
/example/testrepo.git/
pygit2.Repository('/example/testrepo.git/')

> sudo chown -R git:www testrepo.git 
> ls -lah
[...]
drwxrwx---  7 git   www      10B Jul 28 08:48 testrepo.git

> python3 -c "import pygit2;path = pygit2.discover_repository('testrepo.git');print(path);print(pygit2.Repository(path))"
/example/testrepo.git/
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/example/.venv/lib/python3.9/site-packages/pygit2/repository.py", line 1620, in __init__
    path_backend = init_file_backend(path, flags)
_pygit2.GitError: Repository not found at testrepo.git

> sudo chmod -R 777 testrepo.git
> ls -lah
[...]
drwxrwxrwx  7 git   www      10B Jul 28 08:48 testrepo.git

> python3 -c "import pygit2;path = pygit2.discover_repository('testrepo.git');print(path);print(pygit2.Repository(path))"
/example/testrepo.git/
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/example/.venv/lib/python3.9/site-packages/pygit2/repository.py", line 1620, in __init__
    path_backend = init_file_backend(path, flags)
_pygit2.GitError: Repository not found at testrepo.git

It seems, like the repo can only be opened if the owner is also the user; the group permissions seem to be ignored.

I could confirm this behavior also on a Ubuntu machine:

  • Ubuntu: 20.04
  • libgit2-28
  • pygit2: 1.10.0

I'm not quite sure if this is a problem of pygit2 or the underlying libgit2, or if I did something wrong…

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

在受支持的环境中复现 issue 中的权限设置,从 pygit2/repository.py 第 1620 行所示的 pygit2.Repository 和 init_file_backend 调用开始。跟踪组权限失败发生在 Python binding 还是 libgit2 中,然后添加回归测试覆盖,并记录已确认的行为或修复方案。

由索引模型根据 Issue 内容生成。

评估

技术栈
git, python
领域
backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。