From: Eric Bollengier Date: Mon, 20 Apr 2020 13:43:06 +0000 (+0200) Subject: BEE Backport bacula/src/filed/bxattr_linux.c X-Git-Tag: Release-11.3.2~1860 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=881afbc50245e98632835342eb8da0119e2aaf9e;p=thirdparty%2Fbacula.git BEE Backport bacula/src/filed/bxattr_linux.c This commit is the result of the squash of the following main commits: Author: Eric Bollengier Date: Fri Apr 17 18:33:43 2020 +0200 Update Bacula Systems Copyright Author: Eric Bollengier Date: Wed Sep 18 15:52:58 2019 +0200 Scan for CIFS xattributes on CIFS and CIFS2 filesystems Author: Eric Bollengier Date: Thu Sep 20 17:16:49 2018 +0200 Use xattr_list_append() function to check CIFS attributes Author: Eric Bollengier Date: Fri Jul 6 16:07:20 2018 +0200 Add support for system.cifs_acl extended attribute --- diff --git a/bacula/src/filed/bxattr_linux.c b/bacula/src/filed/bxattr_linux.c index 3b405db5fd..9c9a01cfab 100644 --- a/bacula/src/filed/bxattr_linux.c +++ b/bacula/src/filed/bxattr_linux.c @@ -78,6 +78,9 @@ bRC_BXATTR BXATTR_Linux::os_restore_xattr (JCR *jcr, int stream, char *content, return generic_restore_xattr(jcr, stream); }; +#define CIFS_XATTR "system.cifs_acl" +#define CIFS_XATTR_LEN 15 + /* * Return a list of xattr names in newly allocated pool memory and a length of the allocated buffer. * It allocates a memory with poolmem subroutines every time a function is called, so it must be freed @@ -87,14 +90,22 @@ bRC_BXATTR BXATTR_Linux::os_restore_xattr (JCR *jcr, int stream, char *content, */ bRC_BXATTR BXATTR_Linux::os_get_xattr_names (JCR *jcr, POOLMEM ** pxlist, uint32_t * xlen){ - int len; + int len, len2; POOLMEM * list; + bool append_cifs=false; /* check input data */ if (jcr == NULL || xlen == NULL || pxlist == NULL){ return bRC_BXATTR_inval; } + /* With CIFS and CIFS2, the system.cifs_acl attribute holds the BackupRead + * information, but it is not listed by llistxattr + */ + if (strncmp(get_current_fs(), "cifs", 4) == 0) { + append_cifs = true; + } + /* get the length of the extended attributes */ len = llistxattr(jcr->last_fname, NULL, 0); switch (len){ @@ -118,8 +129,12 @@ bRC_BXATTR BXATTR_Linux::os_get_xattr_names (JCR *jcr, POOLMEM ** pxlist, uint32 break; } case 0: - /* xattr available but empty, skip it */ - return bRC_BXATTR_skip; + if (append_cifs) { /* We have nothing, but the cifs attribute can be hidden */ + len += CIFS_XATTR_LEN + 1; + } else { + /* xattr available but empty, skip it */ + return bRC_BXATTR_skip; + } default: break; } @@ -135,8 +150,8 @@ bRC_BXATTR BXATTR_Linux::os_get_xattr_names (JCR *jcr, POOLMEM ** pxlist, uint32 memset(list, 0, len + 1); /* get the list of extended attributes names for a file */ - len = llistxattr(jcr->last_fname, list, len); - switch (len){ + len2 = llistxattr(jcr->last_fname, list, len); + switch (len2){ case -1: { berrno be; @@ -157,10 +172,13 @@ bRC_BXATTR BXATTR_Linux::os_get_xattr_names (JCR *jcr, POOLMEM ** pxlist, uint32 break; } /* ensure a list is nul terminated */ - list[len] = '\0'; + list[len2] = '\0'; + if (append_cifs) { + len2 = xattr_list_append(list, len2, CIFS_XATTR, CIFS_XATTR_LEN); + } /* setup return data */ *pxlist = list; - *xlen = len; + *xlen = len2; return bRC_BXATTR_ok; };