vfs_fruit: store filler bytes from AppleDouble file header in struct adouble
authorRalph Boehme <slow@samba.org>
Fri, 5 Oct 2018 13:12:44 +0000 (15:12 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 10 Oct 2018 20:22:13 +0000 (22:22 +0200)
This can later be used to distinguish between macOS created AppleDouble
files and AppleDouble files created by Samba or Netatalk.

macOS:    "Mac OS X        "
Samba:    "Netatalk        "
Netatalk: "Netatalk        "

Bug: https://bugzilla.samba.org/show_bug.cgi?id=13649

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_fruit.c

index 65d6618ff2d908781d09376102a289aa6a0a7af3..057e4e4265b272ec5b4940aedc5f5265fd186a70 100644 (file)
@@ -262,6 +262,7 @@ typedef enum {ADOUBLE_META, ADOUBLE_RSRC} adouble_type_t;
 #define ADEDLEN_VERSION     4
 #define ADEDLEN_FILLER      16
 #define AD_FILLER_TAG       "Netatalk        " /* should be 16 bytes */
 #define ADEDLEN_VERSION     4
 #define ADEDLEN_FILLER      16
 #define AD_FILLER_TAG       "Netatalk        " /* should be 16 bytes */
+#define AD_FILLER_TAG_OSX   "Mac OS X        " /* should be 16 bytes */
 #define ADEDLEN_NENTRIES    2
 #define AD_HEADER_LEN       (ADEDLEN_MAGIC + ADEDLEN_VERSION + \
                             ADEDLEN_FILLER + ADEDLEN_NENTRIES) /* 26 */
 #define ADEDLEN_NENTRIES    2
 #define AD_HEADER_LEN       (ADEDLEN_MAGIC + ADEDLEN_VERSION + \
                             ADEDLEN_FILLER + ADEDLEN_NENTRIES) /* 26 */
@@ -414,6 +415,7 @@ struct adouble {
        adouble_type_t            ad_type;
        uint32_t                  ad_magic;
        uint32_t                  ad_version;
        adouble_type_t            ad_type;
        uint32_t                  ad_magic;
        uint32_t                  ad_version;
+       uint8_t                   ad_filler[ADEDLEN_FILLER];
        struct ad_entry           ad_eid[ADEID_MAX];
        char                     *ad_data;
        struct ad_xattr_header    adx_header;
        struct ad_entry           ad_eid[ADEID_MAX];
        char                     *ad_data;
        struct ad_xattr_header    adx_header;
@@ -837,6 +839,8 @@ static bool ad_unpack(struct adouble *ad, const size_t nentries,
                return false;
        }
 
                return false;
        }
 
+       memcpy(ad->ad_filler, ad->ad_data + ADEDOFF_FILLER, ADEDLEN_FILLER);
+
        adentries = RSVAL(ad->ad_data, ADEDOFF_NENTRIES);
        if (adentries != nentries) {
                DEBUG(1, ("invalid number of entries: %zu\n",
        adentries = RSVAL(ad->ad_data, ADEDOFF_NENTRIES);
        if (adentries != nentries) {
                DEBUG(1, ("invalid number of entries: %zu\n",