From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Philip Oakley <philipoakley@iee.email>,
Guy Maurel <guy.j@maurel.de>,
git@vger.kernel.org
Subject: Re: a problem with git describe
Date: Tue, 26 Apr 2022 17:43:32 +0200 (CEST) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.2204261742120.355@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <20220425084003.nf267feurpqyvmsd@carlos-mbp.lan>
[-- Attachment #1: Type: text/plain, Size: 1928 bytes --]
Hi Carlo,
On Mon, 25 Apr 2022, Carlo Marcelo Arenas Belón wrote:
> On Mon, Apr 25, 2022 at 12:02:45AM -0700, Carlo Marcelo Arenas Belón wrote:
> > On Sun, Apr 24, 2022 at 11:39:27PM -0700, Junio C Hamano wrote:
> > > Carlo Marcelo Arenas Belón <carenas@gmail.com> writes:
> > >
> > > > At that point, though you might as well excempt root from this check
> > >
> > > But "root" or any higher-valued account is what needs this kind of
> > > protection the most, no?
> >
> > correct, and I didn't meant to excempt root from the protection, but
> > from the check that requires that the config file ownership matches.
> >
> > if the config file is owned by root, we already lost, regardless of what
> > uid git is running as.
>
> apologies for my confusing english, hopefully this C is clearer
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 58fd813bd01..6a385be7d1d 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -440,9 +440,19 @@ static inline int git_offset_1st_component(const char *path)
> static inline int is_path_owned_by_current_uid(const char *path)
> {
> struct stat st;
> + uid_t euid;
> +
> if (lstat(path, &st))
> return 0;
> - return st.st_uid == geteuid();
> +
> + euid = geteuid();
> + if (!euid && st.st_uid && isatty(0)) {
> + struct stat ttyst;
> + if (!stat(ttyname(0), &ttyst))
> + euid = ttyst.st_uid;
> + }
> +
> + return st.st_uid == euid;
> }
>
> #define is_path_owned_by_current_user is_path_owned_by_current_uid
>
> it uses stdin instead not to fall in the issue that was raised by
> Gábor, but I am affraid that it might need to check all stdnandles for
> a valid tty to be safe, and it looking even more complex.
Maybe a better idea for the `sudo` scenario would be to make use of
`SUDO_UID` (assuming that no adversary can gain control over the user's
environment variables)?
Ciao,
Dscho
next prev parent reply other threads:[~2022-04-26 15:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-23 9:12 a problem with git describe Guy Maurel
2022-04-23 11:27 ` Philip Oakley
2022-04-23 16:09 ` Junio C Hamano
2022-04-23 23:44 ` Junio C Hamano
2022-04-25 2:01 ` Carlo Marcelo Arenas Belón
2022-04-25 5:05 ` SZEDER Gábor
2022-04-25 6:03 ` Carlo Marcelo Arenas Belón
2022-04-25 6:39 ` Junio C Hamano
2022-04-25 7:02 ` Carlo Marcelo Arenas Belón
2022-04-25 8:40 ` Carlo Marcelo Arenas Belón
2022-04-25 15:11 ` Guy Maurel
2022-04-26 15:43 ` Johannes Schindelin [this message]
2022-04-26 15:56 ` rsbecker
2022-04-26 16:35 ` Carlo Arenas
2022-04-26 16:46 ` Junio C Hamano
2022-04-26 17:15 ` Carlo Arenas
2022-04-26 15:45 ` Johannes Schindelin
2022-04-26 16:25 ` Junio C Hamano
2022-04-26 1:52 ` Taylor Blau
2022-04-26 15:41 ` Johannes Schindelin
2022-04-26 15:50 ` Taylor Blau
2022-04-26 15:30 ` Johannes Schindelin
2022-04-26 15:36 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=nycvar.QRO.7.76.6.2204261742120.355@tvgsbejvaqbjf.bet \
--to=johannes.schindelin@gmx.de \
--cc=carenas@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=guy.j@maurel.de \
--cc=philipoakley@iee.email \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).