Re: Use of access(X_OK) check in pg_upgrade - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Use of access(X_OK) check in pg_upgrade
Date
Msg-id 201105181613.p4IGDw719425@momjian.us
Whole thread Raw
In response to Use of access(X_OK) check in pg_upgrade  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
Bruce Momjian wrote:
> I broke the Win32 build members by using access(X_OK) in pg_upgrade.  I
> have a fix for this but looking at pg_upgrade's exec.c, I see for
> Win32:
>
>         if ((buf.st_mode & S_IXUSR) == 0)
>
> I am confused why Windows supports S_IXUSR but not X_OK.

I have applied the attached patch to fix this.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +
diff --git a/contrib/pg_upgrade/exec.c b/contrib/pg_upgrade/exec.c
new file mode 100644
index 6f1c6ef..ec2f944
*** a/contrib/pg_upgrade/exec.c
--- b/contrib/pg_upgrade/exec.c
*************** void
*** 94,100 ****
  verify_directories(void)
  {

!     if (access(".", R_OK | W_OK | X_OK) != 0)
          pg_log(PG_FATAL,
          "You must have read and write access in the current directory.\n");

--- 94,109 ----
  verify_directories(void)
  {

!     if (access(".", R_OK | W_OK
! #ifndef WIN32
!     /*
!      *    Directory execute permission on NTFS means "can execute scripts",
!      *    which we don't care about, so skip the check.  Also, X_OK is not
!      *    defined in the API.
!      */
!                     | X_OK
! #endif
!         ) != 0)
          pg_log(PG_FATAL,
          "You must have read and write access in the current directory.\n");


pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Use of access(X_OK) check in pg_upgrade
Next
From: "David E. Wheeler"
Date:
Subject: Re: deprecating contrib for PGXN