]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/filed/backup.c
Merge Preben's patch for ACLs and for Mac OS X resource forks.
[bacula/bacula] / bacula / src / filed / backup.c
1 /*
2  *  Bacula File Daemon  backup.c  send file attributes and data
3  *   to the Storage daemon.
4  *
5  *    Kern Sibbald, March MM
6  *
7  *   Version $Id$
8  *
9  */
10 /*
11    Copyright (C) 2000-2005 Kern Sibbald
12
13    This program is free software; you can redistribute it and/or
14    modify it under the terms of the GNU General Public License as
15    published by the Free Software Foundation; either version 2 of
16    the License, or (at your option) any later version.
17
18    This program is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21    General Public License for more details.
22
23    You should have received a copy of the GNU General Public
24    License along with this program; if not, write to the Free
25    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
26    MA 02111-1307, USA.
27
28  */
29
30 #include "bacula.h"
31 #include "filed.h"
32
33 static int save_file(FF_PKT *ff_pkt, void *pkt);
34 static int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, struct CHKSUM *chksum);
35 #ifdef HAVE_ACL
36 static int read_and_send_acl(JCR *jcr, int acltype, int stream);
37 #endif
38
39 /*
40  * Find all the requested files and send them
41  * to the Storage daemon.
42  *
43  * Note, we normally carry on a one-way
44  * conversation from this point on with the SD, simply blasting
45  * data to him.  To properly know what is going on, we
46  * also run a "heartbeat" monitor which reads the socket and
47  * reacts accordingly (at the moment it has nothing to do
48  * except echo the heartbeat to the Director).
49  *
50  */
51 bool blast_data_to_storage_daemon(JCR *jcr, char *addr)
52 {
53    BSOCK *sd;
54    bool ok = true;
55
56    sd = jcr->store_bsock;
57
58    set_jcr_job_status(jcr, JS_Running);
59
60    Dmsg1(300, "bfiled: opened data connection %d to stored\n", sd->fd);
61
62    LockRes();
63    CLIENT *client = (CLIENT *)GetNextRes(R_CLIENT, NULL);
64    UnlockRes();
65    uint32_t buf_size;
66    if (client) {
67       buf_size = client->max_network_buffer_size;
68    } else {
69       buf_size = 0;                   /* use default */
70    }
71    if (!bnet_set_buffer_size(sd, buf_size, BNET_SETBUF_WRITE)) {
72       set_jcr_job_status(jcr, JS_ErrorTerminated);
73       Jmsg(jcr, M_FATAL, 0, _("Cannot set buffer size FD->SD.\n"));
74       return false;
75    }
76
77    jcr->buf_size = sd->msglen;
78    /* Adjust for compression so that output buffer is
79     * 12 bytes + 0.1% larger than input buffer plus 18 bytes.
80     * This gives a bit extra plus room for the sparse addr if any.
81     * Note, we adjust the read size to be smaller so that the
82     * same output buffer can be used without growing it.
83     */
84    jcr->compress_buf_size = jcr->buf_size + ((jcr->buf_size+999) / 1000) + 30;
85    jcr->compress_buf = get_memory(jcr->compress_buf_size);
86
87    Dmsg1(300, "set_find_options ff=%p\n", jcr->ff);
88    set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime);
89    Dmsg0(300, "start find files\n");
90
91    start_heartbeat_monitor(jcr);
92
93    jcr->acl_text = get_pool_memory(PM_MESSAGE);
94
95    /* Subroutine save_file() is called for each file */
96    if (!find_files(jcr, (FF_PKT *)jcr->ff, save_file, (void *)jcr)) {
97       ok = false;                     /* error */
98       set_jcr_job_status(jcr, JS_ErrorTerminated);
99 //    Jmsg(jcr, M_FATAL, 0, _("Find files error.\n"));
100    }
101
102    free_pool_memory(jcr->acl_text);
103
104    stop_heartbeat_monitor(jcr);
105
106    bnet_sig(sd, BNET_EOD);            /* end data connection */
107
108    if (jcr->big_buf) {
109       free(jcr->big_buf);
110       jcr->big_buf = NULL;
111    }
112    if (jcr->compress_buf) {
113       free_pool_memory(jcr->compress_buf);
114       jcr->compress_buf = NULL;
115    }
116    Dmsg1(300, "end blast_data stat=%d\n", ok);
117    return ok;
118 }
119
120 /*
121  * Called here by find() for each file included.
122  *   This is a callback. The original is find_files() above.
123  *
124  *  Send the file and its data to the Storage daemon.
125  *
126  *  Returns: 1 if OK
127  *           0 if error
128  *          -1 to ignore file/directory (not used here)
129  */
130 static int save_file(FF_PKT *ff_pkt, void *vjcr)
131 {
132    char attribs[MAXSTRING];
133    char attribsEx[MAXSTRING];
134    int stat, attr_stream, data_stream;
135    struct CHKSUM chksum;
136    BSOCK *sd;
137    JCR *jcr = (JCR *)vjcr;
138
139    if (job_canceled(jcr)) {
140       return 0;
141    }
142
143    sd = jcr->store_bsock;
144    jcr->num_files_examined++;         /* bump total file count */
145
146    switch (ff_pkt->type) {
147    case FT_LNKSAVED:                  /* Hard linked, file already saved */
148       Dmsg2(130, "FT_LNKSAVED hard link: %s => %s\n", ff_pkt->fname, ff_pkt->link);
149       break;
150    case FT_REGE:
151       Dmsg1(130, "FT_REGE saving: %s\n", ff_pkt->fname);
152       break;
153    case FT_REG:
154       Dmsg1(130, "FT_REG saving: %s\n", ff_pkt->fname);
155       break;
156    case FT_LNK:
157       Dmsg2(130, "FT_LNK saving: %s -> %s\n", ff_pkt->fname, ff_pkt->link);
158       break;
159    case FT_DIRBEGIN:
160       return 1;                       /* not used */
161    case FT_NORECURSE:
162    case FT_NOFSCHG:
163    case FT_INVALIDFS:
164    case FT_DIREND:
165       if (ff_pkt->type == FT_NORECURSE) {
166          Jmsg(jcr, M_INFO, 1, _("     Recursion turned off. Will not descend into %s\n"),
167             ff_pkt->fname);
168       } else if (ff_pkt->type == FT_NOFSCHG) {
169          Jmsg(jcr, M_INFO, 1, _("     File system change prohibited. Will not descend into %s\n"),
170             ff_pkt->fname);
171       } else if (ff_pkt->type == FT_INVALIDFS) {
172          Jmsg(jcr, M_INFO, 1, _("     Disallowed filesystem. Will not descend into %s\n"),
173             ff_pkt->fname);
174       }
175       ff_pkt->type = FT_DIREND;       /* value is used below */
176       Dmsg1(130, "FT_DIR saving: %s\n", ff_pkt->link);
177       break;
178    case FT_SPEC:
179       Dmsg1(130, "FT_SPEC saving: %s\n", ff_pkt->fname);
180       break;
181    case FT_RAW:
182       Dmsg1(130, "FT_RAW saving: %s\n", ff_pkt->fname);
183       break;
184    case FT_FIFO:
185       Dmsg1(130, "FT_FIFO saving: %s\n", ff_pkt->fname);
186       break;
187    case FT_NOACCESS: {
188       berrno be;
189       Jmsg(jcr, M_NOTSAVED, 0, _("     Could not access %s: ERR=%s\n"), ff_pkt->fname,
190          be.strerror(ff_pkt->ff_errno));
191       jcr->Errors++;
192       return 1;
193    }
194    case FT_NOFOLLOW: {
195       berrno be;
196       Jmsg(jcr, M_NOTSAVED, 0, _("     Could not follow link %s: ERR=%s\n"), ff_pkt->fname,
197          be.strerror(ff_pkt->ff_errno));
198       jcr->Errors++;
199       return 1;
200    }
201    case FT_NOSTAT: {
202       berrno be;
203       Jmsg(jcr, M_NOTSAVED, 0, _("     Could not stat %s: ERR=%s\n"), ff_pkt->fname,
204          be.strerror(ff_pkt->ff_errno));
205       jcr->Errors++;
206       return 1;
207    }
208    case FT_DIRNOCHG:
209    case FT_NOCHG:
210       Jmsg(jcr, M_SKIPPED, 1, _("     Unchanged file skipped: %s\n"), ff_pkt->fname);
211       return 1;
212    case FT_ISARCH:
213       Jmsg(jcr, M_NOTSAVED, 0, _("     Archive file not saved: %s\n"), ff_pkt->fname);
214       return 1;
215    case FT_NOOPEN: {
216       berrno be;
217       Jmsg(jcr, M_NOTSAVED, 0, _("     Could not open directory %s: ERR=%s\n"), ff_pkt->fname,
218          be.strerror(ff_pkt->ff_errno));
219       jcr->Errors++;
220       return 1;
221    }
222    default:
223       Jmsg(jcr, M_NOTSAVED, 0,  _("     Unknown file type %d; not saved: %s\n"), ff_pkt->type, ff_pkt->fname);
224       jcr->Errors++;
225       return 1;
226    }
227
228    Dmsg1(130, "bfiled: sending %s to stored\n", ff_pkt->fname);
229
230    /* Find what data stream we will use, then encode the attributes */
231    data_stream = select_data_stream(ff_pkt);
232    encode_stat(attribs, ff_pkt, data_stream);
233
234    /* Now possibly extend the attributes */
235    attr_stream = encode_attribsEx(jcr, attribsEx, ff_pkt);
236
237    Dmsg3(300, "File %s\nattribs=%s\nattribsEx=%s\n", ff_pkt->fname, attribs, attribsEx);
238
239    P(jcr->mutex);
240    jcr->JobFiles++;                    /* increment number of files sent */
241    ff_pkt->FileIndex = jcr->JobFiles;  /* return FileIndex */
242    pm_strcpy(jcr->last_fname, ff_pkt->fname);
243    V(jcr->mutex);
244
245    /*
246     * Send Attributes header to Storage daemon
247     *    <file-index> <stream> <info>
248     */
249    if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, attr_stream)) {
250       Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
251             bnet_strerror(sd));
252       return 0;
253    }
254    Dmsg1(300, ">stored: attrhdr %s\n", sd->msg);
255
256    /*
257     * Send file attributes to Storage daemon
258     *   File_index
259     *   File type
260     *   Filename (full path)
261     *   Encoded attributes
262     *   Link name (if type==FT_LNK or FT_LNKSAVED)
263     *   Encoded extended-attributes (for Win32)
264     *
265     * For a directory, link is the same as fname, but with trailing
266     * slash. For a linked file, link is the link.
267     */
268    if (ff_pkt->type == FT_LNK || ff_pkt->type == FT_LNKSAVED) {
269       Dmsg2(300, "Link %s to %s\n", ff_pkt->fname, ff_pkt->link);
270       stat = bnet_fsend(sd, "%ld %d %s%c%s%c%s%c%s%c", jcr->JobFiles,
271                ff_pkt->type, ff_pkt->fname, 0, attribs, 0, ff_pkt->link, 0,
272                attribsEx, 0);
273    } else if (ff_pkt->type == FT_DIREND) {
274       /* Here link is the canonical filename (i.e. with trailing slash) */
275       stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles,
276                ff_pkt->type, ff_pkt->link, 0, attribs, 0, 0, attribsEx, 0);
277    } else {
278       stat = bnet_fsend(sd, "%ld %d %s%c%s%c%c%s%c", jcr->JobFiles,
279                ff_pkt->type, ff_pkt->fname, 0, attribs, 0, 0, attribsEx, 0);
280    }
281
282    Dmsg2(300, ">stored: attr len=%d: %s\n", sd->msglen, sd->msg);
283    if (!stat) {
284       Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
285             bnet_strerror(sd));
286       return 0;
287    }
288    bnet_sig(sd, BNET_EOD);            /* indicate end of attributes data */
289
290    /*
291     * Setup for signature handling.
292     * Then initialise the file descriptor we use for data and other streams.
293     */
294    chksum_init(&chksum, ff_pkt->flags);
295
296    binit(&ff_pkt->bfd);
297    if (ff_pkt->flags & FO_PORTABLE) {
298       set_portable_backup(&ff_pkt->bfd); /* disable Win32 BackupRead() */
299    }
300    if (ff_pkt->reader) {
301       set_prog(&ff_pkt->bfd, ff_pkt->reader, jcr);
302    }
303
304    /*
305     * Open any file with data that we intend to save, then save it.
306     *
307     * Note, if is_win32_backup, we must open the Directory so that
308     * the BackupRead will save its permissions and ownership streams.
309     */
310    if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) &&
311          ff_pkt->statp.st_size > 0) ||
312          ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO ||
313          (!is_portable_backup(&ff_pkt->bfd) && ff_pkt->type == FT_DIREND)) {
314       btimer_t *tid;
315       if (ff_pkt->type == FT_FIFO) {
316          tid = start_thread_timer(pthread_self(), 60);
317       } else {
318          tid = NULL;
319       }
320       if (bopen(&ff_pkt->bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) {
321          ff_pkt->ff_errno = errno;
322          berrno be;
323          Jmsg(jcr, M_NOTSAVED, 0, _("     Cannot open %s: ERR=%s.\n"), ff_pkt->fname,
324               be.strerror());
325          jcr->Errors++;
326          if (tid) {
327             stop_thread_timer(tid);
328             tid = NULL;
329          }
330          return 1;
331       }
332       if (tid) {
333          stop_thread_timer(tid);
334          tid = NULL;
335       }
336       stat = send_data(jcr, data_stream, ff_pkt, &chksum);
337       bclose(&ff_pkt->bfd);
338       if (!stat) {
339          return 0;
340       }
341    }
342
343 #ifdef HAVE_DARWIN_OS
344    /* Regular files can have resource forks and Finder Info */
345    if (ff_pkt->type != FT_LNKSAVED && (S_ISREG(ff_pkt->statp.st_mode) &&
346             ff_pkt->flags & FO_HFSPLUS)) {
347       if (ff_pkt->hfsinfo.rsrclength > 0) {
348          int flags;
349          if (!bopen_rsrc(&ff_pkt->bfd, ff_pkt->fname, O_RDONLY | O_BINARY, 0) < 0) {
350             ff_pkt->ff_errno = errno;
351             berrno be;
352             Jmsg(jcr, M_NOTSAVED, -1, _("     Cannot open resource fork for %s: ERR=%s.\n"), ff_pkt->fname,
353                   be.strerror());
354             jcr->Errors++;
355             if (is_bopen(&ff_pkt->bfd)) {
356                bclose(&ff_pkt->bfd);
357             }
358             return 1;
359          }
360          flags = ff_pkt->flags;
361          ff_pkt->flags &= ~(FO_GZIP|FO_SPARSE);
362          stat = send_data(jcr, STREAM_MACOS_FORK_DATA, ff_pkt, &chksum);
363          ff_pkt->flags = flags;
364          bclose(&ff_pkt->bfd);
365          if (!stat) {
366             return 0;
367          }
368       }
369
370       Dmsg1(300, "Saving Finder Info for \"%s\"\n", ff_pkt->fname);
371       bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_HFSPLUS_ATTRIBUTES);
372       Dmsg1(300, "bfiled>stored:header %s\n", sd->msg);
373       memcpy(sd->msg, ff_pkt->hfsinfo.fndrinfo, 32);
374       sd->msglen = 32;
375       chksum_update(&chksum, (unsigned char *)sd->msg, sd->msglen);
376       bnet_send(sd);
377       bnet_sig(sd, BNET_EOD);
378    }
379 #endif
380
381 #ifdef HAVE_ACL
382    if (ff_pkt->flags & FO_ACL) {
383       /* Read access ACLs for files, dirs and links */
384       if (!read_and_send_acl(jcr, BACL_TYPE_ACCESS, STREAM_UNIX_ATTRIBUTES_ACCESS_ACL)) {
385          return 0;
386       }
387       /* Directories can have default ACLs too */
388       if (ff_pkt->type == FT_DIREND && (BACL_CAP & BACL_CAP_DEFAULTS_DIR)) {
389          if (!read_and_send_acl(jcr, BACL_TYPE_DEFAULT, STREAM_UNIX_ATTRIBUTES_DEFAULT_ACL)) {
390             return 0;
391          }
392       }
393    }
394 #endif
395
396    /* Terminate any signature and send it to Storage daemon and the Director */
397    if (chksum.updated) {
398       int stream = 0;
399       chksum_final(&chksum);
400       if (chksum.type == CHKSUM_MD5) {
401          stream = STREAM_MD5_SIGNATURE;
402       } else if (chksum.type == CHKSUM_SHA1) {
403          stream = STREAM_SHA1_SIGNATURE;
404       } else {
405          Jmsg1(jcr, M_WARNING, 0, _("Unknown signature type %i.\n"), chksum.type);
406       }
407       if (stream != 0) {
408          bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, stream);
409          Dmsg1(300, "bfiled>stored:header %s\n", sd->msg);
410          memcpy(sd->msg, chksum.signature, chksum.length);
411          sd->msglen = chksum.length;
412          bnet_send(sd);
413          bnet_sig(sd, BNET_EOD);              /* end of checksum */
414       }
415    }
416
417    return 1;
418 }
419
420 /*
421  * Send data read from an already open file descriptor.
422  *
423  * We return 1 on sucess and 0 on errors.
424  *
425  * ***FIXME***
426  * We use ff_pkt->statp.st_size when FO_SPARSE.
427  * Currently this is not a problem as the only other stream, resource forks,
428  * are not handled as sparse files.
429  */
430 int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, struct CHKSUM *chksum)
431 {
432    BSOCK *sd = jcr->store_bsock;
433    uint64_t fileAddr = 0;             /* file address */
434    char *rbuf, *wbuf;
435    int rsize = jcr->buf_size;      /* read buffer size */
436    POOLMEM *msgsave;
437
438    msgsave = sd->msg;
439    rbuf = sd->msg;                    /* read buffer */
440    wbuf = sd->msg;                    /* write buffer */
441
442
443    Dmsg1(300, "Saving data, type=%d\n", ff_pkt->type);
444
445
446 #ifdef HAVE_LIBZ
447    uLong compress_len, max_compress_len = 0;
448    const Bytef *cbuf = NULL;
449
450    if (ff_pkt->flags & FO_GZIP) {
451       if (ff_pkt->flags & FO_SPARSE) {
452          cbuf = (Bytef *)jcr->compress_buf + SPARSE_FADDR_SIZE;
453          max_compress_len = jcr->compress_buf_size - SPARSE_FADDR_SIZE;
454       } else {
455          cbuf = (Bytef *)jcr->compress_buf;
456          max_compress_len = jcr->compress_buf_size; /* set max length */
457       }
458       wbuf = jcr->compress_buf;    /* compressed output here */
459    }
460 #endif
461
462    /*
463     * Send Data header to Storage daemon
464     *    <file-index> <stream> <info>
465     */
466    if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, stream)) {
467       Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
468             bnet_strerror(sd));
469       return 0;
470    }
471    Dmsg1(300, ">stored: datahdr %s\n", sd->msg);
472
473    /*
474     * Make space at beginning of buffer for fileAddr because this
475     *   same buffer will be used for writing if compression if off.
476     */
477    if (ff_pkt->flags & FO_SPARSE) {
478       rbuf += SPARSE_FADDR_SIZE;
479       rsize -= SPARSE_FADDR_SIZE;
480 #ifdef HAVE_FREEBSD_OS
481       /*
482        * To read FreeBSD partitions, the read size must be
483        *  a multiple of 512.
484        */
485       rsize = (rsize/512) * 512;
486 #endif
487    }
488
489    /*
490     * Read the file data
491     */
492    while ((sd->msglen=(uint32_t)bread(&ff_pkt->bfd, rbuf, rsize)) > 0) {
493       int sparseBlock = 0;
494
495       /* Check for sparse blocks */
496       if (ff_pkt->flags & FO_SPARSE) {
497          ser_declare;
498          if (sd->msglen == rsize &&
499              (fileAddr+sd->msglen < (uint64_t)ff_pkt->statp.st_size)) {
500             sparseBlock = is_buf_zero(rbuf, rsize);
501          }
502
503          ser_begin(wbuf, SPARSE_FADDR_SIZE);
504          ser_uint64(fileAddr);     /* store fileAddr in begin of buffer */
505       }
506
507       jcr->ReadBytes += sd->msglen;         /* count bytes read */
508       fileAddr += sd->msglen;
509
510       /* Update checksum if requested */
511       chksum_update(chksum, (unsigned char *)rbuf, sd->msglen);
512
513 #ifdef HAVE_LIBZ
514       /* Do compression if turned on */
515       if (!sparseBlock && ff_pkt->flags & FO_GZIP) {
516          int zstat;
517          compress_len = max_compress_len;
518          Dmsg4(400, "cbuf=0x%x len=%u rbuf=0x%x len=%u\n", cbuf, compress_len,
519             rbuf, sd->msglen);
520          /* NOTE! This call modifies compress_len !!! */
521          if ((zstat=compress2((Bytef *)cbuf, &compress_len,
522                (const Bytef *)rbuf, (uLong)sd->msglen,
523                ff_pkt->GZIP_level)) != Z_OK) {
524             Jmsg(jcr, M_FATAL, 0, _("Compression error: %d\n"), zstat);
525             sd->msg = msgsave;
526             sd->msglen = 0;
527             set_jcr_job_status(jcr, JS_ErrorTerminated);
528             return 0;
529          }
530          Dmsg2(400, "compressed len=%d uncompressed len=%d\n",
531             compress_len, sd->msglen);
532
533          sd->msglen = compress_len;      /* set compressed length */
534       }
535 #endif
536
537       /* Send the buffer to the Storage daemon */
538       if (!sparseBlock) {
539          if (ff_pkt->flags & FO_SPARSE) {
540             sd->msglen += SPARSE_FADDR_SIZE; /* include fileAddr in size */
541          }
542          sd->msg = wbuf;              /* set correct write buffer */
543          if (!bnet_send(sd)) {
544             Jmsg2(jcr, M_FATAL, 0, _("Network send error %d to SD. ERR=%s\n"),
545                   sd->msglen, bnet_strerror(sd));
546             sd->msg = msgsave;     /* restore bnet buffer */
547             sd->msglen = 0;
548             return 0;
549          }
550       }
551       Dmsg1(130, "Send data to SD len=%d\n", sd->msglen);
552       /*          #endif */
553       jcr->JobBytes += sd->msglen;      /* count bytes saved possibly compressed */
554       sd->msg = msgsave;                /* restore read buffer */
555
556    } /* end while read file data */
557
558
559    if (sd->msglen < 0) {
560       berrno be;
561       Jmsg(jcr, M_ERROR, 0, _("Read error on file %s. ERR=%s\n"),
562          ff_pkt->fname, be.strerror(ff_pkt->bfd.berrno));
563    }
564
565    if (!bnet_sig(sd, BNET_EOD)) {        /* indicate end of file data */
566       Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
567             bnet_strerror(sd));
568       return 0;
569    }
570
571    return 1;
572 }
573
574 #ifdef HAVE_ACL
575 /*
576  * Read and send an ACL for the last encountered file.
577  */
578 static int read_and_send_acl(JCR *jcr, int acltype, int stream)
579 {
580    BSOCK *sd = jcr->store_bsock;
581    POOLMEM *msgsave;
582    int len;
583
584    len = bacl_get(jcr, acltype);
585    if (len < 0) {
586       Jmsg1(jcr, M_WARNING, 0, "Error reading ACL of %s\n", jcr->last_fname);
587       return 1;
588    }
589    if (len == 0) {
590       return 1;                       /* no ACL */
591    }
592
593    /* Send header */
594    if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, stream)) {
595       Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
596             bnet_strerror(sd));
597       return 0;
598    }
599
600    /* Send the buffer to the storage deamon */
601    Dmsg2(400, "Backing up ACL type 0x%2x <%s>\n", acltype, jcr->acl_text);
602    msgsave = sd->msg;
603    sd->msg = jcr->acl_text;
604    sd->msglen = len + 1;
605    if (!bnet_send(sd)) {
606       sd->msg = msgsave;
607       sd->msglen = 0;
608       Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
609             bnet_strerror(sd));
610       return 0;
611    }
612
613    jcr->JobBytes += sd->msglen;
614    sd->msg = msgsave;
615    if (!bnet_sig(sd, BNET_EOD)) {
616       Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
617             bnet_strerror(sd));
618       return 0;
619    }
620
621    Dmsg1(200, "ACL of file: %s successfully backed up!\n", jcr->last_fname);
622    return 1;
623 }
624 #endif