From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 0EB9E1F5AE for ; Thu, 16 Jul 2020 14:26:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbgGPOZx (ORCPT ); Thu, 16 Jul 2020 10:25:53 -0400 Received: from mail.ltpcgo.com ([54.93.149.123]:51416 "EHLO mail.ltpcgo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728622AbgGPOZw (ORCPT ); Thu, 16 Jul 2020 10:25:52 -0400 X-Greylist: delayed 569 seconds by postgrey-1.27 at vger.kernel.org; Thu, 16 Jul 2020 10:25:51 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ltpcgo.com; h= organization:message-id:subject:subject:from:from:date:date :content-transfer-encoding:content-type:content-type :mime-version; s=mail; t=1594909545; bh=AX16XLqMxyB81vX80S3jx/Q5 enm3lT0VSiXXS/LMaCs=; b=pE2XBf+pjxKBIE9s/K6GkzVkQe5IiSgY1b8FxKZY 7jRUayH9SxhAzCw6cE6FjuSpnsmSSuc3+vixthLeTKFbKlkg8ZqiiK8OcaSbUywU i8L6QW+I6a8crLVtMlBCxNd2+W5XqPUXZCEu7IoccIP1lS+whc525atqICkrqZS6 aRpq8ldyHtDSdD/BNrC4hKWp7Uwskv9/E0dBV76x/FJT+aUpN16NS7XwdG8ZmtS2 J+ZYzmY7AI+HJiJ4Iu8SmwU7Rd9CUNOLfsTBmo0IMK+SPejm16wgdJYAVg4NH+Pc z69mxl6QO1vltyIrW0GvOasdT0zOFUn85+eiRV9YQ37B3Q== MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Date: Thu, 16 Jul 2020 16:25:45 +0200 From: LTPCGO | George To: git@vger.kernel.org Subject: Issue with insufficient permission for adding an object to repository database .git/objects Message-ID: Organization: LTPCGO Content-Transfer-Encoding: quoted-printable Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org See discussion here=20 https://groups.google.com/forum/?fromgroups#!topic/git-users/35HBb76oA6c=20 and https://github.com/trapexit/mergerfs/issues/626 On certain file systems, there are issues with staging a commit because=20 a call to open a file stored under .git/objects fails. It has been=20 brought up in this discussion group previously. I have attached a fix below, but it would be much better to fix in the=20 code. I am curious first, before proposing a fix in the code (although=20 I can't find the specific call in the source at=20 https://github.com/git/git ), what the reasoning is for the current=20 permissions check on the call rather than checking the contents of the=20 opened tmp file. cc -Wall -O3 -D_GNU_SOURCE -fPIC -c -o githack.o githack.c; gcc -o=20 githack.so -nostartfiles -shared githack.o -ldl; LD_PRELOAD=3D./githack.so git commit -a -m "Some new commit" The code is below: #include #include #include #include #include //#define openat ignorethisopen #define open ignorethisopen #define open64 ignorethisopen64 #include //#undef openat #undef open #undef open64 #include /* 'strace git ...' will show git fail on an openat() command this is probably implemented as open64() on your system you can confirm this by use of 'ltrace git ...' you may also need to adjust the oflag comparison of 194 */ /*static int (*___openat)(int, char *, int, mode_t);*/ static int (*___open)(const char *, int, mode_t); static int (*___open64)(const char *, int, mode_t); static void* dlwrap(const char *fn) { const char *e; void *p =3D dlsym(RTLD_NEXT, fn); if ((e=3Ddlerror())!=3D0) fprintf(stderr, "dlsym(RTLD_NEXT,'%s')= :=20 %s\r\n", fn, e); return p; } void _init(void) { ___open =3D dlwrap("open"); ___open64 =3D dlwrap("open64"); } /*int openat(int dirfd, const char *pathname, int oflag, mode_t mode)*/ int open(const char *pathname, int oflag, mode_t mode) { if (oflag && oflag =3D=3D 194) return ___open(pathname, oflag, S_IRWXU); return ___open(pathname, oflag, mode); } int open64(const char *pathname, int oflag, mode_t mode) { if (oflag && oflag =3D=3D 194) return ___open64(pathname, oflag, S_IRWXU); return ___open64(pathname, oflag, mode); } =F0=9F=96=B3 LTPCGO =F0=9F=96=B3 Next-level security Dr. George O=E2=80=99Neill +44 7717 318 220 george@ltpcgo.com https://www.ltpcgo.com/