From ffc8b93e0daf105276e595a2293cb079cd668df9 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Fri, 13 May 2011 19:55:53 +0200 Subject: [PATCH] First attempt at fixing bug #1735 where acls on OSX doesn't seem to reach the backup. --- bacula/autoconf/config.h.in | 18 ++++++++++++------ bacula/autoconf/configure.in | 31 ++++++++++++++++++++++++++++++- bacula/src/filed/acl.c | 31 ++++++++++++------------------- 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/bacula/autoconf/config.h.in b/bacula/autoconf/config.h.in index 2b4f018fd3..caa6daadcc 100644 --- a/bacula/autoconf/config.h.in +++ b/bacula/autoconf/config.h.in @@ -114,12 +114,6 @@ /* Define if you have zlib */ #undef HAVE_LIBZ -/* Define if you have libacl */ -#undef HAVE_ACL - -/* Define if you have AFS acls */ -#undef HAVE_AFS_ACL - /* General libs */ #undef LIBS @@ -227,6 +221,18 @@ /* Normal acl support */ #undef HAVE_ACL +/* Defines if your system have the ACL_TYPE_DEFAULT_DIR acl type */ +#undef HAVE_ACL_TYPE_DEFAULT_DIR + +/* Defines if your system have the ACL_TYPE_EXTENDED acl type */ +#undef HAVE_ACL_TYPE_EXTENDED + +/* Defines if your system have the ACL_TYPE_NFS4 acl type */ +#undef HAVE_ACL_TYPE_NFS4 + +/* Define to 1 if you have the 'add_proplist_entry' function. */ +#undef HAVE_ADD_PROPLIST_ENTRY + /* Defines if your system has AFS support */ #undef HAVE_AFS diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index bbcd0e2f04..3fd7bcc422 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -2625,14 +2625,43 @@ if test x$support_acl = xyes -o x$support_acl = xauto; then dnl dnl Check for acl_get_file in libpacl (OSF1) + dnl and if ACL_TYPE_DEFAULT_DIR is defined. dnl - if test $have_acl = no; then + if test $have_acl = no -a \ + x${HAVE_OSF1_OS_TRUE} = x; then AC_CHECK_LIB(pacl, acl_get_file, [ have_acl=yes FDLIBS="-lpacl $FDLIBS" ] ) + + AC_CHECK_DECL([ACL_TYPE_DEFAULT_DIR], + [AC_DEFINE(HAVE_ACL_TYPE_DEFAULT_DIR,1,[Defines if your system have the ACL_TYPE_DEFAULT_DIR acl type])], + [], + [[#include ]]) + fi + + dnl + dnl On OSX check for availability of ACL_TYPE_EXTENDED + dnl + if test $have_acl = yes -a \ + x${HAVE_DARWIN_OS_TRUE} = x; then + AC_CHECK_DECL([ACL_TYPE_EXTENDED], + [AC_DEFINE(HAVE_ACL_TYPE_EXTENDED,1,[Defines if your system have the ACL_TYPE_EXTENDED acl type])], + [], + [[#include ]]) + fi + + dnl + dnl On FreeBSD check for availability of ACL_TYPE_NFS4 + dnl + if test $have_acl = yes -a \ + x${HAVE_FREEBSD_OS_TRUE} = x; then + AC_CHECK_DECL([ACL_TYPE_NFS4], + [AC_DEFINE(HAVE_ACL_TYPE_NFS4,1,[Defines if your system have the ACL_TYPE_NFS4 acl type])], + [], + [[#include ]]) fi dnl diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index 9e4f922558..69659e98ba 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -480,7 +480,7 @@ static acl_type_t bac_to_os_acltype(bacl_type acltype) case BACL_TYPE_DEFAULT: ostype = ACL_TYPE_DEFAULT; break; -#ifdef ACL_TYPE_NFS4 +#ifdef HAVE_ACL_TYPE_NFS4 /** * FreeBSD has an additional acl type named ACL_TYPE_NFS4. */ @@ -488,7 +488,7 @@ static acl_type_t bac_to_os_acltype(bacl_type acltype) ostype = ACL_TYPE_NFS4; break; #endif -#ifdef ACL_TYPE_DEFAULT_DIR +#ifdef HAVE_ACL_TYPE_DEFAULT_DIR case BACL_TYPE_DEFAULT_DIR: /** * TRU64 has an additional acl type named ACL_TYPE_DEFAULT_DIR. @@ -496,7 +496,7 @@ static acl_type_t bac_to_os_acltype(bacl_type acltype) ostype = ACL_TYPE_DEFAULT_DIR; break; #endif -#ifdef ACL_TYPE_EXTENDED +#ifdef HAVE_ACL_TYPE_EXTENDED case BACL_TYPE_EXTENDED: /** * MacOSX has an additional acl type named ACL_TYPE_EXTENDED. @@ -680,12 +680,10 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) jcr->acl_data->content_length = 0; acl_free(acl); return bacl_exit_error; - } - - /** - * Handle errors gracefully. - */ - if (acl == (acl_t)NULL) { + } else { + /** + * Handle errors gracefully. + */ switch (errno) { #if defined(BACL_ENOTSUP) case BACL_ENOTSUP: @@ -696,7 +694,9 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) * when we change from one filesystem to an other. */ jcr->acl_data->flags &= ~BACL_FLAG_SAVE_NATIVE; - break; /* not supported */ + pm_strcpy(jcr->acl_data->content, ""); + jcr->acl_data->content_length = 0; + return bacl_exit_ok; #endif case ENOENT: pm_strcpy(jcr->acl_data->content, ""); @@ -714,13 +714,6 @@ static bacl_exit_code generic_get_acl_from_os(JCR *jcr, bacl_type acltype) return bacl_exit_error; } } - - /** - * Not supported, just pretend there is nothing to see - */ - pm_strcpy(jcr->acl_data->content, ""); - jcr->acl_data->content_length = 0; - return bacl_exit_ok; } /** @@ -810,7 +803,7 @@ static int os_default_acl_streams[1] = { -1 }; static bacl_exit_code darwin_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { -#if defined(ACL_TYPE_EXTENDED) +#if defined(HAVE_ACL_TYPE_EXTENDED) /** * On MacOS X, acl_get_file (name, ACL_TYPE_ACCESS) * and acl_get_file (name, ACL_TYPE_DEFAULT) @@ -838,7 +831,7 @@ static bacl_exit_code darwin_build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) static bacl_exit_code darwin_parse_acl_streams(JCR *jcr, int stream) { -#if defined(ACL_TYPE_EXTENDED) +#if defined(HAVE_ACL_TYPE_EXTENDED) return generic_set_acl_on_os(jcr, BACL_TYPE_EXTENDED); #else return generic_set_acl_on_os(jcr, BACL_TYPE_ACCESS); -- 2.39.5