r2582: Merge checks for xattr and acl libraries from Samba3 so the {get,set}ntacl
authorTim Potter <tpot@samba.org>
Fri, 24 Sep 2004 04:49:45 +0000 (04:49 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:59:07 +0000 (12:59 -0500)
programs can build on non-xattr machines.

source/build/m4/rewrite.m4
source/include/includes.h
source/utils/getntacl.c
source/utils/setntacl.c

index 5afcfa687cb9f7d62c5e6ccec87ab547082aa144..577864fc5a58172d386ee9d80f59588d5d4025a6 100644 (file)
@@ -1547,3 +1547,117 @@ samba_cv_HAVE_COMPARISON_FN_T=yes,samba_cv_HAVE_COMPARISON_FN_T=no)
 if test x"$samba_cv_HAVE_COMPARISON_FN_T" = x"yes"; then
        AC_DEFINE(HAVE_COMPARISON_FN_T,1,[Whether or not we have comparison_fn_t])
 fi
+
+############################################
+# Check if we have extended attributes
+AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h)
+AC_SEARCH_LIBS(getxattr, [attr])
+AC_CHECK_FUNCS(getxattr lgetxattr fgetxattr listxattr llistxattr)
+AC_CHECK_FUNCS(flistxattr removexattr lremovexattr fremovexattr)
+AC_CHECK_FUNCS(setxattr lsetxattr fsetxattr)
+AC_CHECK_FUNCS(attr_get attr_list attr_set attr_remove)
+AC_CHECK_FUNCS(attr_getf attr_listf attr_setf attr_removef)
+
+#################################################
+# check for ACL support
+
+AC_MSG_CHECKING(whether to support ACLs)
+AC_ARG_WITH(acl-support,
+[  --with-acl-support      Include ACL support (default=no)],
+[ case "$withval" in
+  yes)
+
+       case "$host_os" in
+       *sysv5*)
+               AC_MSG_RESULT(Using UnixWare ACLs)
+               AC_DEFINE(HAVE_UNIXWARE_ACLS,1,[Whether UnixWare ACLs are available])
+               ;;
+       *solaris*)
+               AC_MSG_RESULT(Using solaris ACLs)
+               AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether solaris ACLs are available])
+               ;;
+       *hpux*)
+               AC_MSG_RESULT(Using HPUX ACLs)
+               AC_DEFINE(HAVE_HPUX_ACLS,1,[Whether HPUX ACLs are available])
+               ;;
+       *irix*)
+               AC_MSG_RESULT(Using IRIX ACLs)
+               AC_DEFINE(HAVE_IRIX_ACLS,1,[Whether IRIX ACLs are available])
+               ;;
+       *aix*)
+               AC_MSG_RESULT(Using AIX ACLs)
+               AC_DEFINE(HAVE_AIX_ACLS,1,[Whether AIX ACLs are available])
+               ;;
+       *osf*)
+               AC_MSG_RESULT(Using Tru64 ACLs)
+               AC_DEFINE(HAVE_TRU64_ACLS,1,[Whether Tru64 ACLs are available])
+               ACL_LIBS="$ACL_LIBS -lpacl"
+               ;;
+       *freebsd5*)
+               AC_MSG_RESULT(Using FreeBSD posix ACLs)
+               AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether FreeBSD POSIX ACLs are available])
+               AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
+               ;;
+       *linux*)
+               AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
+                       AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
+               AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
+               acl_LIBS=$LIBS
+               LIBS="$LIBS -lacl"
+               AC_TRY_LINK([#include <sys/types.h>
+#include <sys/acl.h>],
+[ 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)
+               LIBS=$acl_LIBS])
+                       if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
+                               AC_MSG_RESULT(Using posix ACLs)
+                               AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
+                               AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
+                               acl_LIBS=$LIBS
+                               LIBS="$LIBS -lacl"
+                               AC_TRY_LINK([#include <sys/types.h>
+#include <sys/acl.h>],
+[ 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)
+                               LIBS=$acl_LIBS])
+                               if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
+                                       AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
+                               fi
+                       fi
+            ;;
+         *)
+               AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
+               AC_CACHE_CHECK([for ACL support],samba_cv_HAVE_POSIX_ACLS,[
+               acl_LIBS=$LIBS
+               LIBS="$LIBS -lacl"
+               AC_TRY_LINK([#include <sys/types.h>
+#include <sys/acl.h>],
+[ 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)
+               LIBS=$acl_LIBS])
+                       if test x"$samba_cv_HAVE_POSIX_ACLS" = x"yes"; then
+                               AC_MSG_RESULT(Using posix ACLs)
+                               AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])
+                               AC_CACHE_CHECK([for acl_get_perm_np],samba_cv_HAVE_ACL_GET_PERM_NP,[
+                               acl_LIBS=$LIBS
+                               LIBS="$LIBS -lacl"
+                               AC_TRY_LINK([#include <sys/types.h>
+#include <sys/acl.h>],
+[ 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)
+                               LIBS=$acl_LIBS])
+                               if test x"$samba_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
+                                       AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
+                               fi
+                       fi
+            ;;
+        esac
+        ;;
+  *)
+    AC_MSG_RESULT(no)
+    AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support is available])
+    ;;
+  esac ],
+  AC_DEFINE(HAVE_NO_ACLS,1,[Whether no ACLs support should be built in])
+  AC_MSG_RESULT(no)
+)
index a5fd620049363dd12d60e071b09457d311b70938..8b20ee9b4f26a14e9ea3bd74cc81229f3c1eeeea 100644 (file)
@@ -1057,5 +1057,16 @@ time_t timegm(struct tm *tm);
 #define VXFS_QUOTA
 #endif
 
+#if HAVE_SYS_ATTRIBUTES_H
+#include <sys/attributes.h>
+#endif
+
+/* mutually exclusive (SuSE 8.2) */
+#if HAVE_ATTR_XATTR_H
+#include <attr/xattr.h>
+#elif HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#endif
+
 #endif /* _INCLUDES_H */
 
index b17200aeb5b43966cc45c749b59df190876a9784..0d6e86bf3b2328b0b25d2c906731812e2080ba2c 100644 (file)
 */
 
 #include "includes.h"
-#include <attr/xattr.h>
+
+#ifdef HAVE_NO_ACLS
+
+int main(int argc, char **argv)
+{
+       printf("ACL support not compiled in.");
+       return 1;
+}
+
+#else
 
 /* Display a security descriptor in "psec" format which is as follows.
 
@@ -114,3 +123,5 @@ int main(int argc, char **argv)
        print_psec(data, &sd);
        return 0;
 }
+
+#endif /* HAVE_NO_ACLS */
index 492c3ba9fefbe552347d482a2a3701aecff4800b..93939caec09909cf32aa035163a7c7e162ed5ef4 100644 (file)
 */
 
 #include "includes.h"
-#include <attr/xattr.h>
+
+#ifdef HAVE_NO_ACLS
+
+int main(int argc, char **argv)
+{
+       printf("ACL support not compiled in.");
+       return 1;
+}
+
+#else
 
 static void setntacl(char *filename, struct security_descriptor *sd)
 {
@@ -103,3 +112,5 @@ static void setntacl(char *filename, struct security_descriptor *sd)
 
        return 0;
 }
+
+#endif /* HAVE_NO_ACLS */