#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);
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 = (acl_data_t *)malloc(sizeof(acl_data_t));
+ memset((caddr_t)jcr->acl_data, 0, sizeof(acl_data_t));
+ jcr->acl_data->content = get_pool_memory(PM_MESSAGE);
+ }
+
+ if (have_xattr) {
+ jcr->xattr_data = (xattr_data_t *)malloc(sizeof(xattr_data_t));
+ memset((caddr_t)jcr->xattr_data, 0, sizeof(xattr_data_t));
+ jcr->xattr_data->content = 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)) {
set_jcr_job_status(jcr, JS_ErrorTerminated);
}
+ if (have_acl && jcr->acl_data->nr_errors > 0) {
+ Jmsg(jcr, M_ERROR, 0, _("Encountered %ld acl errors while doing backup\n"),
+ jcr->acl_data->nr_errors);
+ }
+ if (have_xattr && jcr->xattr_data->nr_errors > 0) {
+ Jmsg(jcr, M_ERROR, 0, _("Encountered %ld xattr errors while doing backup\n"),
+ jcr->xattr_data->nr_errors);
+ }
+
accurate_send_deleted_list(jcr); /* send deleted list to SD */
stop_heartbeat_monitor(jcr);
sd->signal(BNET_EOD); /* end of sending data */
- if (jcr->acl_data) {
- free_pool_memory(jcr->acl_data);
+ if (have_acl && jcr->acl_data) {
+ free_pool_memory(jcr->acl_data->content);
+ free(jcr->acl_data);
jcr->acl_data = NULL;
}
- if (jcr->xattr_data) {
- free_pool_memory(jcr->xattr_data);
+ if (have_xattr && jcr->xattr_data) {
+ free_pool_memory(jcr->xattr_data->content);
+ free(jcr->xattr_data);
jcr->xattr_data = NULL;
}
if (jcr->big_buf) {
#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))
+ if (have_acl) {
+ if (ff_pkt->flags & FO_ACL && ff_pkt->type != FT_LNK && !ff_pkt->cmd_plugin) {
+ switch (build_acl_streams(jcr, ff_pkt)) {
+ case bacl_exit_fatal:
goto bail_out;
+ case bacl_exit_error:
+ /*
+ * Non-fatal errors, count them and when the number is under ACL_REPORT_ERR_MAX_PER_JOB
+ * print the error message set by the lower level routine in jcr->errmsg.
+ */
+ if (jcr->acl_data->nr_errors < ACL_REPORT_ERR_MAX_PER_JOB) {
+ Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
+ }
+ jcr->acl_data->nr_errors++;
+ break;
+ case bacl_exit_ok:
+ break;
+ }
}
}
/*
- * 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))
+ if (have_xattr) {
+ if (ff_pkt->flags & FO_XATTR && !ff_pkt->cmd_plugin) {
+ switch (build_xattr_streams(jcr, ff_pkt)) {
+ case bxattr_exit_fatal:
goto bail_out;
+ case bxattr_exit_error:
+ /*
+ * Non-fatal errors, count them and when the number is under XATTR_REPORT_ERR_MAX_PER_JOB
+ * print the error message set by the lower level routine in jcr->errmsg.
+ */
+ if (jcr->xattr_data->nr_errors < XATTR_REPORT_ERR_MAX_PER_JOB) {
+ Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg);
+ }
+ jcr->xattr_data->nr_errors++;
+ break;
+ case bxattr_exit_ok:
+ break;
+ }
}
}
* <file-index> <stream> <info>
*/
if (!sd->fsend("%ld %d 0", jcr->JobFiles, stream)) {
- Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
- sd->bstrerror());
+ if (!job_canceled(jcr)) {
+ Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+ sd->bstrerror());
+ }
goto err;
}
Dmsg1(300, ">stored: datahdr %s\n", sd->msg);
}
sd->msg = wbuf; /* set correct write buffer */
if (!sd->send()) {
- Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
- sd->bstrerror());
+ if (!job_canceled(jcr)) {
+ Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+ sd->bstrerror());
+ }
goto err;
}
Dmsg1(130, "Send data to SD len=%d\n", sd->msglen);
sd->msglen = encrypted_len; /* set encrypted length */
sd->msg = jcr->crypto.crypto_buf; /* set correct write buffer */
if (!sd->send()) {
- Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
- sd->bstrerror());
+ if (!job_canceled(jcr)) {
+ Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+ sd->bstrerror());
+ }
goto err;
}
Dmsg1(130, "Send data to SD len=%d\n", sd->msglen);
}
if (!sd->signal(BNET_EOD)) { /* indicate end of file data */
- Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
- sd->bstrerror());
+ if (!job_canceled(jcr)) {
+ Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+ sd->bstrerror());
+ }
goto err;
}
* <file-index> <stream> <info>
*/
if (!sd->fsend("%ld %d 0", jcr->JobFiles, attr_stream)) {
- Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
- sd->bstrerror());
+ if (!job_canceled(jcr)) {
+ Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+ sd->bstrerror());
+ }
return false;
}
Dmsg1(300, ">stored: attrhdr %s\n", sd->msg);
Dmsg2(300, ">stored: attr len=%d: %s\n", sd->msglen, sd->msg);
if (!stat) {
- Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
- sd->bstrerror());
+ if (!job_canceled(jcr)) {
+ Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
+ sd->bstrerror());
+ }
return false;
}
sd->signal(BNET_EOD); /* indicate end of attributes data */