From e95598c6afa0b4a40961108da8179cf2b17e0fa2 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 8 Jan 2014 01:30:47 +0100 Subject: [PATCH] Removing ressource fork AppleDouble fails, bug #542 When the AFP client uses FPSetForkParms to set the ressource fork length to 0, Netatalk will call unlink() in ad_rtruncate() in libatalk/adouble/ad_write.c in order to to unlink the files AppleDouble ressource fork. The function ad_rtruncate() gets just the filename as path from the caller, so obviously at this point the caller should have ensured that it had called chdir() to the enclosing directory of the file. Fixes bug #542. --- NEWS | 5 +++++ etc/afpd/fork.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/NEWS b/NEWS index 8ea8c21b..2504a47d 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ Changes in 3.1.1 Bug #537. * UPD: Add support for AFP 3.4. From FR #85. * FIX: Registering with mDNS crashed. Bug #540 +* FIX: Saving from applications like Photoshop may fail, because + removing the ressource fork AppleDouble file failed. Bug #542. Changes in 3.1.0 ================ @@ -27,6 +29,9 @@ Changes in 3.0.7 * UPD: Use dedicated exit code for AFP connections that were dropped by the client right after the TCP handshake * FIX: Workaround for a problem which cannot be advertized by Avahi. Bug #541. +* FIX: Registering with mDNS crashed. Bug #540 +* FIX: Saving from applications like Photoshop may fail, because + removing the ressource fork AppleDouble file failed. Bug #542. Changes in 3.0.6 ================ diff --git a/etc/afpd/fork.c b/etc/afpd/fork.c index 73abb1e9..24284c1d 100644 --- a/etc/afpd/fork.c +++ b/etc/afpd/fork.c @@ -500,6 +500,8 @@ openfork_err: int afp_setforkparams(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf _U_, size_t *rbuflen) { struct ofork *ofork; + struct vol *vol; + struct dir *dir; off_t size; uint16_t ofrefnum, bitmap; int err; @@ -522,6 +524,16 @@ int afp_setforkparams(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf _U_, s return( AFPERR_PARAM ); } + vol = ofork->of_vol; + if ((dir = dirlookup(vol, ofork->of_did)) == NULL) { + LOG(log_error, logtype_afpd, "%s: bad fork did", of_name(ofork)); + return AFPERR_MISC; + } + if (movecwd(vol, dir) != 0) { + LOG(log_error, logtype_afpd, "%s: bad fork directory", dir->d_fullpath); + return AFPERR_MISC; + } + if (ofork->of_vol->v_flags & AFPVOL_RO) return AFPERR_VLOCK; -- 2.39.2