Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add the.git subdir as anothersafe.directory on Cygwin CI#1916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 2 commits intogitpython-developers:mainfromEliahKagan:dubious
May 27, 2024

Conversation

EliahKagan
Copy link
Member

@EliahKaganEliahKagan commentedMay 26, 2024
edited
Loading

As shown inthis run on my fork, the CI test job for Cygwin is failing now. This fixes that.

The first commit in this pull request just demonstrates that the failure is due to the upgrade of the Cygwingit package from 2.43.0-1 to 2.45.1-1. Although that commit makes test pass, I recommend against following that approach, mainly because the new version containsmultiple security updates (coming in with the upstream2.45.1 version, not with any downstream patches), but also because the older version will eventually be dropped from the Cygwin repositories.

The better workaround is in the second commit here, which adds the.git subdirectory of the clonedGitPython directory as a value of the multi-valuedsafe.directory Git configuration variable. Its parent directory is already added, which was previously sufficient, but not anymore.

I suspect that, rather than this being any bug in the downstream package, this is actually the correct behavior due to one of the several security fixes in the new version of Git, though I have not verified that. So maybe this is really not a workaround, but a permanent fix.

I believe the reason there is no need to modify any other workflow is that the other workflows don't need to add anysafe.directory paths at all: they either clone the repository with the necessary ownership in the first place or, in the case of the Alpine Linux job,set the ownership withchown.

Using this older version is not in general secure, since the newversion is a security update. It is sometimes acceptable to runsoftware with security bugs in CI workflows, but the intent of thischange is just to check if the version of the Cygwin `git` packageis the cause of the failures. If so, they can probably be fixed orworked around in a better way than downgrading. (Furthermore, thelower version of the `git` package will not always be avaialablefrom Cygwin's repositories.)
This undoes the change of pinning Git to an earlier version (beforethe recent security update) on Cygwin, and instead adds the `.git`subdirectory of the `GitPython` directory as an additional value ofthe multi-valued `safe.directory` Git configuration variable.
@EliahKaganEliahKagan marked this pull request as ready for reviewMay 26, 2024 21:28
@EliahKaganEliahKagan mentioned this pull requestMay 26, 2024
Copy link
Member

@ByronByron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks a lot!

Seeing the change tosafe.directory made me wonder if this is indeed a change in how it works and ifgitoxide is affected.

And indeed, 22 months agoI see no evidence of it.

This line tells us it will check the git-dir/repository-directory if there is no worktree, but it's certainly strange that awt/.git is a clone that is bare, it's an unusual name.

Anyway, it's good this is fixed and I don't worry about it.

@ByronByron merged commit9fbfb71 intogitpython-developers:mainMay 27, 2024
@EliahKaganEliahKagan deleted the dubious branchMay 27, 2024 11:57
@EliahKagan
Copy link
MemberAuthor

I'm still not totally clear what's going on here. Some of the changes in 2.45.1 were judged overzealous and undone in 2.45.2. But don't know if that has anything to do with this. Anyway, git 2.45.2 is not yet in the Cygwin repositories, and I'm not sure it will be since it's not a security fix (so it might be skipped over, with some future version being packaged next).

Byron reacted with thumbs up emoji

@EliahKagan
Copy link
MemberAuthor

This line tells us it will check the git-dir/repository-directory if there is no worktree, but it's certainly strange that awt/.git is a clone that is bare, it's an unusual name.

That specific fragment is:

structsafe_directory_datadata= {.path=worktree ?worktree :gitdir};

But that is only used for this:

/* * data.path is the "path" that identifies the repository and it is * constant regardless of what failed above. data.is_safe should be * initialized to false, and might be changed by the callback. */git_protected_config(safe_directory_cb,&data);returndata.is_safe;

However, that code is just for figuring out which path to look for as a value of thesafe.directory configuration variable. (It makes sense that you were looking at that: it's the part that is directly relevant to what I was saying about thesafe.directory variable in the PR description above! But I think the change may be subtler than that, and may not directly involve a change to that.)

In between the two is the ownership check, which does not referencedata:

if (!git_env_bool("GIT_TEST_ASSUME_DIFFERENT_OWNER",0)&&(!gitfile||is_path_owned_by_current_user(gitfile,report))&&(!worktree||is_path_owned_by_current_user(worktree,report))&&(!gitdir||is_path_owned_by_current_user(gitdir,report)))return1;

While none of this code has changed around the same time as the breakage that this PR fixed, nor recently, I do not know if thesafe.directory checking logic implemented throughgit_protected_config changed, though I would guess it has not--I think it's just doing a straightforward comparisong to values ofsafe.directory where it is defined in protected (not local or worktree) scopes. I also don't know if the way the effects of call that are used later changed.

More likely relevant, I think, is that I am also unsure if any of thegitfile,worktree, andgitdir parameters are passed as non-NULL values where they had beenNULL before.

So while it seems like maybe the need to add the.git directory explicitly is due to some oddity of Cygwin paths, I am not sure. Likewise, I cannot tell directly from this if any recent changes tosafe.directory-related checks in Git would have any implications for gitoxide.


I am wondering if some GitPython tests run commands in the.git directory of a non-bare repository.

At least with current versions of Git, this requires that the.git directory specifically be owned by the current user or listed as a value of thesafe.directory variable (in a protected scope), even if the working tree is a parent directory of that.git directory andgit will operate on the working tree itself due to it being listed explicitly insafe.directory:

ek@Kip:~/src$ git versiongit version 2.48.1ek@Kip:~/src$ git init ownership-experimentInitialized empty Git repository in /home/ek/src/ownership-experiment/.git/ek@Kip:~/src$ sudo chown -R ek2:ek2 ownership-experiment[sudo] password for ek:ek@Kip:~/src$ ls -ld ownership-experiment ownership-experiment/.gitdrwxrwxr-x 3 ek2 ek2 4096 Feb 20 15:45 ownership-experimentdrwxrwxr-x 6 ek2 ek2 4096 Feb 20 15:45 ownership-experiment/.gitek@Kip:~/src$ git -C ownership-experiment statusfatal: detected dubious ownership in repository at '/home/ek/src/ownership-experiment'To add an exception for this directory, call:        git config --global --add safe.directory /home/ek/src/ownership-experimentek@Kip:~/src[128]$ git config --global --add safe.directory /home/ek/src/ownership-experimentek@Kip:~/src$ git -C ownership-experiment statusOn branch mainNo commits yetnothing to commit (create/copy files and use "git add" to track)ek@Kip:~/src$ git -C ownership-experiment/.git statusfatal: detected dubious ownership in repository at '/home/ek/src/ownership-experiment/.git'To add an exception for this directory, call:        git config --global --add safe.directory /home/ek/src/ownership-experiment/.git

That was on GNU/Linux, but it is not specific to it (nor to systems with the somewhat rare relaxed 0002 umask value I have set there). It is also not specific to passing the directory to operate on using-C (which makes sense, since-C is implemented by actually changing directory).

That same experiment in Cygwin, where I create the repository with Cygwin git 2.45.1, then outside the Cygwin environment navigate to the working tree in Windows Explorer and recursively change its ownership to another user (which includes changing that of its.git subdirectory, since I do it recursively) has the same effect.

Could this behavior have been what changed? Could the working tree have been sufficient before, even when operating directly in the.git subdirectory?

@Byron
Copy link
Member

Thanks for reviving this conversation.

I am entirely unsure how all this relates to GitPython, but know thatgitoxide has a completely different security model when it comes to that. It determines the ownership of configuration files so it can trust (or ignore) sections in the configuration (each section has 'trust' attached to it, based on file ownership).

@EliahKagan
Copy link
MemberAuthor

I am entirely unsure how all this relates to GitPython

As far as I know, the only connection to GitPython is through its Cygwin CI workflow, which had to be changed to accommodate this. That is, I am not proposing that a bug in GitPython itself causes this or that anything in thegit/ directory should be changed related to it. Rather, I am curious if it is due to something specific to Cygwin. The Cygwin workflow breaks more often than some of the others, so if I can understand more of what is happening in it, then maybe that can be improved or at least handled more easily. To be clear, I donot think this has anything at all to do with the current breakage described in#2004.

but know thatgitoxide has a completely different security model when it comes to that. It determines the ownership of configuration files so it can trust (or ignore) sections in the configuration (each section has 'trust' attached to it, based on file ownership).

Thanks--this way of putting it clarifies a comment that puzzled me during something I'm working on in gitoxide!

@Byron
Copy link
Member

Thanks for clarifying - indeed I was trying to understand if there was something actionable for GitPython and had/have no memory on how this works here. In that regard I am happy thatgitoxide won't have that problem at least as it's generally more open than Git is by default, ideally not any disadvantage.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ByronByronByron approved these changes

Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@EliahKagan@Byron

[8]ページ先頭

©2009-2025 Movatter.jp