[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: copy_acl on IRIX
From: |
Paul Eggert |
Subject: |
Re: copy_acl on IRIX |
Date: |
Mon, 22 Oct 2007 23:34:28 -0700 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) |
Paul Eggert <address@hidden> writes:
> Jim Meyering <address@hidden> writes:
>
>> However, a long-term (forward-looking :-) solution should
>> also take into consideration the state of NFSv4 and ZFS.
>
> Yes, I'll see if I can pry free some time to look into that.
Here's a proposed patch to gnulib, to port copy_file to NFSv4 and ZFS,
using the Solaris interfaces.
2007-10-22 Paul Eggert <address@hidden>
Port copy_acl to Solaris 10.
* lib/acl.c (copy_acl): Prefer Solaris 10's functions if available.
* m4/acl.m4 (AC_FUNC_ACL): Check for facl_get a la Solaris 10.
diff --git a/lib/acl.c b/lib/acl.c
index 89d48d3..c9c1d98 100644
--- a/lib/acl.c
+++ b/lib/acl.c
@@ -40,22 +40,43 @@ chmod_or_fchmod (const char *name, int desc, mode_t mode)
/* Copy access control lists from one file to another. If SOURCE_DESC is
a valid file descriptor, use file descriptor operations, else use
filename based operations on SRC_NAME. Likewise for DEST_DESC and
- DEST_NAME.
+ DST_NAME.
If access control lists are not available, fchmod the target file to
MODE. Also sets the non-permission bits of the destination file
(S_ISUID, S_ISGID, S_ISVTX) to those from MODE if any are set.
- System call return value semantics. */
+ Return 0 if successful, otherwise output a diagnostic and return -1. */
int
copy_acl (const char *src_name, int source_desc, const char *dst_name,
int dest_desc, mode_t mode)
{
- int ret;
+#if USE_ACL && HAVE_FACL_GET
+
+ /* Solaris 10 ACLs. */
+ acl_t *aclp;
+ int ret = (source_desc < 0
+ ? acl_get (src_name, 0, &aclp)
+ : facl_get (source_desc, 0, &aclp));
+
+ if (ret != 0)
+ error (0, errno, "%s", quote (src_name));
+ else
+ {
+ ret = (dest_desc < 0
+ ? acl_set (dst_name, aclp)
+ : facl_set (dest_desc, aclp));
+ if (ret != 0)
+ error (0, errno, _("preserving permissions for %s"), quote (dst_name));
+ acl_free (aclp);
+ }
-#if USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_SET_FILE && HAVE_ACL_FREE
+ return ret;
+
+#elif USE_ACL && HAVE_ACL_GET_FILE && HAVE_ACL_SET_FILE && HAVE_ACL_FREE
/* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
acl_t acl;
+ int ret;
if (HAVE_ACL_GET_FD && source_desc != -1)
acl = acl_get_fd (source_desc);
else
@@ -145,7 +166,7 @@ copy_acl (const char *src_name, int source_desc, const char
*dst_name,
}
return 0;
#else
- ret = chmod_or_fchmod (dst_name, dest_desc, mode);
+ int ret = chmod_or_fchmod (dst_name, dest_desc, mode);
if (ret != 0)
error (0, errno, _("preserving permissions for %s"), quote (dst_name));
return ret;
diff --git a/m4/acl.m4 b/m4/acl.m4
index 6e6bd08..61a7937 100644
--- a/m4/acl.m4
+++ b/m4/acl.m4
@@ -16,14 +16,20 @@ AC_DEFUN([AC_FUNC_ACL],
AC_CHECK_HEADERS(sys/acl.h)
AC_CHECK_FUNCS(acl)
ac_save_LIBS="$LIBS"
- AC_SEARCH_LIBS(acl_get_file, acl,
- [test "$ac_cv_search_acl_get_file" = "none required" ||
- LIB_ACL=$ac_cv_search_acl_get_file])
+ LIB_ACL=
+ AC_SEARCH_LIBS(facl_get, sec,
+ [test "$ac_cv_search_facl_get" = "none required" ||
+ LIB_ACL=$ac_cv_search_facl_get])
+ if test -z "$LIB_ACL"; then
+ AC_SEARCH_LIBS(acl_get_file, acl,
+ [test "$ac_cv_search_acl_get_file" = "none required" ||
+ LIB_ACL=$ac_cv_search_acl_get_file])
+ fi
AC_SUBST(LIB_ACL)
AC_CHECK_HEADERS(acl/libacl.h)
AC_CHECK_FUNCS(acl_get_file acl_get_fd acl_set_file acl_set_fd \
acl_free acl_from_mode acl_from_text \
- acl_delete_def_file acl_extended_file)
+ acl_delete_def_file acl_extended_file facl_get)
if test $ac_cv_header_sys_acl_h = yes; then
use_acl=1
if test $ac_cv_func_acl_get_file = yes; then