www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/08/01/08:25:18

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Mon, 1 Aug 2011 14:24:25 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: bash-4.2 and symlink to folder that turns to be not executable
Message-ID: <20110801122425.GX26203@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <20110801115922 DOT GA1124 AT po8371>
MIME-Version: 1.0
In-Reply-To: <20110801115922.GA1124@po8371>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Aug  1 13:58, Denis Excoffier wrote:
> 
> Hello,
> 
> I have a bash-4.2 (installed in /home/my), compiled with GCC 4.6.1
> directly from the sources. With this one, the following script:
> 
> ---------------------------------
> #!/home/my/bash-4.2
> 
> rm -rf /tmp/xxx
> mkdir -p /tmp/xxx/folder1
> ln -s folder1 /tmp/xxx/folder
> if [ -d /tmp/xxx/folder ]; then echo folder; else echo no folder; fi
> if [ -x /tmp/xxx/folder ]; then echo execut; else echo no execut; fi
> exit
> ---------------------------------
> 
> produces:
> 
> folder
> no execut
> 
> while the regular /bin/bash (4.1.10), with the same script:
> 
> ---------------------------------
> #!/bin/bash
> 
> rm -rf /tmp/xxx
> mkdir -p /tmp/xxx/folder1
> ln -s folder1 /tmp/xxx/folder
> if [ -d /tmp/xxx/folder ]; then echo folder; else echo no folder; fi
> if [ -x /tmp/xxx/folder ]; then echo execut; else echo no execut; fi
> exit
> ---------------------------------
> 
> produces (correctly):
> 
> folder
> execut
> 
> 
> Could be a bug in bash-4.2, but...
> i have noticed that it occurs only under the newest snapshots.
> The change occurred between the 2011-07-21 and 2011-07-29 snapshots.
> 
> My current /proc/version | tr -d '@' is:
> CYGWIN_NT-5.1 version 1.7.10s(0.249/5/3) (cgf) (gcc version 4.3.4 20090804 (release) 1 (GCC) ) 20110801 00:02:52
> 
> Could someone please have a look and reproduce this?

I can't since I have bash 4.1.10(4) from the distro installed.  This is
a nice case where you would have to debug this yourself since you have
the binaries available to do it.

However, at a first glance I doubt this is a Cygwin bug.  Consider:

- bash 4.1.10 returns "execut"
- /bin/test from coreustils returns "execut"
- My highly professional and streamlined testcase returns the correct
  result:

    #include <stdio.h>
    #include <unistd.h>
    #include <errno.h>
    #include <string.h>

    void
    my_access (const char *file, int flag, const char *fname, int effective)
    {
      int ret = effective ? access (file, flag) : eaccess (file, flag);
      printf ("%saccess (%s, %s) = %d",
	      effective ? "e" : " ", file, fname, ret);
      if (ret)
	printf (" <%s>", strerror (errno));
      fputc ('\n', stdout);
    }

    int
    main (int argc, char**argv)
    {
      int eff;

      if (argc > 1)
	for (eff = 0; eff < 2; ++eff)
	  {
	    my_access (argv[1], F_OK, "F_OK", eff);
	    my_access (argv[1], R_OK, "R_OK", eff);
	    my_access (argv[1], W_OK, "W_OK", eff);
	    my_access (argv[1], X_OK, "X_OK", eff);
	  }
      return 0;
    }

  $ gcc -g -o access access.c
  $ ./access /tmp/xxx/folder
   access (/tmp/xxx/folder, F_OK) = 0
   access (/tmp/xxx/folder, R_OK) = 0
   access (/tmp/xxx/folder, W_OK) = 0
   access (/tmp/xxx/folder, X_OK) = 0
  eaccess (/tmp/xxx/folder, F_OK) = 0
  eaccess (/tmp/xxx/folder, R_OK) = 0
  eaccess (/tmp/xxx/folder, W_OK) = 0
  eaccess (/tmp/xxx/folder, X_OK) = 0


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019