vfs_fruit: handling of ftruncate() on AFP_AfpInfo stream
authorRalph Boehme <slow@samba.org>
Mon, 14 Dec 2015 15:09:54 +0000 (16:09 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 21 Dec 2015 22:21:17 +0000 (23:21 +0100)
With help of some torture tests I verified the following behaviour of OS
X SMB server:

* ftruncate AFP_AfpInfo stream > 60 bytes results in an error
  NT_STATUS_ALLOTTED_SPACE_EXCEEDED

* ftruncate AFP_AfpInfo stream <=60 returns success but has no effect

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

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

index 4a42eaf784deec6083c3ddf909630bb8811e2c47..ff19b6dbead6224ad896de4e4b189d99e918b49c 100644 (file)
@@ -3271,19 +3271,23 @@ static int fruit_ftruncate_meta(struct vfs_handle_struct *handle,
                                off_t offset,
                                struct adouble *ad)
 {
-       /*
-        * As this request hasn't been seen in the wild,
-        * the only sensible use I can imagine is the client
-        * truncating the stream to 0 bytes size.
-        * We simply remove the metadata on such a request.
-        */
-       if (offset != 0) {
+       struct fruit_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct fruit_config_data, return -1);
+
+       if (offset > 60) {
                DBG_WARNING("ftruncate %s to %jd",
                            fsp_str_dbg(fsp), (intmax_t)offset);
+               /* OS X returns NT_STATUS_ALLOTTED_SPACE_EXCEEDED  */
+               errno = EOVERFLOW;
                return -1;
        }
 
-       return SMB_VFS_FREMOVEXATTR(fsp, AFPRESOURCE_EA_NETATALK);
+       DBG_WARNING("ignoring ftruncate %s to %jd",
+                   fsp_str_dbg(fsp), (intmax_t)offset);
+       /* OS X returns success but does nothing  */
+       return 0;
 }
 
 static int fruit_ftruncate_rsrc(struct vfs_handle_struct *handle,