From: Marco van Wieringen Date: Sat, 4 Jul 2009 21:18:49 +0000 (+0000) Subject: Change checking for acl and xattr support from first file to job level. X-Git-Tag: Release-3.0.2~109 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=05dcc38a2a7fa335a637499362a9bbfa1c559d47;p=bacula%2Fbacula Change checking for acl and xattr support from first file to job level. Call acl and xattr function only when requested for fileset and filed has support for acl or xattr Fix typo introduces by fix for bug #1305 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8957 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/filed/acl.c b/bacula/src/filed/acl.c index 9e76b24045..80c454b6f6 100644 --- a/bacula/src/filed/acl.c +++ b/bacula/src/filed/acl.c @@ -57,40 +57,20 @@ #include "bacula.h" #include "filed.h" -/* - * List of supported OSes. Everything outside that gets stub functions. - * Also when ACL support is explicitly disabled. - * Not sure if all the HAVE_XYZ_OS are correct for autoconf. - * The ones that says man page, are coded according to man pages only. - */ -#if !defined(HAVE_ACL) /* ACL support is required, of course */ \ - || !( defined(HAVE_AIX_OS) /* man page -- may need flags */ \ - || defined(HAVE_DARWIN_OS) /* tested -- compile without flags */ \ - || defined(HAVE_FREEBSD_OS) /* tested -- compile without flags */ \ - || defined(HAVE_HPUX_OS) /* man page -- may need flags */ \ - || defined(HAVE_IRIX_OS) /* man page -- compile without flags */ \ - || defined(HAVE_LINUX_OS) /* tested -- compile with -lacl */ \ - || defined(HAVE_OSF1_OS) /* man page -- may need -lpacl */ \ - || defined(HAVE_SUN_OS) /* tested -- compile with -lsec */ \ - ) - +#if !defined(HAVE_ACL) /* * Entry points when compiled without support for ACLs or on an unsupported platform. */ bool build_acl_streams(JCR *jcr, FF_PKT *ff_pkt) { - Jmsg(jcr, M_FATAL, 0, _("ACL support not configured for your machine.\n")); return false; } - +- bool parse_acl_stream(JCR *jcr, int stream) { - Jmsg(jcr, M_FATAL, 0, _("ACL support not configured for your machine.\n")); return false; } - #else - /* * Send an ACL stream to the SD. */ diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index f098c96ee5..0fb9494a00 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -38,6 +38,18 @@ #include "bacula.h" #include "filed.h" +#if defined(HAVE_ACL) +const bool have_acl = true; +#else +const bool have_acl = false; +#endif + +#if defined(HAVE_XATTR) +const bool have_xattr = true; +#else +const bool have_xattr = false; +#endif + /* Forward referenced functions */ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level); static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, DIGEST *signature_digest); @@ -128,8 +140,12 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) start_heartbeat_monitor(jcr); - jcr->acl_data = get_pool_memory(PM_MESSAGE); - jcr->xattr_data = get_pool_memory(PM_MESSAGE); + if (have_acl) { + jcr->acl_data = get_pool_memory(PM_MESSAGE); + } + if (have_xattr) { + jcr->xattr_data = get_pool_memory(PM_MESSAGE); + } /* Subroutine save_file() is called for each file */ if (!find_files(jcr, (FF_PKT *)jcr->ff, save_file, plugin_save)) { @@ -143,11 +159,11 @@ bool blast_data_to_storage_daemon(JCR *jcr, char *addr) sd->signal(BNET_EOD); /* end of sending data */ - if (jcr->acl_data) { + if (have_acl && jcr->acl_data) { free_pool_memory(jcr->acl_data); jcr->acl_data = NULL; } - if (jcr->xattr_data) { + if (have_xattr && jcr->xattr_data) { free_pool_memory(jcr->xattr_data); jcr->xattr_data = NULL; } @@ -580,23 +596,21 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) #endif /* - * Save ACLs for anything not being a symlink and not being a plugin. + * Save ACLs when requested and available for anything not being a symlink and not being a plugin. */ - if (!ff_pkt->cmd_plugin) { - if (ff_pkt->flags & FO_ACL && ff_pkt->type != FT_LNK) { - if (!build_acl_streams(jcr, ff_pkt)) - goto bail_out; - } + if (ff_pkt->flags & FO_ACL && have_acl && + ff_pkt->type != FT_LNK && !ff_pkt->cmd_plugin) { + if (!build_acl_streams(jcr, ff_pkt)) + goto bail_out; } /* - * Save Extended Attributes for all files not being a plugin. + * Save Extended Attributes when requested and available for all files not being a plugin. */ - if (!ff_pkt->cmd_plugin) { - if (ff_pkt->flags & FO_XATTR) { - if (!build_xattr_streams(jcr, ff_pkt)) - goto bail_out; - } + if (ff_pkt->flags & FO_XATTR && have_xattr && + !ff_pkt->cmd_plugin) { + if (!build_xattr_streams(jcr, ff_pkt)) + goto bail_out; } /* Terminate the signing digest and send it to the Storage daemon */ diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 4d825499ee..c91f2135fa 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -44,6 +44,22 @@ static pthread_mutex_t vss_mutex = PTHREAD_MUTEX_INITIALIZER; static int enable_vss = 0; #endif +/* + * As Windows saves ACLs as part of the standard backup stream + * we just pretend here that is has implicit acl support. + */ +#if defined(HAVE_ACL) || defined(HAVE_WIN32) +const bool have_acl = true; +#else +const bool have_acl = false; +#endif + +#if defined(HAVE_XATTR) +const bool have_xattr = true; +#else +const bool have_xattr = false; +#endif + extern CLIENT *me; /* our client resource */ /* Imported functions */ @@ -196,7 +212,7 @@ static char read_close[] = "read close session %d\n"; * 5. FD gets/runs ClientRunBeforeJob and sends ClientRunAfterJob * 6. Dir sends include/exclude * 7. FD sends data to SD - * 8. SD/FD disconnects while SD despools data and attributes (optionnal) + * 8. SD/FD disconnects while SD despools data and attributes (optional) * 9. FD runs ClientRunAfterJob */ @@ -1439,6 +1455,19 @@ static int backup_cmd(JCR *jcr) } #endif + /* + * Validate some options given to the backup make sense for the compiled in + * options of this filed. + */ + if (jcr->ff->flags & FO_ACL && !have_acl) { + Jmsg(jcr, M_FATAL, 0, _("ACL support not configured for your machine.\n")); + goto cleanup; + } + if (jcr->ff->flags & FO_XATTR && !have_xattr) { + Jmsg(jcr, M_FATAL, 0, _("XATTR support not configured for your machine.\n")); + goto cleanup; + } + set_jcr_job_status(jcr, JS_Blocked); jcr->set_JobType(JT_BACKUP); Dmsg1(100, "begin backup ff=%p\n", jcr->ff); diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index e85fcb770b..e24abdf3f5 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -57,9 +57,9 @@ const bool have_acl = false; #endif #ifdef HAVE_SHA2 - const bool have_sha2 = true; +const bool have_sha2 = true; #else - const bool have_sha2 = false; +const bool have_sha2 = false; #endif #if defined(HAVE_XATTR) @@ -250,8 +250,12 @@ void do_restore(JCR *jcr) binit(&rctx.bfd); binit(&rctx.forkbfd); attr = rctx.attr = new_attr(jcr); - jcr->acl_data = get_pool_memory(PM_MESSAGE); - jcr->xattr_data = get_pool_memory(PM_MESSAGE); + if (have_acl) { + jcr->acl_data = get_pool_memory(PM_MESSAGE); + } + if (have_xattr) { + jcr->xattr_data = get_pool_memory(PM_MESSAGE); + } while (bget_msg(sd) >= 0 && !job_canceled(jcr)) { /* Remember previous stream type */ @@ -733,11 +737,11 @@ ok_out: jcr->compress_buf_size = 0; } - if (jcr->xattr_data) { + if (have_xattr && jcr->xattr_data) { free_pool_memory(jcr->xattr_data); jcr->xattr_data = NULL; } - if (jcr->acl_data) { + if (have_acl && jcr->acl_data) { free_pool_memory(jcr->acl_data); jcr->acl_data = NULL; } diff --git a/bacula/src/filed/xattr.c b/bacula/src/filed/xattr.c index 6c67839806..99f9bbb63b 100644 --- a/bacula/src/filed/xattr.c +++ b/bacula/src/filed/xattr.c @@ -47,32 +47,20 @@ #include "filed.h" #include "xattr.h" +#if !defined(HAVE_XATTR) /* - * List of supported OSes. Everything outside that gets stub functions. - * Also when XATTR support is explicitly disabled. + * Entry points when compiled without support for XATTRs or on an unsupported platform. */ -#if !defined(HAVE_XATTR) /* Extended Attributes support is required, of course */ \ - || !( defined(HAVE_DARWIN_OS) /* OSX has XATTR support using getxattr etc. */ \ - || defined(HAVE_FREEBSD_OS) /* FreeBSD has XATTR support using lgetxattr etc. */ \ - || defined(HAVE_LINUX_OS) /* Linux has XATTR support using the lgetxattr etc. */ \ - || defined(HAVE_NETBSD_OS) /* NetBSD has XATTR support using the lgetxattr etc. */ \ - || defined(HAVE_SUN_OS) /* Solaris has XATTR support using attropen etc. */ \ - ) - bool build_xattr_streams(JCR *jcr, FF_PKT *ff_pkt) { - Jmsg(jcr, M_FATAL, 0, _("XATTR support not configured for your machine.\n")); return false; } bool parse_xattr_stream(JCR *jcr, int stream) { - Jmsg(jcr, M_FATAL, 0, _("XATTR support not configured for your machine.\n")); return false; } - #else - /* * Send a XATTR stream to the SD. */ @@ -713,7 +701,7 @@ static void add_xattr_link_cache_entry(ino_t inum, char *target) if (xattr_link_cache_head == NULL) { xattr_link_cache_head = ptr; } - if (xattr_link_cache_tail != NULL) + if (xattr_link_cache_tail != NULL) { xattr_link_cache_tail->next = ptr; } } @@ -1383,8 +1371,8 @@ static bool solaris_restore_xattr_acl(JCR *jcr, int fd, const char *attrname, ch acl_t *aclp = NULL; if ((error = acl_fromtext(acl_text, &aclp)) != 0) { - Jmsg1(jcr, M_ERROR, 0, _("Unable to convert acl from text on file \"%s\"\n" - jcr->last_fname)); + Jmsg1(jcr, M_ERROR, 0, _("Unable to convert acl from text on file \"%s\"\n"), + jcr->last_fname); return true; /* non-fatal */ } diff --git a/bacula/technotes b/bacula/technotes index 08670e550e..0e52abe7be 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -2,6 +2,12 @@ General: +04Jul09 +mvw Change checking for acl and xattr support from first file to + job level. +mvw Call acl and xattr function only when requested for fileset + and filed has support for acl or xattr +mvw Fix typo introduces by fix for bug #1305 03Jul09 ebl Should fix the first part #1323 about the restore option "List Jobs where a given File is saved" wich display deleted files