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.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 7FE3B1F4B4 for ; Wed, 20 Jan 2021 08:32:14 +0000 (UTC) Received: from localhost ([::1]:46644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l28uT-0003JJ-1L for normalperson@yhbt.net; Wed, 20 Jan 2021 03:32:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l28uQ-0003J0-24 for bug-gnulib@gnu.org; Wed, 20 Jan 2021 03:32:10 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.216]:35548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l28uN-0001Op-HG for bug-gnulib@gnu.org; Wed, 20 Jan 2021 03:32:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1611131525; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:From: Subject:Sender; bh=6OCprmbpPnpxxBfLW3c1cgXFKHncXhPgl0M2dd6d660=; b=B7r+EndrEAdjjrFHkrbGm3r4hGbGyERx88EWbNkT2kzQqyd5DvJpkMPGs54mspXJOH b9ICDrABU/VdQWUNjKuY+IcRrr+cpOnTcovR3+ZgLfJiuT/4ZCuKREabbZvnE1f8zoRE LdD7tYS2sGVz/7svSvBnuqJ7RFYITc6LQi0WG+7dPuq8B0Vl/xeEOO0HpqZzTNTMke2M 2ZSEsN9DBobaH/B0lBPK7dc5XH22KXm9f16fof3vAtpFEgUPMbL5p8CVqajXO3XqTLTa Zv+JTsRsy2JzuAgKEz1y0W4DxagtxvnzRbISeGaEAphfQr5e34h0grxBC57zADF/rbW+ CiqA== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOHqfyyvs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.12.1 DYNA|AUTH) with ESMTPSA id u0aa20x0K8Vt5rg (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Wed, 20 Jan 2021 09:31:55 +0100 (CET) From: Bruno Haible To: Ken Brown Subject: Re: canonicalize test failures on Cygwin Date: Wed, 20 Jan 2021 09:31:54 +0100 Message-ID: <4020784.TNRAV67S1Q@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <61d5cba8-0a95-a4ab-6356-ddedae71b39f@cornell.edu> References: <2648155.ZFRgl74NVv@omega> <61d5cba8-0a95-a4ab-6356-ddedae71b39f@cornell.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.216; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Eggert , bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Ken Brown wrote: > I took a quick look, and it appears that this is a Cygwin bug in which > realpath() fails with ENOENT instead of ENOTDIR. Yes, I confirm. POSIX says that when one of the components "names an existing file that is neither a directory nor a symbolic link to a directory", realpath() shall fail with error ENOTDIR. Failing with error ENOENT is not allowed in this case. Here's a patch that detects the issue at configure time and adds a workaround. With it, the unit tests pass. 2021-01-20 Bruno Haible canonicalize-lgpl: Work around a Cygwin bug. * m4/canonicalize.m4 (gl_FUNC_REALPATH_WORKS): Test for lstat. Add a test case that involves a symbolic link to an existing file. * doc/posix-functions/realpath.texi: Mention the Cygwin bug. diff --git a/doc/posix-functions/realpath.texi b/doc/posix-functions/realpath.texi index a5b7c1d..dbeed3d 100644 --- a/doc/posix-functions/realpath.texi +++ b/doc/posix-functions/realpath.texi @@ -24,9 +24,9 @@ This function fails to detect trailing slashes on non-directories on some platforms: glibc 2.3.5, Mac OS X 10.13, OpenBSD 6.0. @item -This function fails to recognize non-directories followed @samp{..} on -some platforms: -cygwin. +This function fails to recognize non-directories or symlinks to non-directories +followed by @samp{..} on some platforms: +Cygwin 2.9. @item This function misbehaves on consecutive slashes on some platforms: musl libc 1.2.2, AIX 7. diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4 index 6821c70..0dfb2da 100644 --- a/m4/canonicalize.m4 +++ b/m4/canonicalize.m4 @@ -1,4 +1,4 @@ -# canonicalize.m4 serial 36 +# canonicalize.m4 serial 37 dnl Copyright (C) 2003-2007, 2009-2021 Free Software Foundation, Inc. @@ -78,15 +78,20 @@ AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE], # so is the latter. AC_DEFUN([gl_FUNC_REALPATH_WORKS], [ - AC_CHECK_FUNCS_ONCE([realpath]) + AC_CHECK_FUNCS_ONCE([realpath lstat]) AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles AC_CACHE_CHECK([whether realpath works], [gl_cv_func_realpath_works], [ rm -rf conftest.a conftest.d touch conftest.a + # Assume that if we have lstat, we can also check symlinks. + if test $ac_cv_func_lstat = yes; then + ln -s conftest.a conftest.l + fi mkdir conftest.d AC_RUN_IFELSE([ AC_LANG_PROGRAM([[ ]GL_NOCRASH[ + #include #include #include ]], [[ @@ -98,17 +103,27 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], result |= 1; free (name); } + /* This test fails on older versions of Cygwin. */ { char *name = realpath ("conftest.b/../conftest.a", NULL); if (name != NULL) result |= 2; free (name); } + /* This test fails on Cygwin 2.9. */ + #if HAVE_LSTAT + { + char *name = realpath ("conftest.l/../conftest.a", NULL); + if (name != NULL || errno != ENOTDIR) + result |= 4; + free (name); + } + #endif /* This test fails on Mac OS X 10.13, OpenBSD 6.0. */ { char *name = realpath ("conftest.a/", NULL); if (name != NULL) - result |= 4; + result |= 8; free (name); } /* This test fails on AIX 7, Solaris 10. */ @@ -116,7 +131,7 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], char *name1 = realpath (".", NULL); char *name2 = realpath ("conftest.d//./..", NULL); if (! name1 || ! name2 || strcmp (name1, name2)) - result |= 8; + result |= 16; free (name1); free (name2); } @@ -127,7 +142,7 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], { char *name = realpath ("//", NULL); if (! name || strcmp (name, "/")) - result |= 16; + result |= 32; free (name); } #endif @@ -136,7 +151,7 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], ], [gl_cv_func_realpath_works=yes], [case $? in - 16) gl_cv_func_realpath_works=nearly ;; + 32) gl_cv_func_realpath_works=nearly ;; *) gl_cv_func_realpath_works=no ;; esac ], @@ -145,13 +160,15 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS], *-gnu* | gnu*) gl_cv_func_realpath_works="guessing yes" ;; # Guess 'nearly' on musl systems. *-musl*) gl_cv_func_realpath_works="guessing nearly" ;; + # Guess no on Cygwin. + cygwin*) gl_cv_func_realpath_works="guessing no" ;; # Guess no on native Windows. mingw*) gl_cv_func_realpath_works="guessing no" ;; # If we don't know, obey --enable-cross-guesses. *) gl_cv_func_realpath_works="$gl_cross_guess_normal" ;; esac ]) - rm -rf conftest.a conftest.d + rm -rf conftest.a conftest.l conftest.d ]) case "$gl_cv_func_realpath_works" in *yes)