From 67a85c2b8a870d5f34acbc699f6c429b865b4d10 Mon Sep 17 00:00:00 2001 From: David Bartley Date: Mon, 4 May 2009 12:19:25 +0200 Subject: [PATCH] Fix test-file-has-acl on FreeBSD. --- ChangeLog | 10 ++++++++++ modules/acl-tests | 1 + tests/test-file-has-acl.c | 11 ++++++++++- tests/test-file-has-acl.sh | 10 +++++++--- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ad5e0fe638..3f6d793843 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-05-04 David Bartley + Bruno Haible + + Fix test-file-has-acl on FreeBSD. + * tests/test-file-has-acl.sh: Also test a directory. On FreeBSD, the + mask is implicitly added. + * tests/test-file-has-acl.c: Include . + (main): Terminate the test after 5 seconds. + * modules/acl-tests (configure.ac): Check for alarm function. + 2009-05-04 Bruno Haible Exploit new semantics of AC_DEFUN_ONCE available since 2009-01-26. diff --git a/modules/acl-tests b/modules/acl-tests index 0aacd4141b..b0a3b73485 100644 --- a/modules/acl-tests +++ b/modules/acl-tests @@ -14,6 +14,7 @@ unistd xalloc configure.ac: +AC_CHECK_DECLS_ONCE([alarm]) Makefile.am: TESTS += test-file-has-acl.sh test-set-mode-acl.sh test-copy-acl.sh diff --git a/tests/test-file-has-acl.c b/tests/test-file-has-acl.c index daab4dbd9f..5685f41155 100644 --- a/tests/test-file-has-acl.c +++ b/tests/test-file-has-acl.c @@ -1,5 +1,5 @@ /* Test for presence of ACL. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include "acl.h" +#include #include #include #include @@ -54,6 +55,14 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } + /* Check against possible infinite loop in file_has_acl. */ +#if HAVE_DECL_ALARM + /* Declare failure if test takes too long, by using default abort + caused by SIGALRM. */ + signal (SIGALRM, SIG_DFL); + alarm (5); +#endif + #if USE_ACL { int ret = file_has_acl (file, &statbuf); diff --git a/tests/test-file-has-acl.sh b/tests/test-file-has-acl.sh index 9783960823..7064c1cdf0 100755 --- a/tests/test-file-has-acl.sh +++ b/tests/test-file-has-acl.sh @@ -183,6 +183,9 @@ cd "$builddir" || func_test_has_acl tmpfile0 no + mkdir tmpdir0 + func_test_has_acl tmpdir0 no + if test $acl_flavor != none; then # Use a user and group id different from the current one, to avoid # redundant/ambiguous ACLs. @@ -208,11 +211,11 @@ cd "$builddir" || *) setfacl -d user:$auid:1 tmpfile0 ;; esac - # On Linux, the ACL for the mask is implicitly added. + # On Linux and FreeBSD, the ACL for the mask is implicitly added. # On Solaris, it is always there. case $acl_flavor in - linux) func_test_has_acl tmpfile0 yes ;; - *) func_test_has_acl tmpfile0 no ;; + linux | freebsd) func_test_has_acl tmpfile0 yes ;; + *) func_test_has_acl tmpfile0 no ;; esac # Remove the ACL for the mask, if it was implicitly added. @@ -328,6 +331,7 @@ cd "$builddir" || fi rm -f tmpfile[0-9] tmp.err + rm -rf tmpdir0 ) || exit 1 rm -rf "$tmp" -- 2.30.2