git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] repack.c: chmod +w before rename()

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 24, 2014, 22:24 UTC
Message-ID
<alpine.DEB.1.00.1401242318060.14982@s15462909.onlinehome-server.info>
In-Reply-To
<20140124214023.GB58260@vauxhall.crustytoothpaste.net>
Hi Brian,
On Fri, 24 Jan 2014, brian m. carlson wrote:
Show 15 quoted lines
> On Fri, Jan 24, 2014 at 10:05:14PM +0100, Torsten Bögershausen wrote:
> > diff --git a/builtin/repack.c b/builtin/repack.c
> > index ba66c6e..033b4c2 100644
> > --- a/builtin/repack.c
> > +++ b/builtin/repack.c
> > @@ -324,6 +324,10 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
> >  				statbuffer.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
> >  				chmod(fname_old, statbuffer.st_mode);
> >  			}
> > +			if (!stat(fname, &statbuffer)) {
> > +				statbuffer.st_mode |= (S_IWUSR | S_IWGRP | S_IWOTH);
> > +				chmod(fname, statbuffer.st_mode);
> > +			}
> 
> Are we sure that the file in question can never be a symlink?
On Windows: yes. Otherwise, no.

Having said that, the files in question are files generated by Git, so you really would have to tamper with things in order to get into trouble.

> Because if it is, we'll end up changing the permissions on the wrong
> file.

In any case, I'd rather change the permissions only when the rename failed. *And* I feel uncomfortable ignoring the return value...

> In general, I'm wary of changing permissions on a file to suit Windows's
> rename because of the symlink issue and the security issues that can
> result.
I agree on the Windows issue.
> Hard links probably have the same issue.

No, hard links have their own permissions. If you change the permissions on a hardlink, any other hardlinks to the same content are unaffected.

Ciao, Johannes

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Previous: brian m. carlsonNext: brian m. carlson
Message 3 of 7 in “repack.c: chmod +w before rename()”
  1. repack.c: chmod +w before rename()Torsten Bögershausen, Jan 24, 2014
  2. brian m. carlsonJan 24, 2014
  3. Johannes SchindelinJan 24, 2014
  4. brian m. carlsonJan 24, 2014
  5. Mike HommeyJan 24, 2014
  6. Junio C HamanoJan 24, 2014
  7. Junio C HamanoJan 24, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.