changeset 10115:4e8f2032eb4d

Add support for ACLs on OSF/1.
author Bruno Haible <bruno@clisp.org>
date Fri, 23 May 2008 03:48:39 +0200
parents 51164d97e89b
children 2721f34f8750
files ChangeLog lib/acl-internal.h lib/acl_entries.c m4/acl.m4
diffstat 4 files changed, 49 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri May 23 01:13:51 2008 +0200
+++ b/ChangeLog	Fri May 23 03:48:39 2008 +0200
@@ -1,3 +1,14 @@
+2008-05-22  Bruno Haible  <bruno@clisp.org>
+
+	Add support for ACLs on OSF/1.
+	* lib/acl-internal.h (acl_get_fd, acl_set_fd): New inline function
+	replacements.
+	(acl_free_text): New macro fallback.
+	* lib/acl_entries.c (acl_entries): Use acl_free_text instead of
+	acl_free.
+	* m4/acl.m4 (gl_FUNC_ACL): Look also in libpacl library. Test for
+	acl_free_text function. Require AC_C_INLINE.
+	
 2008-05-22  Bruno Haible  <bruno@clisp.org>
 
 	Make copy_acl work on MacOS X 10.5.
--- a/lib/acl-internal.h	Fri May 23 01:13:51 2008 +0200
+++ b/lib/acl-internal.h	Fri May 23 03:48:39 2008 +0200
@@ -59,19 +59,48 @@
 #endif
 
 /* POSIX 1003.1e (draft 17) */
-#ifndef HAVE_ACL_GET_FD
+#ifdef HAVE_ACL_GET_FD
+/* Most platforms have a 1-argument acl_get_fd, only OSF/1 has a 2-argument
+   macro(!).  */
+# if HAVE_ACL_FREE_TEXT /* OSF/1 */
+static inline acl_t
+rpl_acl_get_fd (int fd)
+{
+  return acl_get_fd (fd, ACL_TYPE_ACCESS);
+}
+#  undef acl_get_fd
+#  define acl_get_fd rpl_acl_get_fd
+# endif
+#else
 # define HAVE_ACL_GET_FD false
 # undef acl_get_fd
 # define acl_get_fd(fd) (NULL)
 #endif
 
 /* POSIX 1003.1e (draft 17) */
-#ifndef HAVE_ACL_SET_FD
+#ifdef HAVE_ACL_SET_FD
+/* Most platforms have a 2-argument acl_set_fd, only OSF/1 has a 3-argument
+   macro(!).  */
+# if HAVE_ACL_FREE_TEXT /* OSF/1 */
+static inline int
+rpl_acl_set_fd (int fd, acl_t acl)
+{
+  return acl_set_fd (fd, ACL_TYPE_ACCESS, acl);
+}
+#  undef acl_set_fd
+#  define acl_set_fd rpl_acl_set_fd
+# endif
+#else
 # define HAVE_ACL_SET_FD false
 # undef acl_set_fd
 # define acl_set_fd(fd, acl) (-1)
 #endif
 
+/* POSIX 1003.1e (draft 13) */
+#if ! HAVE_ACL_FREE_TEXT
+# define acl_free_text(buf) acl_free (buf)
+#endif
+
 /* Linux-specific */
 #ifndef HAVE_ACL_EXTENDED_FILE
 # define HAVE_ACL_EXTENDED_FILE false
--- a/lib/acl_entries.c	Fri May 23 01:13:51 2008 +0200
+++ b/lib/acl_entries.c	Fri May 23 03:48:39 2008 +0200
@@ -1,6 +1,6 @@
 /* Return the number of entries in an ACL.
 
-   Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2008 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
@@ -33,6 +33,6 @@
     return -1;
   for (t = text; *t; t++)
     entries += (*t == '\n');
-  acl_free (text);
+  acl_free_text (text);
   return entries;
 }
--- a/m4/acl.m4	Fri May 23 01:13:51 2008 +0200
+++ b/m4/acl.m4	Fri May 23 03:48:39 2008 +0200
@@ -1,5 +1,5 @@
 # acl.m4 - check for access control list (ACL) primitives
-# serial 4
+# serial 6
 
 # Copyright (C) 2002, 2004-2008 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -16,6 +16,7 @@
 
   LIB_ACL=
   use_acl=0
+  AC_REQUIRE([AC_C_INLINE])
   if test "x$enable_acl" != "xno"; then
     dnl Prerequisites of lib/acl.c.
     AC_CHECK_HEADERS(sys/acl.h)
@@ -29,7 +30,8 @@
 	 AC_CHECK_FUNCS([acl_trivial])],
 	[AC_CHECK_FUNCS([acl_trivial])
 	 if test $ac_cv_func_acl_trivial != yes; then
-	   AC_SEARCH_LIBS([acl_get_file], [acl],
+	   dnl -lacl is needed on Linux, -lpacl is needed on OSF/1.
+	   AC_SEARCH_LIBS([acl_get_file], [acl pacl],
 	     [test "$ac_cv_search_acl_get_file" = "none required" ||
 	      LIB_ACL=$ac_cv_search_acl_get_file
 	      AC_CHECK_FUNCS(
@@ -38,7 +40,7 @@
 		 acl_delete_def_file acl_extended_file \
 		 acl_delete_fd_np acl_delete_file_np \
 		 acl_copy_ext_native acl_create_entry_np \
-		 acl_to_short_text])
+		 acl_to_short_text acl_free_text])
 	      if test $ac_cv_func_acl_get_file = yes; then
 		# If the acl_get_file bug is detected, disable all ACL support.
 		gl_ACL_GET_FILE( , [use_acl=0])