All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: Junio C Hamano <gitster@pobox.com>, Eric Wong <normalperson@yhbt.net>
Cc: "Johannes Sixt" <j6t@kdbg.org>,
	"Jens Lehmann" <Jens.Lehmann@web.de>,
	"Torsten Bögershausen" <tboegi@web.de>,
	"Git Mailing List" <git@vger.kernel.org>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Michael Haggerty" <mhagger@alum.mit.edu>
Subject: No fchmd. was: Re: [PATCH 00/14] Add submodule test harness
Date: Thu, 10 Jul 2014 08:22:31 +0200	[thread overview]
Message-ID: <53BE3127.8020805@web.de> (raw)
In-Reply-To: <xmqqion69ovj.fsf@gitster.dls.corp.google.com>

On 07/09/2014 11:57 PM, Junio C Hamano wrote:
> Eric Wong <normalperson@yhbt.net> writes:
>
>> Junio C Hamano <gitster@pobox.com> wrote:
>>> Johannes Sixt <j6t@kdbg.org> writes:
>>>> Am 08.07.2014 21:34, schrieb Jens Lehmann:
>>>>>> And Msysgit complains
>>>>>> error: fchmod on c:/xxxt/trash directory.t7613-merge-submodule/submodule_update_repo/.git/modules/sub1/config.lock failed: Function not implemented
>>>>> I'm not sure what this is about, seems to happen during the "cp -R" of
>>>>> the repo under .git/modules into the submodule.
>>>> No. It happens because fchmod() is not implemented in our Windows port.
>>>>
>>>> Please see my band-aid patch at
>>>> http://thread.gmane.org/gmane.comp.version-control.git/248154/focus=20266
>>>> The sub-thread ended inconclusive.
>>> We need to start somewhere, and a no-op fchmod() in your patch may
>>> be as a good place to start as anything.  At least we would then
>>> keep the old behaviour without introducing any new failure.
>> Right, this likely makes the most sense for single-user systems or
>> systesm without a *nix-like permission system.
>>
>>> An alternative might be to use chmod() after we are done writing to
>>> the config.lock in order to avoid the use of fchmod() altogether,
>>> which I think can replace the existing two callsites of fchmod().
>>> That approach might be a more expedient, but may turn out to be
>>> undesirable in the longer term.
>> In that case, we would need to open with mode=0600 to avoid a window
>> where the file may be world-readable with any data in it.
> Yes, of course.
>
> To elaborate what I was alluding to at the end of the message you
> are responding to a bit more, if we were to move this "grab perms
> from existing file (if there is any) and propagate to the new one"
> into the lockfile API,
>
>   - in hold_lock_file_for_update(), we would record the permission of
>     the original file, if any, to a new field in "struct lock_file";
>   - open with 0600 or tighter in lock_file(), and
>
>   - either before closing the file use fchmod() or after closing and
>     moving the file use chmod() to propagate the permission.
>
> If the original did not exist, we would pass 0666 to open as before
> in lock_file() and do not bother chmod/fchmod at the end.
>
> Or something like that, perhaps.

Isn't the whole problem starting here:
in config.c:

     fd = hold_lock_file_for_update(lock, config_filename, 0);
In lockfile.c:
   /* This should return a meaningful errno on failure */
   int hold_lock_file_for_update(struct lock_file *lk, const char *path, 
int flags)
   {
       int fd = lock_file(lk, path, flags);
which leads to
   static int lock_file(struct lock_file *lk, const char *path, int flags)
     []
     lk->fd = open(lk->filename.buf, O_RDWR | O_CREAT | O_EXCL, 0666);

There is no way to tell which permissions the new lockfile should have.
That is somewhat unlucky.

On the other hand, shouldn't we call
adjust_shared_perm(const char *path) from path.c on the config file?

And to all files which are fiddled through the lock_file API?
In other words, the lockfile could be created with the restrictive 
permissions
600, and once the lockfile had been closed and renamed into the final name
we apply adjust_shared_perm() on it ?

Or probably directly after close() ?

I think there are 2 different things missing here:

- Be able to specify permissions to hold_lock_file_for_update(),
    especially restrictive ones, like 600 and not 666.

- Adjust the permissions for "shared files" in a shared repo.
   This is probably needed for a shared repo, when the user itself
    has a umask which is too restrictive and adjust_shared_perm()
    must be run to widen the permissions.

Do I miss something ?

  reply	other threads:[~2014-07-10  6:23 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-15 16:56 [PATCH 00/14] Add submodule test harness Jens Lehmann
2014-06-15 16:57 ` [PATCH 01/14] test-lib: add test_dir_is_empty() Jens Lehmann
2014-06-16 22:05   ` Junio C Hamano
2014-06-17 16:47     ` Jens Lehmann
2014-06-19 20:12   ` [PATCH v2 " Jens Lehmann
2014-06-15 16:58 ` [PATCH 02/14] submodules: Add the lib-submodule-update.sh test library Jens Lehmann
2014-06-16 22:49   ` Junio C Hamano
2014-06-17 17:33     ` Jens Lehmann
2014-06-17 18:44       ` Junio C Hamano
2014-06-17 20:46         ` Jens Lehmann
2014-06-17 21:05           ` Junio C Hamano
2014-06-19 20:12   ` [PATCH v2 " Jens Lehmann
2014-06-20 17:31     ` Junio C Hamano
2014-07-01 21:24       ` [PATCH v3 " Jens Lehmann
2014-06-15 16:58 ` [PATCH 03/14] checkout: call the new submodule update test framework Jens Lehmann
2014-06-15 16:59 ` [PATCH 04/14] apply: add t4137 for submodule updates Jens Lehmann
2014-06-15 16:59 ` [PATCH 05/14] read-tree: add t1013 " Jens Lehmann
2014-06-15 17:00 ` [PATCH 06/14] reset: add t7112 " Jens Lehmann
2014-06-15 17:01 ` [PATCH 07/14] bisect: add t6041 " Jens Lehmann
2014-06-19 20:12   ` [PATCH v2 " Jens Lehmann
2014-06-15 17:01 ` [PATCH 08/14] merge: add t7613 " Jens Lehmann
2014-06-15 17:02 ` [PATCH 09/14] rebase: add t3426 " Jens Lehmann
2014-06-16  9:57   ` Eric Sunshine
2014-06-17 17:41     ` Jens Lehmann
2014-06-19 20:12   ` [PATCH v2 " Jens Lehmann
2014-06-15 17:02 ` [PATCH 10/14] pull: add t5572 " Jens Lehmann
2014-06-15 17:03 ` [PATCH 11/14] cherry-pick: add t3512 " Jens Lehmann
2014-06-15 17:03 ` [PATCH 12/14] am: add t4255 " Jens Lehmann
2014-06-15 17:04 ` [PATCH 13/14] stash: add t3906 " Jens Lehmann
2014-06-19 20:12   ` [PATCH v2 " Jens Lehmann
2014-06-15 17:04 ` [PATCH 14/14] revert: add t3513 " Jens Lehmann
2014-06-19 20:12   ` [PATCH v2 " Jens Lehmann
2014-07-02 14:54 ` [PATCH 00/14] Add submodule test harness Torsten Bögershausen
2014-07-02 19:57   ` Jens Lehmann
2014-07-03  5:56     ` Torsten Bögershausen
2014-07-03 21:14       ` Jens Lehmann
2014-07-07 17:05         ` Junio C Hamano
2014-07-07 19:40           ` Torsten Bögershausen
2014-07-08 19:34             ` Jens Lehmann
2014-07-08 20:25               ` Ramsay Jones
2014-07-08 21:03                 ` Ramsay Jones
2014-07-09  6:39                 ` No fchmod() under msygit - Was: " Torsten Bögershausen
2014-07-09 20:00                   ` Eric Wong
2014-07-14 11:31                     ` Erik Faye-Lund
2014-07-14 13:55                       ` Nico Williams
2014-07-14 14:02                         ` Nico Williams
2014-07-14 19:30                     ` Karsten Blees
2014-07-14 21:18                       ` Junio C Hamano
2014-07-09  6:14               ` Torsten Bögershausen
2014-07-09 15:20                 ` Junio C Hamano
2014-07-09 18:19                 ` Jens Lehmann
2014-07-09 19:31                   ` Junio C Hamano
2014-07-10 20:52                     ` Junio C Hamano
2014-07-12 18:23                       ` Jens Lehmann
2014-07-14  1:01                         ` Junio C Hamano
2014-07-14 18:22                           ` Jens Lehmann
2014-07-14 21:18                             ` Junio C Hamano
2014-07-09 17:21               ` Johannes Sixt
2014-07-09 19:22                 ` Junio C Hamano
2014-07-09 19:56                   ` Eric Wong
2014-07-09 21:57                     ` Junio C Hamano
2014-07-10  6:22                       ` Torsten Bögershausen [this message]
2014-07-10 19:49                         ` No fchmd. was: " Junio C Hamano
2014-07-10 20:55                           ` Torsten Bögershausen
2014-07-10 21:43                             ` 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=53BE3127.8020805@web.de \
    --to=tboegi@web.de \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=mhagger@alum.mit.edu \
    --cc=normalperson@yhbt.net \
    --cc=pclouds@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.