[PATCH] Makefile: use fileno macro work around on AIX

2019-04-18 Thread CHIGOT, CLEMENT
Declare FILENO_IS_A_MACRO on AIX

On AIX, fileno(fp) is a macro and need to use the work around already made for 
BSD's. 

Signed-off-by: Clément Chigot 
---
 config.mak.uname | 1 +
 1 file changed, 1 insertion(+)

diff --git a/config.mak.uname b/config.mak.uname
index 41e85fab1c..86cbe47627 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -269,6 +269,7 @@ ifeq ($(uname_S),AIX)
INTERNAL_QSORT = UnfortunatelyYes
NEEDS_LIBICONV = YesPlease
BASIC_CFLAGS += -D_LARGE_FILES
+   FILENO_IS_A_MACRO = UnfortunatelyYes
ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
NO_PTHREADS = YesPlease
else
-- 
2.17.1


[PATCH] git-compat-util: work around for access(X_OK) under root

2019-04-23 Thread CHIGOT, CLEMENT
On some OSes like AIX, access with X_OK is always true if launched under
root.
Add NEED_ACCESS_ROOT_HANDLER in order to use an access helper function.
It checks with stat if any executable flags is set when the current user
is root.

Signed-off-by: Clément Chigot 
---
 Makefile  |  8 
 compat/access.c   | 29 +
 config.mak.uname  |  1 +
 git-compat-util.h |  8 
 4 files changed, 46 insertions(+)
 create mode 100644 compat/access.c

diff --git a/Makefile b/Makefile
index 9f1b6e8926..513d835d01 100644
--- a/Makefile
+++ b/Makefile
@@ -439,6 +439,9 @@ all::
 #
 # Define FILENO_IS_A_MACRO if fileno() is a macro, not a real function.
 #
+# Define NEED_ACCESS_ROOT_HANDLER if access() with X_OK returns always true
+# when launched as root.
+#
 # Define PAGER_ENV to a SP separated VAR=VAL pairs to define
 # default environment variables to be passed when a pager is spawned, e.g.
 #
@@ -1833,6 +1836,11 @@ ifdef FILENO_IS_A_MACRO
COMPAT_OBJS += compat/fileno.o
 endif
 
+ifdef NEED_ACCESS_ROOT_HANDLER
+   COMPAT_CFLAGS += -DNEED_ACCESS_ROOT_HANDLER
+   COMPAT_OBJS += compat/access.o
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK = NoThanks
 endif
diff --git a/compat/access.c b/compat/access.c
new file mode 100644
index 00..e4202d4585
--- /dev/null
+++ b/compat/access.c
@@ -0,0 +1,29 @@
+#include "../git-compat-util.h"
+
+/* Do the same thing access(2) does, but use the effective uid and gid,
+   and don't make the mistake of telling root that any file is
+   executable.  This version uses stat(2). */
+int git_access (const char *path, int mode)
+{
+   struct stat st;
+   uid_t euid = geteuid();
+   uid_t uid = getuid();
+
+   if (stat(path, &st) < 0)
+   return -1;
+
+   if (!(uid) || !(euid)) {
+   /* Root can read or write any file. */
+   if (!(mode & X_OK))
+   return 0;
+
+   /* Root can execute any file that has any one of the execute
+  bits set. */
+   if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
+   return 0;
+   errno = EACCES;
+   return -1;
+   }
+
+   return access(path, X_OK);
+}
diff --git a/config.mak.uname b/config.mak.uname
index 86cbe47627..ce13ab8295 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -270,6 +270,7 @@ ifeq ($(uname_S),AIX)
NEEDS_LIBICONV = YesPlease
BASIC_CFLAGS += -D_LARGE_FILES
FILENO_IS_A_MACRO = UnfortunatelyYes
+   NEED_ACCESS_ROOT_HANDLER = UnfortunatelyYes
ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
NO_PTHREADS = YesPlease
else
diff --git a/git-compat-util.h b/git-compat-util.h
index 31b47932bd..bb8df9d2e5 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1242,6 +1242,14 @@ int git_fileno(FILE *stream);
 # endif
 #endif
 
+#ifdef NEED_ACCESS_ROOT_HANDLER
+#ifdef access
+#undef access
+#endif
+#define access git_access
+extern int git_access(const char *path, int mode);
+#endif
+
 /*
  * Our code often opens a path to an optional file, to work on its
  * contents when we can successfully open it.  We can ignore a failure
-- 
2.17.1



Clément Chigot
ATOS Bull SAS
1 rue de Provence - 38432 Échirolles - France


Re: [PATCH] git-compat-util: work around for access(X_OK) under root

2019-04-23 Thread CHIGOT, CLEMENT
From: Junio C Hamano  on behalf of Junio C Hamano 

> > On some OSes like AIX, access with X_OK is always true if launched under
> > root.
> 
> That may be the case, but you'd need to describe why it is a problem
> here, before talking about the need for a "work around".
> 
> For example, if a directory on $PATH has a file called git-frotz
> that has no executable bit, perhaps "git frotz" would execute that
> file but only when you are running it as the root user, but not as
> any other user.
> 
> But that by itself does not sound like a problem to me.  After all,
> a user with such a set-up on AIX may deliberately wanted to make
> sure that a program like "git-frotz" that is only useful for
> administrative purposes does not get in the way when using "git"
> normally, but becomes available only when the user does "su".  IOW,
> that sounds more like a feature an AIX user might want to take
> advantage of.
> 
> Perhaps the reason why you do not want to use access(X_OK) that
> returns true for root may be different from the above, but without
> knowing what it is, it is far from clear to me why this patch is a
> good idea.  The patch needs to be justified a lot better.
> 
> Everything below may become a moot point, as it is unclear if the
> (untold) motivation behind this change makes sense in the first
> place, but assuming that it is a good change that merely is poorly
> explained, let's read on.
> 

This patch is needed in order to have hooks working on AIX. When run as root,
access on hooks will return true even if a hook can't be executed. Therefore,
as far as I know, git will try to execute it as is and we'll get this kind of
error:
"git commit -m content
 fatal: cannot exec '.git/hooks/pre-commit': Permission denied"

I'm not fully aware about how git is using access and if it's adding some chmod,
if it returns false. 

We already know that there is some problems with access() as it has already
occurs during our port of bash. Note that a part of this code comes from it.

We find this work around and thought it could be interesting to add it in the
source code as some others OS (like Solaris according to bash) has the same kind
of problems.
However, you're right it's far from perfect and I might have
submitted to soon, sorry about that.. 

> > diff --git a/compat/access.c b/compat/access.c
> > new file mode 100644
> > index 00..e4202d4585
> > --- /dev/null
> > +++ b/compat/access.c
> > @@ -0,0 +1,29 @@
> > +#include "../git-compat-util.h"
> 
> This will get interesting.
> 
> > +/* Do the same thing access(2) does, but use the effective uid and gid,
> > +   and don't make the mistake of telling root that any file is
> > +   executable.  This version uses stat(2). */
> 
> /*
>  * Our multi-line comment looks more like
>  * this.  A slash-asterisk without anything else
>  * on its own line begins it, and it is concluded
>  * with  an asterisk-slash on its own line.
>  * Each line in between begins with an asterisk,
>  * and the asterisks align on a monospace terminal.
>  */
> 
> > +int git_access (const char *path, int mode)
> 
> No SP after function name before the parens that begins the
> parameter list.
> 
> > +{
> > + struct stat st;
> > + uid_t euid = geteuid();
> > + uid_t uid = getuid();
> > +
> > + if (stat(path, &st) < 0)
> > + return -1;
> 
> This stat is a wasted syscall if the running user is not root.
> Structure the function more like
> 
> 
> int git_access(const char *path, int mode)
> {
> struct stat st;
> 
> /* do not interfere a normal user */
> if (geteuid())
> return access(path, mode);
> 
> if (stat(path, &st) < 0)
> return -1; /* errno apprpriately set by stat() */
> ... other stuff needed for the root user ...
> }
> 
> Does the true UID matter for the purpose of permission/privilege
> checking?  Why do we have to check anything other than the effective
> UID?
>

Actually, I don't know. Bash is doing it but I think EUID is enough. 

> > + if (!(uid) || !(euid)) {
> > + /* Root can read or write any file. */
> > + if (!(mode & X_OK))
> > + return 0;
> > +
> > + /* Root can execute any file that has any one of the execute
> > +bits set. */
> > + if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
> > + return 0;
> > + errno = EACCES;
> > + return -1;
> > + }
> > +
> > + return access(path, X_OK);
> 
> I think the last "fallback to the system access()" is wrong, as the
> "special case for root" block seems to except that the function may
> be called to check for Read or Write permission, not just for X_OK.

That's a mistake from me. It should be "mode" instead of "X_OK". It seems that 
most of the time, it

Re: [PATCH] git-compat-util: work around for access(X_OK) under root

2019-04-24 Thread CHIGOT, CLEMENT
From: Junio C Hamano  on behalf of Junio C Hamano 

> "CHIGOT, CLEMENT"  writes:
> > From: Junio C Hamano  on behalf of Junio C Hamano 
> > 
> >> > On some OSes like AIX, access with X_OK is always true if launched under
> >> > root.
> >>
> >> That may be the case, but you'd need to describe why it is a problem
> >> here, before talking about the need for a "work around".
> >>
> >> For example, if a directory on $PATH has a file called git-frotz
> >> that has no executable bit, perhaps "git frotz" would execute that
> >> file but only when you are running it as the root user, but not as
> >> any other user.
> >> ...
> >
> > This patch is needed in order to have hooks working on AIX. When run as 
> > root,
> > access on hooks will return true even if a hook can't be executed.
> 
> Ah, OK, so the issue is not that AIX allows the root to execute even
> files that have no executable bit, but X_OK check on it returns
> useless answer when we want to know if an attempted execution of the
> file by the user would succeed.
> 
> That was exactly the kind of information expected in your log
> message to explain why this change is a good thing to have.

Ok I'll add something clearer. 

> 
> >> Does the true UID matter for the purpose of permission/privilege
> >> checking?  Why do we have to check anything other than the effective
> >> UID?
> >>
> >
> > Actually, I don't know. Bash is doing it but I think EUID is enough.
> 
> I wasn't questioning if it is "enough".  If the root user "su"es to
> a normal user, does the issue that exec(path) and access(path, X_OK)
> are incoherent still happen?  If not, checking for !uid is actively
> wrong, not just unnecessary.

Yes, it doesn't happen. So, only EUID should be check as you said. 

> 
> >> > + return access(path, X_OK);
> >>
> >> I think the last "fallback to the system access()" is wrong, as the
> >> "special case for root" block seems to except that the function may
> >> be called to check for Read or Write permission, not just for X_OK.
> >
> > That's a mistake from me. It should be "mode" instead of "X_OK". It seems 
> > that
> > most of the time, it's used only with X_OK or F_OK that's why it has 
> > worked. I'll
> > fix that.
> 
> Yup, and have the function fall-back to the system supplied access()
> after doing geteuid() and finding that the user is not the root user
> without doing anything else---and use the remaining lines in the
> function for the special case.  That would make the function's logic
> easier to read, too.
> 
> >> See how FILENO_IS_A_MACRO defined immediately before this part uses
> >> the "#ifndef COMPAT_CODE" to guard against exactly the same problem.
> >
> > Alright, I now understand how this work.
> 
> Good.
> 
> > By the way, do I need to recreate a thread with [PATCH v2] ? Or I'll add 
> > the new
> > version in this one ? I don't know how you're proceeding. 
> 
> As the patch we are discussing in this exchange has not been
> accepted nor merged to the 'next' branch yet, you'd be sending a new
> version as a whole (i.e. not as an incremental patch on top of the
> version we have reviewed here) with "[PATCH v2]" on its subject
> header.
> 
> Emily Shaffer has been writing and revising a tutorial on the
> procedure recently, which may be of interest to you, and I am
> interested in using your fresh eyes to see if its expectation
> for the readers is set appropriately.
> 
>   
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpublic-inbox.org%2Fgit%2F20190423193410.101803-1-emilyshaffer%40google.com%2F&data=02%7C01%7Cclement.chigot%40atos.net%7C4646e90041f04b4fa46c08d6c84ea22b%7C33440fc6b7c7412cbb730e70b0198d5a%7C0%7C1%7C636916637385863489&sdata=nO1e1MV99iHsCyhDLTgBNIRCj0AZ%2BpwqtGrQY%2FJAB3g%3D&reserved=0

Indeed, that's a really good tutorial. As I didn't made a new feature, I can't
judge the part referring to this. But, how to submit with both way seems pretty
clear to me. Maybe a sum up can be added because it's quite long and verbose. I
think a part with just the commands to run in order can be useful. Something
like this: https://golang.org/doc/contribute.html#tmp_12. 

> 
> Thanks.






[PATCH v2] git-compat-util: work around for access(X_OK) under root

2019-04-24 Thread CHIGOT, CLEMENT
On AIX, access(X_OK) may success when run under root even if the
execution isn't possible. This comes from the POSIX specifications
which say:
"... for a process with appropriate privileges, an implementation
 may indicate success for X_OK even if execute permission is not
 granted to any user."

This behavior can lead hook programs to have their execution refused:
 "git commit -m content
  fatal: cannot exec '.git/hooks/pre-commit': Permission denied"

Add NEED_ACCESS_ROOT_HANDLER in order to use an access helper function.
It checks with stat if any executable flags is set when the current user
is root.

Signed-off-by: Clément Chigot 
Message-ID: 

---
 Makefile  |  8 
 compat/access.c   | 30 ++
 config.mak.uname  |  1 +
 git-compat-util.h |  7 +++
 4 files changed, 46 insertions(+)
 create mode 100644 compat/access.c

diff --git a/Makefile b/Makefile
index 9f1b6e8926..6ac7218106 100644
--- a/Makefile
+++ b/Makefile
@@ -439,6 +439,9 @@ all::
 #
 # Define FILENO_IS_A_MACRO if fileno() is a macro, not a real function.
 #
+# Define NEED_ACCESS_ROOT_HANDLER if access() under root may success for X_OK
+# even if execution permission isn't granted for any user.
+#
 # Define PAGER_ENV to a SP separated VAR=VAL pairs to define
 # default environment variables to be passed when a pager is spawned, e.g.
 #
@@ -1833,6 +1836,11 @@ ifdef FILENO_IS_A_MACRO
COMPAT_OBJS += compat/fileno.o
 endif
 
+ifdef NEED_ACCESS_ROOT_HANDLER
+   COMPAT_CFLAGS += -DNEED_ACCESS_ROOT_HANDLER
+   COMPAT_OBJS += compat/access.o
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK = NoThanks
 endif
diff --git a/compat/access.c b/compat/access.c
new file mode 100644
index 00..fcfaefb0c0
--- /dev/null
+++ b/compat/access.c
@@ -0,0 +1,30 @@
+#define COMPAT_CODE_ACCESS
+#include "../git-compat-util.h"
+
+/* Do the same thing access(2) does, but use the effective uid,
+ * and don't make the mistake of telling root that any file is
+ * executable.  This version uses stat(2).
+ */
+int git_access(const char *path, int mode)
+{
+   struct stat st;
+
+   /* do not interfere a normal user */
+   if (geteuid())
+   return access(path, mode);
+
+   if (stat(path, &st) < 0)
+   return -1;
+
+   /* Root can read or write any file. */
+   if (!(mode & X_OK))
+   return 0;
+
+   /* Root can execute any file that has any one of the execute
+  bits set. */
+   if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
+   return 0;
+
+   errno = EACCES;
+   return -1;
+}
diff --git a/config.mak.uname b/config.mak.uname
index 86cbe47627..ce13ab8295 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -270,6 +270,7 @@ ifeq ($(uname_S),AIX)
NEEDS_LIBICONV = YesPlease
BASIC_CFLAGS += -D_LARGE_FILES
FILENO_IS_A_MACRO = UnfortunatelyYes
+   NEED_ACCESS_ROOT_HANDLER = UnfortunatelyYes
ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
NO_PTHREADS = YesPlease
else
diff --git a/git-compat-util.h b/git-compat-util.h
index 31b47932bd..d0cb380522 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1242,6 +1242,13 @@ int git_fileno(FILE *stream);
 # endif
 #endif
 
+#ifdef NEED_ACCESS_ROOT_HANDLER
+int git_access(const char *path, int mode);
+# ifndef COMPAT_CODE_ACCESS
+#  define access(path, mode) git_access(path, mode)
+# endif
+#endif
+
 /*
  * Our code often opens a path to an optional file, to work on its
  * contents when we can successfully open it.  We can ignore a failure
-- 
2.17.1


Clément Chigot
ATOS Bull SAS
1 rue de Provence - 38432 Échirolles - France


Re: [PATCH v2] git-compat-util: work around for access(X_OK) under root

2019-04-24 Thread CHIGOT, CLEMENT
> From: Junio C Hamano 
> "CHIGOT, CLEMENT"  writes:
> 
> > On AIX, access(X_OK) may success when run under root even if the
> 
> s/success/succeed/;
> 
> Also perhaps s/under/as/.
> 
> > execution isn't possible. This comes from the POSIX specifications
> 
> s/comes from/behaviour is allowed by/;  I agree with you that AIX
> behaviour is suboptimal and I do not think we want to give an
> impression that POSIX encourages such an illogical behaviour.  It
> merely is permitted.

Yes, that's better

> 
> >  "git commit -m content
> >   fatal: cannot exec '.git/hooks/pre-commit': Permission denied"
> 
> I am not sure what the double-quotes around these two lines are
> about.  Perhaps drop them, and if you want to clarify which part is
> your word and which part is quoted material, have blank lines to
> delineate instead, perhap like:
> 
>     ... POSIX says:
> 
>     ... for a process with appropriate ...
>     ... to any user.
> 
>     This behaviour can fail the execution of hooks, like so:
> 
>     $ git commit
>     fatal: cannot exec '.git/hooks/pre-commit': Permission denied
> 
>     Add NEED_ACCESS_ROOT_HANDLER in order to...

I'm used to do that. But if you think that's clearer, I'll do it. 

> 
> > is root.
> >
> > Signed-off-by: Clément Chigot 
> > Message-ID: 
> > 
> 
> Drop "Message-Id:" from the footer.
> 
> > ---
> > ...
> > diff --git a/compat/access.c b/compat/access.c
> > new file mode 100644
> > index 00..fcfaefb0c0
> > --- /dev/null
> > +++ b/compat/access.c
> > @@ -0,0 +1,30 @@
> > +#define COMPAT_CODE_ACCESS
> 
> I am torn between just using COMPAT_CODE like the other one does, or
> introducing the new symbol like this.  If we were to do the latter,
> perhaps we should give the original one a more specific name as well
> (e.g. COMPAT_CODE_FILENO or something like that).
>

I think using the same define is possible for now. But it might become confusing
if others are needed. Moreover, I'm not sure it will work if, for example,
fileno is needed inside git_access. That's very unlikely to happen, but
it seems better to have one COMPAT_CODE_X defined for each special handler. 
I'll let you decide., anyway. 

> > + if (stat(path, &st) < 0)
> > + return -1;
> > +
> > + /* Root can read or write any file. */
> > + if (!(mode & X_OK))
> > + return 0;
> > +
> > + /* Root can execute any file that has any one of the execute
> > +    bits set. */
> 
>     /*
>  * Our multi-line comment looks like this,
>  * with opening slash-asterisk and closing
>  * asterisk-slash on their own lines.
>  */

.. I've forgotten this one, sorry. 

> > diff --git a/git-compat-util.h b/git-compat-util.h
> > index 31b47932bd..d0cb380522 100644
> > --- a/git-compat-util.h
> > +++ b/git-compat-util.h
> > @@ -1242,6 +1242,13 @@ int git_fileno(FILE *stream);
> >  # endif
> >  #endif


> > 
> > +#ifdef NEED_ACCESS_ROOT_HANDLER
> > +int git_access(const char *path, int mode);
> > +# ifndef COMPAT_CODE_ACCESS
> 
> Notice that the fileno thing we are trying to mimick protects us
> from a system header that defines the macro we are about to define,
> which is a good practice to prevent compilers from complaining
> against redefinition.  We should imitate it like this here:
> 
>    #  ifdef access
>    #  undef access
>    #  endif
> 
> > +#  define access(path, mode) git_access(path, mode)
> > +# endif
> > +#endif
> > +

Ok. 

> 
> Other than that, looks good to me.
  


[PATCH v3] git-compat-util: work around for access(X_OK) under root

2019-04-25 Thread CHIGOT, CLEMENT
On AIX, access(X_OK) may succeed when run as root even if the
execution isn't possible. This behavior is allowed by POSIX
which says:

  ... for a process with appropriate privileges, an implementation
  may indicate success for X_OK even if execute permission is not
  granted to any user.

It can lead hook programs to have their execution refused:

   git commit -m content
   fatal: cannot exec '.git/hooks/pre-commit': Permission denied

Add NEED_ACCESS_ROOT_HANDLER in order to use an access helper function.
It checks with stat if any executable flags is set when the current user
is root.

Signed-off-by: Clément Chigot 
Message-ID: 

---
 Makefile  |  8 
 compat/access.c   | 31 +++
 compat/fileno.c   |  2 +-
 config.mak.uname  |  1 +
 git-compat-util.h | 12 +++-
 5 files changed, 52 insertions(+), 2 deletions(-)
 create mode 100644 compat/access.c

diff --git a/Makefile b/Makefile
index 9f1b6e8926..6ac7218106 100644
--- a/Makefile
+++ b/Makefile
@@ -439,6 +439,9 @@ all::
 #
 # Define FILENO_IS_A_MACRO if fileno() is a macro, not a real function.
 #
+# Define NEED_ACCESS_ROOT_HANDLER if access() under root may success for X_OK
+# even if execution permission isn't granted for any user.
+#
 # Define PAGER_ENV to a SP separated VAR=VAL pairs to define
 # default environment variables to be passed when a pager is spawned, e.g.
 #
@@ -1833,6 +1836,11 @@ ifdef FILENO_IS_A_MACRO
COMPAT_OBJS += compat/fileno.o
 endif
 
+ifdef NEED_ACCESS_ROOT_HANDLER
+   COMPAT_CFLAGS += -DNEED_ACCESS_ROOT_HANDLER
+   COMPAT_OBJS += compat/access.o
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK = NoThanks
 endif
diff --git a/compat/access.c b/compat/access.c
new file mode 100644
index 00..19fda3e877
--- /dev/null
+++ b/compat/access.c
@@ -0,0 +1,31 @@
+#define COMPAT_CODE_ACCESS
+#include "../git-compat-util.h"
+
+/* Do the same thing access(2) does, but use the effective uid,
+ * and don't make the mistake of telling root that any file is
+ * executable.  This version uses stat(2).
+ */
+int git_access(const char *path, int mode)
+{
+   struct stat st;
+
+   /* do not interfere a normal user */
+   if (geteuid())
+   return access(path, mode);
+
+   if (stat(path, &st) < 0)
+   return -1;
+
+   /* Root can read or write any file. */
+   if (!(mode & X_OK))
+   return 0;
+
+   /* Root can execute any file that has any one of the execute
+* bits set.
+*/
+   if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
+   return 0;
+
+   errno = EACCES;
+   return -1;
+}
diff --git a/compat/fileno.c b/compat/fileno.c
index 7b105f4cd7..8e80ef335d 100644
--- a/compat/fileno.c
+++ b/compat/fileno.c
@@ -1,4 +1,4 @@
-#define COMPAT_CODE
+#define COMPAT_CODE_FILENO
 #include "../git-compat-util.h"
 
 int git_fileno(FILE *stream)
diff --git a/config.mak.uname b/config.mak.uname
index 86cbe47627..ce13ab8295 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -270,6 +270,7 @@ ifeq ($(uname_S),AIX)
NEEDS_LIBICONV = YesPlease
BASIC_CFLAGS += -D_LARGE_FILES
FILENO_IS_A_MACRO = UnfortunatelyYes
+   NEED_ACCESS_ROOT_HANDLER = UnfortunatelyYes
ifeq ($(shell expr "$(uname_V)" : '[1234]'),1)
NO_PTHREADS = YesPlease
else
diff --git a/git-compat-util.h b/git-compat-util.h
index 31b47932bd..bdca50e64d 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1236,12 +1236,22 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
 
 #ifdef FILENO_IS_A_MACRO
 int git_fileno(FILE *stream);
-# ifndef COMPAT_CODE
+# ifndef COMPAT_CODE_FILENO
 #  undef fileno
 #  define fileno(p) git_fileno(p)
 # endif
 #endif
 
+#ifdef NEED_ACCESS_ROOT_HANDLER
+int git_access(const char *path, int mode);
+# ifndef COMPAT_CODE_ACCESS
+#  ifdef access
+#  undef access
+#  endif
+#  define access(path, mode) git_access(path, mode)
+# endif
+#endif
+
 /*
  * Our code often opens a path to an optional file, to work on its
  * contents when we can successfully open it.  We can ignore a failure
-- 
2.17.1


Clément Chigot
ATOS Bull SAS
1 rue de Provence - 38432 Échirolles - France


[PATCH] contrib/svn-fe: fix shebang for svnrdump_sim.py

2019-09-17 Thread CHIGOT, CLEMENT
The shebang for a python script should be "/usr/bin/env python" and not
"/usr/bin/python". On some OSes like AIX, python default path is not under
"/usr/bin" ("/opt/freeware/bin" for AIX).

Note the main reason behind this change is that AIX rpm will add a
dependency on "/usr/bin/python" instead of "/usr/bin/env".

Signed-off-by: Clément Chigot 
---
 contrib/svn-fe/svnrdump_sim.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/svn-fe/svnrdump_sim.py b/contrib/svn-fe/svnrdump_sim.py
index 11ac6f6927..50c6a4f89d 100755
--- a/contrib/svn-fe/svnrdump_sim.py
+++ b/contrib/svn-fe/svnrdump_sim.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """
 Simulates svnrdump by replaying an existing dump from a file, taking care
 of the specified revision range.
-- 
2.17.1


Clément Chigot
ATOS Bull SAS
1 rue de Provence - 38432 Échirolles - France