From ed449b8ca7697d64ab3cfe8289287dd18566c91e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 14 Apr 2001 19:46:28 +0000 Subject: Added POSIX_ACL support for *BSD. Patch from jedgar@fxp.org. Changed a bit to use AC_TRY_LINK to ensure functions are available for link instead of AC_TRY_COMPILE. Jeremy. (This used to be commit c23628746342b6afa28cb34b0b4eaa61189ad390) --- source3/acconfig.h | 1 + source3/configure | 60 +++++++++++++++++++++++++++++++++++---------- source3/configure.in | 22 +++++++++++------ source3/include/config.h.in | 1 + source3/lib/sysacls.c | 9 +++++++ 5 files changed, 73 insertions(+), 20 deletions(-) diff --git a/source3/acconfig.h b/source3/acconfig.h index fd319509b9..63af9f78c1 100644 --- a/source3/acconfig.h +++ b/source3/acconfig.h @@ -139,6 +139,7 @@ #undef MIPS_SPINLOCKS #undef POWERPC_SPINLOCKS #undef HAVE_POSIX_ACLS +#undef HAVE_ACL_GET_PERM_NP #undef HAVE_UNIXWARE_ACLS #undef HAVE_SOLARIS_ACLS #undef HAVE_IRIX_ACLS diff --git a/source3/configure b/source3/configure index 7cf0e29407..4a3b7f07be 100755 --- a/source3/configure +++ b/source3/configure @@ -12041,7 +12041,7 @@ EOF ;; *) - echo $ac_n "checking for acl_get_file in -lacl""... $ac_c" 1>&6 + echo $ac_n "checking for acl_get_file in -lacl""... $ac_c" 1>&6 echo "configure:12046: checking for acl_get_file in -lacl" >&5 ac_lib_var=`echo acl'_'acl_get_file | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then @@ -12088,13 +12088,13 @@ else echo "$ac_t""no" 1>&6 fi - echo $ac_n "checking for ACL support""... $ac_c" 1>&6 + echo $ac_n "checking for ACL support""... $ac_c" 1>&6 echo "configure:12093: checking for ACL support" >&5 if eval "test \"`echo '$''{'samba_cv_HAVE_POSIX_ACLS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - cat > conftest.$ac_ext < conftest.$ac_ext < @@ -12103,7 +12103,7 @@ int main() { acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p); ; return 0; } EOF -if { (eval echo configure:12107: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:12107: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* samba_cv_HAVE_POSIX_ACLS=yes else @@ -12116,21 +12116,55 @@ rm -f conftest* fi echo "$ac_t""$samba_cv_HAVE_POSIX_ACLS" 1>&6 - if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then - echo "$ac_t""Using posix ACLs" 1>&6 - cat >> confdefs.h <<\EOF + if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then + echo "$ac_t""Using posix ACLs" 1>&6 + cat >> confdefs.h <<\EOF #define HAVE_POSIX_ACLS 1 EOF - fi + echo $ac_n "checking for acl_get_perm_np""... $ac_c" 1>&6 +echo "configure:12127: checking for acl_get_perm_np" >&5 +if eval "test \"`echo '$''{'samba_cv_HAVE_ACL_GET_PERM_NP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + + cat > conftest.$ac_ext < +#include +int main() { + acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm); +; return 0; } +EOF +if { (eval echo configure:12141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + samba_cv_HAVE_ACL_GET_PERM_NP=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + samba_cv_HAVE_ACL_GET_PERM_NP=no +fi +rm -f conftest* +fi + +echo "$ac_t""$samba_cv_HAVE_ACL_GET_PERM_NP" 1>&6 + if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then + cat >> confdefs.h <<\EOF +#define HAVE_ACL_GET_PERM_NP 1 +EOF + + fi + fi echo $ac_n "checking for XFS ACL support""... $ac_c" 1>&6 -echo "configure:12128: checking for XFS ACL support" >&5 +echo "configure:12162: checking for XFS ACL support" >&5 if eval "test \"`echo '$''{'samba_cv_HAVE_XFS_ACLS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -12138,7 +12172,7 @@ int main() { char test_str[13] = SGI_ACL_FILE; ; return 0; } EOF -if { (eval echo configure:12142: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:12176: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* samba_cv_HAVE_XFS_ACLS=yes else @@ -12183,11 +12217,11 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:12225: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "configure OK"; else diff --git a/source3/configure.in b/source3/configure.in index c8270d2d5c..16f7f0af1a 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2075,16 +2075,24 @@ AC_ARG_WITH(acl-support, AC_DEFINE(HAVE_IRIX_ACLS) ;; *) - AC_CHECK_LIB(acl,acl_get_file) - AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[ - AC_TRY_COMPILE([#include + AC_CHECK_LIB(acl,acl_get_file) + AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[ + AC_TRY_LINK([#include #include ], [ acl_t acl; int entry_id; acl_entry_t *entry_p; return acl_get_entry( acl, entry_id, entry_p);], samba_cv_HAVE_POSIX_ACLS=yes,samba_cv_HAVE_POSIX_ACLS=no)]) - if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then - AC_MSG_RESULT(Using posix ACLs) - AC_DEFINE(HAVE_POSIX_ACLS) - fi + if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then + AC_MSG_RESULT(Using posix ACLs) + AC_DEFINE(HAVE_POSIX_ACLS) + AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[ + AC_TRY_LINK([#include +#include ], +[ acl_permset_t permset_d; acl_perm_t perm; return acl_get_perm_np( permset_d, perm);], +samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_cv_HAVE_ACL_GET_PERM_NP=no)]) + if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then + AC_DEFINE(HAVE_ACL_GET_PERM_NP) + fi + fi AC_CACHE_CHECK([for XFS ACL support],samba_cv_HAVE_XFS_ACLS,[ AC_TRY_COMPILE([#include #include ], diff --git a/source3/include/config.h.in b/source3/include/config.h.in index b13f465691..6a6c856766 100644 --- a/source3/include/config.h.in +++ b/source3/include/config.h.in @@ -202,6 +202,7 @@ #undef MIPS_SPINLOCKS #undef POWERPC_SPINLOCKS #undef HAVE_POSIX_ACLS +#undef HAVE_ACL_GET_PERM_NP #undef HAVE_UNIXWARE_ACLS #undef HAVE_SOLARIS_ACLS #undef HAVE_IRIX_ACLS diff --git a/source3/lib/sysacls.c b/source3/lib/sysacls.c index 02018a52b3..ba015e8f8d 100644 --- a/source3/lib/sysacls.c +++ b/source3/lib/sysacls.c @@ -113,7 +113,16 @@ int sys_acl_add_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm) int sys_acl_get_perm( SMB_ACL_PERMSET_T permset, SMB_ACL_PERM_T perm) { +#if defined(HAVE_ACL_GET_PERM_NP) + /* + * Required for TrustedBSD-based ACL implementations where + * non-POSIX.1e functions are denoted by a _np (non-portable) + * suffix. + */ + return acl_get_perm_np(permset, perm); +#else return acl_get_perm(permset, perm); +#endif } char *sys_acl_to_text( SMB_ACL_T the_acl, ssize_t *plen) -- cgit