Add support for ACLs on OSF/1.
authorBruno Haible <bruno@clisp.org>
Fri, 23 May 2008 01:48:39 +0000 (03:48 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 23 May 2008 02:16:57 +0000 (04:16 +0200)
ChangeLog
lib/acl-internal.h
lib/acl_entries.c
m4/acl.m4

index e9d1de6..5bc446d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 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.
        * lib/acl-internal.h (MODE_INSIDE_ACL): New macro.
        (ACL_NOT_WELL_SUPPORTED): On MacOS X, also handle ENOENT.
index 75bca17..eeedc74 100644 (file)
 #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
index 43c752d..cd3c38b 100644 (file)
@@ -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 @@ acl_entries (acl_t acl)
     return -1;
   for (t = text; *t; t++)
     entries += (*t == '\n');
-  acl_free (text);
+  acl_free_text (text);
   return entries;
 }
index 4eadab5..de76616 100644 (file)
--- a/m4/acl.m4
+++ b/m4/acl.m4
@@ -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 @@ AC_DEFUN([gl_FUNC_ACL],
 
   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_DEFUN([gl_FUNC_ACL],
         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 @@ AC_DEFUN([gl_FUNC_ACL],
                 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])