Commit 0a9d9877 authored by Paul Eggert's avatar Paul Eggert

Add support for Solaris 10 ACLs. Also, ACLs are Gnulib, not Autoconf.

* modules/acl (configure.ac): Rename AC_FUNC_ACL to gl_FUNC_ACL.
* m4/acl.m4 (gl_FUNC_ACL): Renamed from AC_FUNC_ACL.  On Solaris,
put -lsec in even for programs other than 'ls'.  This fixes a problem
for gettext reported by Bruno Haible in
<http://lists.gnu.org/archive/html/bug-gnulib/2007-12/msg00007.html>.
* lib/acl.c (copy_acl, qset_acl) [USE_ACL && defined ACL_NO_TRIVIAL]:
Add support for Solaris 10.  This isn't efficient, but should get the
job done for now.
parent 07dcdcf7
2007-12-03 Paul Eggert <eggert@cs.ucla.edu>
Add support for Solaris 10 ACLs. Also, ACLs are Gnulib, not Autoconf.
* modules/acl (configure.ac): Rename AC_FUNC_ACL to gl_FUNC_ACL.
* m4/acl.m4 (gl_FUNC_ACL): Renamed from AC_FUNC_ACL. On Solaris,
put -lsec in even for programs other than 'ls'. This fixes a problem
for gettext reported by Bruno Haible in
<http://lists.gnu.org/archive/html/bug-gnulib/2007-12/msg00007.html>.
* lib/acl.c (copy_acl, qset_acl) [USE_ACL && defined ACL_NO_TRIVIAL]:
Add support for Solaris 10. This isn't efficient, but should get the
job done for now.
2007-12-03 James Youngman <jay@gnu.org>
* doc/regexprops-generic.texi: change "an close-group" to "a
......@@ -144,10 +144,38 @@ copy_acl (const char *src_name, int source_desc, const char *dst_name,
acl_free (acl);
}
return 0;
#else
ret = chmod_or_fchmod (dst_name, dest_desc, mode);
# if USE_ACL && defined ACL_NO_TRIVIAL
/* Solaris 10 NFSv4 ACLs. */
acl_t *aclp = NULL;
ret = (source_desc < 0
? acl_get (src_name, ACL_NO_TRIVIAL, &aclp)
: facl_get (source_desc, ACL_NO_TRIVIAL, &aclp));
if (ret != 0 && errno != ENOSYS)
{
error (0, errno, "%s", quote (src_name));
return ret;
}
# endif
ret = qset_acl (dst_name, dest_desc, mode);
if (ret != 0)
error (0, errno, _("preserving permissions for %s"), quote (dst_name));
# if USE_ACL && defined ACL_NO_TRIVIAL
if (ret == 0 && aclp)
{
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);
}
# endif
return ret;
#endif
}
......@@ -240,7 +268,43 @@ qset_acl (char const *name, int desc, mode_t mode)
}
return 0;
#else
# if USE_ACL && defined ACL_NO_TRIVIAL
/* Solaris 10, with NFSv4 ACLs. */
acl_t *aclp;
char acl_text[] = "user::---,group::---,mask:---,other:---";
if (mode & S_IRUSR) acl_text[ 6] = 'r';
if (mode & S_IWUSR) acl_text[ 7] = 'w';
if (mode & S_IXUSR) acl_text[ 8] = 'x';
if (mode & S_IRGRP) acl_text[17] = acl_text[26] = 'r';
if (mode & S_IWGRP) acl_text[18] = acl_text[27] = 'w';
if (mode & S_IXGRP) acl_text[19] = acl_text[28] = 'x';
if (mode & S_IROTH) acl_text[36] = 'r';
if (mode & S_IWOTH) acl_text[37] = 'w';
if (mode & S_IXOTH) acl_text[38] = 'x';
if (acl_fromtext (acl_text, &aclp) != 0)
{
errno = ENOMEM;
return -1;
}
else
{
int acl_result = (desc < 0 ? acl_set (name, aclp) : facl_set (desc, aclp));
int acl_errno = errno;
acl_free (aclp);
if (acl_result == 0 || acl_errno != ENOSYS)
{
errno = acl_errno;
return acl_result;
}
}
# endif
return chmod_or_fchmod (name, desc, mode);
#endif
}
......
......@@ -7,50 +7,54 @@
# Written by Paul Eggert and Jim Meyering.
AC_DEFUN([AC_FUNC_ACL],
AC_DEFUN([gl_FUNC_ACL],
[
AC_LIBOBJ([acl])
AC_LIBOBJ([file-has-acl])
dnl Prerequisites of lib/acl.c.
LIB_ACL=
use_acl=0
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])
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)
if test $ac_cv_header_sys_acl_h = yes; then
use_acl=1
if test $ac_cv_func_acl_get_file = yes; then
# If we detect the acl_get_file bug, disable ACL support altogether.
gl_ACL_GET_FILE( , [use_acl=0])
fi
else
use_acl=0
fi
if test $use_acl = 1 &&
test $ac_cv_func_acl_get_file = yes &&
test $ac_cv_func_acl_free = yes; then
AC_REPLACE_FUNCS([acl_entries])
fi
LIBS="$ac_save_LIBS"
if test $use_acl = 1; then
ac_save_LIBS="$LIBS"
if test $ac_cv_header_sys_acl_h = yes; then
ac_save_LIBS=$LIBS
AC_CHECK_FUNCS([acl])
use_acl=1
AC_SEARCH_LIBS([acl_trivial], [sec],
[AC_DEFINE([HAVE_ACL_TRIVIAL], 1,
[Define to 1 if you have the `acl_trivial' function.])
test "$ac_cv_search_acl_trivial" = "none required" ||
LIB_ACL_TRIVIAL="$ac_cv_search_acl_trivial"])
AC_SUBST([LIB_ACL_TRIVIAL])
LIBS="$ac_save_LIBS"
[test "$ac_cv_search_acl_trivial" = "none required" ||
LIB_ACL=$ac_cv_search_acl_trivial
AC_CHECK_FUNCS([acl_trivial])],
[if test $ac_cv_func_acl_trivial != yes; 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
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])
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])
fi
if test $use_acl = 1; then
AC_CHECK_HEADERS([acl/libacl.h])
if test $ac_cv_func_acl_get_file = yes &&
test $ac_cv_func_acl_free = yes; then
AC_REPLACE_FUNCS([acl_entries])
fi
else
LIB_ACL=
fi])
fi])
LIBS=$ac_save_LIBS
fi
AC_DEFINE_UNQUOTED(USE_ACL, $use_acl,
[Define if you want access control list support.])
AC_SUBST([LIB_ACL])
AC_DEFINE_UNQUOTED([USE_ACL], [$use_acl],
[Define to nonzero if you want access control list support.])
# This is for backwards compatibility; remove this by the end of 2007.
LIB_ACL_TRIVIAL=
AC_SUBST([LIB_ACL_TRIVIAL])
])
# gl_ACL_GET_FILE(IF-WORKS, IF-NOT)
......
......@@ -16,7 +16,7 @@ quote
sys_stat
configure.ac:
AC_FUNC_ACL
gl_FUNC_ACL
Makefile.am:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment