* [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories
@ 2022-11-06 11:03 Michał Górny
2022-11-06 11:19 ` Florian Schmaus
0 siblings, 1 reply; 7+ messages in thread
From: Michał Górny @ 2022-11-06 11:03 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Mark all checkout directories as "safe" to avoid dubious ownership
errors with newer git versions when the checkout directory is accessed
from src_install().
Bug: https://bugs.gentoo.org/879353
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/git-r3.eclass | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
index 59d4f9a0038f..bdb28565e2f9 100644
--- a/eclass/git-r3.eclass
+++ b/eclass/git-r3.eclass
@@ -887,6 +887,11 @@ git-r3_checkout() {
cp "${orig_repo}"/packed-refs "${GIT_DIR}"/packed-refs || die
fi
+ # mark this directory as "safe" so that src_install() can access it
+ # https://bugs.gentoo.org/879353
+ git config --global --add safe.directory \
+ "$(cd "${out_dir}" && echo "${PWD}")" || die
+
# (no need to copy HEAD, we will set it via checkout)
if [[ -f ${orig_repo}/shallow ]]; then
--
2.38.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories
2022-11-06 11:03 [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories Michał Górny
@ 2022-11-06 11:19 ` Florian Schmaus
2022-11-06 11:38 ` Michał Górny
2022-11-06 11:39 ` Michael Orlitzky
0 siblings, 2 replies; 7+ messages in thread
From: Florian Schmaus @ 2022-11-06 11:19 UTC (permalink / raw
To: gentoo-dev
On 06.11.22 12:03, Michał Górny wrote:
> Mark all checkout directories as "safe" to avoid dubious ownership
> errors with newer git versions when the checkout directory is accessed
> from src_install().
>
> Bug: https://bugs.gentoo.org/879353
> Signed-off-by: Michał Górny <mgorny@gentoo.org>
> ---
> eclass/git-r3.eclass | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
> index 59d4f9a0038f..bdb28565e2f9 100644
> --- a/eclass/git-r3.eclass
> +++ b/eclass/git-r3.eclass
> @@ -887,6 +887,11 @@ git-r3_checkout() {
> cp "${orig_repo}"/packed-refs "${GIT_DIR}"/packed-refs || die
> fi
>
> + # mark this directory as "safe" so that src_install() can access it
> + # https://bugs.gentoo.org/879353
> + git config --global --add safe.directory \
> + "$(cd "${out_dir}" && echo "${PWD}")" || die
I guess there is no way we can avoid the --global and use --local instead?
- Flow
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories
2022-11-06 11:19 ` Florian Schmaus
@ 2022-11-06 11:38 ` Michał Górny
2022-11-06 15:08 ` Florian Schmaus
2022-11-06 11:39 ` Michael Orlitzky
1 sibling, 1 reply; 7+ messages in thread
From: Michał Górny @ 2022-11-06 11:38 UTC (permalink / raw
To: gentoo-dev
On Sun, 2022-11-06 at 12:19 +0100, Florian Schmaus wrote:
> On 06.11.22 12:03, Michał Górny wrote:
> > Mark all checkout directories as "safe" to avoid dubious ownership
> > errors with newer git versions when the checkout directory is accessed
> > from src_install().
> >
> > Bug: https://bugs.gentoo.org/879353
> > Signed-off-by: Michał Górny <mgorny@gentoo.org>
> > ---
> > eclass/git-r3.eclass | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
> > index 59d4f9a0038f..bdb28565e2f9 100644
> > --- a/eclass/git-r3.eclass
> > +++ b/eclass/git-r3.eclass
> > @@ -887,6 +887,11 @@ git-r3_checkout() {
> > cp "${orig_repo}"/packed-refs "${GIT_DIR}"/packed-refs || die
> > fi
> >
> > + # mark this directory as "safe" so that src_install() can access it
> > + # https://bugs.gentoo.org/879353
> > + git config --global --add safe.directory \
> > + "$(cd "${out_dir}" && echo "${PWD}")" || die
>
> I guess there is no way we can avoid the --global and use --local instead?
>
safe.directory works only in protected scoeps, i.e. system, global and
command. See git-config(1).
That said, the check wouldn't really make sense if the repository were
able to declare itself safe.
--
Best regards,
Michał Górny
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories
2022-11-06 11:19 ` Florian Schmaus
2022-11-06 11:38 ` Michał Górny
@ 2022-11-06 11:39 ` Michael Orlitzky
1 sibling, 0 replies; 7+ messages in thread
From: Michael Orlitzky @ 2022-11-06 11:39 UTC (permalink / raw
To: gentoo-dev
On Sun, 2022-11-06 at 12:19 +0100, Florian Schmaus wrote:
>
> I guess there is no way we can avoid the --global and use --local instead?
>
The setting is only respected if it's in the global ($HOME) or system
(/etc) configs. There's no explanation for that in the man page, but
it's probably because you can't let $repo/.git/config be in charge of
safety if $repo is untrustworthy.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories
2022-11-06 11:38 ` Michał Górny
@ 2022-11-06 15:08 ` Florian Schmaus
2022-11-06 15:52 ` Michał Górny
0 siblings, 1 reply; 7+ messages in thread
From: Florian Schmaus @ 2022-11-06 15:08 UTC (permalink / raw
To: gentoo-dev
On 06.11.22 12:38, Michał Górny wrote:
> On Sun, 2022-11-06 at 12:19 +0100, Florian Schmaus wrote:
>> On 06.11.22 12:03, Michał Górny wrote:
>>> Mark all checkout directories as "safe" to avoid dubious ownership
>>> errors with newer git versions when the checkout directory is accessed
>>> from src_install().
>>>
>>> Bug: https://bugs.gentoo.org/879353
>>> Signed-off-by: Michał Górny <mgorny@gentoo.org>
>>> ---
>>> eclass/git-r3.eclass | 5 +++++
>>> 1 file changed, 5 insertions(+)
>>>
>>> diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
>>> index 59d4f9a0038f..bdb28565e2f9 100644
>>> --- a/eclass/git-r3.eclass
>>> +++ b/eclass/git-r3.eclass
>>> @@ -887,6 +887,11 @@ git-r3_checkout() {
>>> cp "${orig_repo}"/packed-refs "${GIT_DIR}"/packed-refs || die
>>> fi
>>>
>>> + # mark this directory as "safe" so that src_install() can access it
>>> + # https://bugs.gentoo.org/879353
>>> + git config --global --add safe.directory \
>>> + "$(cd "${out_dir}" && echo "${PWD}")" || die
>>
>> I guess there is no way we can avoid the --global and use --local instead?
>>
>
> safe.directory works only in protected scoeps, i.e. system, global and
> command. See git-config(1).
>
> That said, the check wouldn't really make sense if the repository were
> able to declare itself safe.
Fair point, and I suspected as much.
Am I right that this does modify ~portage/.gitconfig (so usually
/var/lib/portage/home/.gitconfig)? If so, I wonder if this could be
avoided, e.g., by setting XDG_CONFIG_HOME to $T/.config. But I guess
that has the potential to break other things. And having some eclass
modifying the home directory of the portage user is not probably
something we could live with. It would just we be nice if the
save.directory setting would be just temporary during the emerge, e.g.,
set somewhere under T.
- Flow
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories
2022-11-06 15:08 ` Florian Schmaus
@ 2022-11-06 15:52 ` Michał Górny
2022-11-06 19:07 ` Florian Schmaus
0 siblings, 1 reply; 7+ messages in thread
From: Michał Górny @ 2022-11-06 15:52 UTC (permalink / raw
To: gentoo-dev
On Sun, 2022-11-06 at 16:08 +0100, Florian Schmaus wrote:
> On 06.11.22 12:38, Michał Górny wrote:
> > On Sun, 2022-11-06 at 12:19 +0100, Florian Schmaus wrote:
> > > On 06.11.22 12:03, Michał Górny wrote:
> > > > Mark all checkout directories as "safe" to avoid dubious ownership
> > > > errors with newer git versions when the checkout directory is accessed
> > > > from src_install().
> > > >
> > > > Bug: https://bugs.gentoo.org/879353
> > > > Signed-off-by: Michał Górny <mgorny@gentoo.org>
> > > > ---
> > > > eclass/git-r3.eclass | 5 +++++
> > > > 1 file changed, 5 insertions(+)
> > > >
> > > > diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
> > > > index 59d4f9a0038f..bdb28565e2f9 100644
> > > > --- a/eclass/git-r3.eclass
> > > > +++ b/eclass/git-r3.eclass
> > > > @@ -887,6 +887,11 @@ git-r3_checkout() {
> > > > cp "${orig_repo}"/packed-refs "${GIT_DIR}"/packed-refs || die
> > > > fi
> > > >
> > > > + # mark this directory as "safe" so that src_install() can access it
> > > > + # https://bugs.gentoo.org/879353
> > > > + git config --global --add safe.directory \
> > > > + "$(cd "${out_dir}" && echo "${PWD}")" || die
> > >
> > > I guess there is no way we can avoid the --global and use --local instead?
> > >
> >
> > safe.directory works only in protected scoeps, i.e. system, global and
> > command. See git-config(1).
> >
> > That said, the check wouldn't really make sense if the repository were
> > able to declare itself safe.
>
>
> Fair point, and I suspected as much.
>
> Am I right that this does modify ~portage/.gitconfig (so usually
> /var/lib/portage/home/.gitconfig)? If so, I wonder if this could be
> avoided, e.g., by setting XDG_CONFIG_HOME to $T/.config. But I guess
> that has the potential to break other things. And having some eclass
> modifying the home directory of the portage user is not probably
> something we could live with. It would just we be nice if the
> save.directory setting would be just temporary during the emerge, e.g.,
> set somewhere under T.
>
HOME
All
Ditto
The full path to an appropriate temporary directory for use by any
programs invoked by the ebuild that may read or modify the home
directory. [1]
[1] https://projects.gentoo.org/pms/8/pms.html#x1-10900011.1
--
Best regards,
Michał Górny
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories
2022-11-06 15:52 ` Michał Górny
@ 2022-11-06 19:07 ` Florian Schmaus
0 siblings, 0 replies; 7+ messages in thread
From: Florian Schmaus @ 2022-11-06 19:07 UTC (permalink / raw
To: gentoo-dev
On 06.11.22 16:52, Michał Górny wrote:
> On Sun, 2022-11-06 at 16:08 +0100, Florian Schmaus wrote:
>> Fair point, and I suspected as much.
>>
>> Am I right that this does modify ~portage/.gitconfig (so usually
>> /var/lib/portage/home/.gitconfig)? If so, I wonder if this could be
>> avoided, e.g., by setting XDG_CONFIG_HOME to $T/.config. But I guess
>> that has the potential to break other things. And having some eclass
>> modifying the home directory of the portage user is not probably
>> something we could live with. It would just we be nice if the
>> save.directory setting would be just temporary during the emerge, e.g.,
>> set somewhere under T.
>>
>
> HOME
> All
> Ditto
> The full path to an appropriate temporary directory for use by any
> programs invoked by the ebuild that may read or modify the home
> directory. [1]
Nice, I wasn't aware that PMS mandates HOME being set.
- Flow
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-11-06 19:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-06 11:03 [gentoo-dev] [PATCH] git-r3.eclass: Add checkout dirs as "safe" directories Michał Górny
2022-11-06 11:19 ` Florian Schmaus
2022-11-06 11:38 ` Michał Górny
2022-11-06 15:08 ` Florian Schmaus
2022-11-06 15:52 ` Michał Górny
2022-11-06 19:07 ` Florian Schmaus
2022-11-06 11:39 ` Michael Orlitzky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox