From: franklahm Date: Fri, 19 Jun 2009 13:38:32 +0000 (+0000) Subject: Fix #2802236. https://sourceforge.net/support/tracker.php?aid=2802236 X-Git-Tag: before-ipv6~157 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=d805fe9ecdc9d13b65c5ff586af85ce4ac48b066;ds=sidebyside Fix #2802236. https://sourceforge.net/support/tracker.php?aid=2802236 --- diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index 4abaae91..ad7741a7 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -1,5 +1,5 @@ /* - * $Id: directory.c,v 1.97 2009-04-17 04:24:20 didg Exp $ + * $Id: directory.c,v 1.98 2009-06-19 13:38:32 franklahm Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -2155,6 +2155,10 @@ int setdirparams(const struct vol *vol, break; case DIRPBIT_FINFO : if (isad) { + /* Fixes #2802236 */ + u_int16_t *fflags = (u_int16_t *)(finder_buf + FINDERINFO_FRFLAGOFF); + *fflags &= htons(~FINDERINFO_ISHARED); + /* #2802236 end */ if ( dir->d_did == DIRDID_ROOT ) { /* * Alright, we admit it, this is *really* sick! diff --git a/etc/afpd/directory.h b/etc/afpd/directory.h index 51e61996..aae48aec 100644 --- a/etc/afpd/directory.h +++ b/etc/afpd/directory.h @@ -1,5 +1,5 @@ /* - * $Id: directory.h,v 1.24 2009-04-17 04:24:20 didg Exp $ + * $Id: directory.h,v 1.25 2009-06-19 13:38:33 franklahm Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -125,11 +125,6 @@ extern int path_isadir(struct path *o_path); #define DIRPBIT_PDINFO 13 /* ProDOS Info */ #define DIRPBIT_UNIXPR 15 -/* directory attribute bits (see file.h for other bits) */ -#define ATTRBIT_EXPFOLDER (1 << 1) /* shared point */ -#define ATTRBIT_MOUNTED (1 << 3) /* mounted share point by non-admin */ -#define ATTRBIT_INEXPFOLDER (1 << 4) /* folder in a shared area */ - #define FILDIRBIT_ISDIR (1 << 7) /* is a directory */ #define FILDIRBIT_ISFILE (0) /* is a file */ diff --git a/include/atalk/adouble.h b/include/atalk/adouble.h index c1f293e7..3d880ed4 100644 --- a/include/atalk/adouble.h +++ b/include/atalk/adouble.h @@ -1,5 +1,5 @@ /* - * $Id: adouble.h,v 1.35 2009-06-10 08:37:25 franklahm Exp $ + * $Id: adouble.h,v 1.36 2009-06-19 13:38:33 franklahm Exp $ * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. * @@ -254,16 +254,18 @@ struct ad_fd { struct adouble_fops; struct adouble { - u_int32_t ad_magic; - u_int32_t ad_version; - char ad_filler[ 16 ]; - struct ad_entry ad_eid[ ADEID_MAX ]; - struct ad_fd ad_data_fork, ad_resource_fork, ad_metadata_fork; - struct ad_fd *ad_md; /* either ad_resource or ad_metadata */ - - int ad_flags; + u_int32_t ad_magic; + u_int32_t ad_version; + char ad_filler[ 16 ]; + struct ad_entry ad_eid[ ADEID_MAX ]; + struct ad_fd ad_data_fork, ad_resource_fork, ad_metadata_fork; + struct ad_fd *ad_md; /* either ad_resource or ad_metadata */ + + int ad_flags; /* This really stores version info too (AD_VERSION*) */ + int ad_adflags; /* ad_open flags adflags like ADFLAGS_DIR */ unsigned int ad_inited; int ad_options; + int ad_fileordir; int ad_refcount; /* used in afpd/ofork.c */ off_t ad_rlen; /* ressource fork len with AFP 3.0 the header parameter size is too small. @@ -372,17 +374,17 @@ struct adouble_fops { #define FINDERINFO_FRFLAGOFF 8 /* finderinfo flags */ -#define FINDERINFO_ISONDESK (1) +#define FINDERINFO_ISONDESK (1) /* "d" */ #define FINDERINFO_COLOR (0x0e) -#define FINDERINFO_ISHARED (1<<6) -#define FINDERINFO_HASNOINITS (1<<7) -#define FINDERINFO_HASBEENINITED (1<<8) -#define FINDERINFO_HASCUSTOMICON (1<<10) -#define FINDERINFO_ISSTATIONNERY (1<<11) -#define FINDERINFO_NAMELOCKED (1<<12) -#define FINDERINFO_HASBUNDLE (1<<13) -#define FINDERINFO_INVISIBLE (1<<14) -#define FINDERINFO_ISALIAS (1<<15) +#define FINDERINFO_ISHARED (1<<6) /* "m" */ +#define FINDERINFO_HASNOINITS (1<<7) /* "n" */ +#define FINDERINFO_HASBEENINITED (1<<8) /* "i" */ +#define FINDERINFO_HASCUSTOMICON (1<<10) /* "c" */ +#define FINDERINFO_ISSTATIONNERY (1<<11) /* "t" */ +#define FINDERINFO_NAMELOCKED (1<<12) /* "s" */ +#define FINDERINFO_HASBUNDLE (1<<13) /* "b" */ +#define FINDERINFO_INVISIBLE (1<<14) /* "v" */ +#define FINDERINFO_ISALIAS (1<<15) /* "a" */ #define FINDERINFO_FRVIEWOFF 14 #define FINDERINFO_CUSTOMICON 0x4 @@ -395,16 +397,16 @@ struct adouble_fops { */ /* AFP attributes for files and dirs. (d) = only these are valid for directories */ -#define ATTRBIT_INVISIBLE (1<<0) /* invisible ("v") (d) */ -#define ATTRBIT_MULTIUSER (1<<1) /* multiuser ("m") */ -#define ATTRBIT_SYSTEM (1<<2) /* system ("y") (d) */ +#define ATTRBIT_INVISIBLE (1<<0) /* (d) */ +#define ATTRBIT_MULTIUSER (1<<1) +#define ATTRBIT_SYSTEM (1<<2) /* "y" (d) */ #define ATTRBIT_DOPEN (1<<3) /* data fork already open */ #define ATTRBIT_ROPEN (1<<4) /* resource fork already open */ -#define ATTRBIT_NOWRITE (1<<5) /* write inhibit(v2)/read-only(v1) bit ("") */ -#define ATTRBIT_BACKUP (1<<6) /* backup needed ("") (d) */ -#define ATTRBIT_NORENAME (1<<7) /* rename inhibit ("") (d) */ -#define ATTRBIT_NODELETE (1<<8) /* delete inhibit ("") (d) */ -#define ATTRBIT_NOCOPY (1<<10) /* copy protect ("") */ +#define ATTRBIT_NOWRITE (1<<5) /* "w" write inhibit(v2)/read-only(v1) bit ("") */ +#define ATTRBIT_BACKUP (1<<6) /* "b" (d) */ +#define ATTRBIT_NORENAME (1<<7) /* "r" (d) */ +#define ATTRBIT_NODELETE (1<<8) /* "d" (d) */ +#define ATTRBIT_NOCOPY (1<<10) /* "c" */ #define ATTRBIT_SETCLR (1<<15) /* set/clear bits (d) */ /* AFP attributes for dirs */ diff --git a/libatalk/adouble/ad_attr.c b/libatalk/adouble/ad_attr.c index 7a4ff2e3..3cd55c5d 100644 --- a/libatalk/adouble/ad_attr.c +++ b/libatalk/adouble/ad_attr.c @@ -1,5 +1,5 @@ /* - * $Id: ad_attr.c,v 1.8 2009-06-10 08:37:25 franklahm Exp $ + * $Id: ad_attr.c,v 1.9 2009-06-19 13:38:34 franklahm Exp $ */ #ifdef HAVE_CONFIG_H @@ -41,21 +41,15 @@ int ad_getattr(const struct adouble *ad, u_int16_t *attr) else *attr &= htons(~ATTRBIT_INVISIBLE); /* - Although technically correct to check if its a directory because FINDERINFO_ISHARED and - ATTRBIT_MULTIUSER are only valid then, at least 10.4 doesn't mind and sets FINDERINFO_ISHARED - for directories if told so with e.g. SetFile -a M . The check would cause an - out of sync, so I disabled it. + This one is tricky, I actually got it wrong the first time: + for directories bit 1<<1 is ATTRBIT_EXPFLDR and is NOT opaque ! */ -#if 0 - if ( ! (ad->ad_flags & ADFLAGS_DIR) ) { -#endif + if ( ! (ad->ad_adflags & ADFLAGS_DIR)) { if (fflags & htons(FINDERINFO_ISHARED)) *attr |= htons(ATTRBIT_MULTIUSER); else *attr &= htons(~ATTRBIT_MULTIUSER); -#if 0 } -#endif } } #endif @@ -71,11 +65,15 @@ int ad_getattr(const struct adouble *ad, u_int16_t *attr) int ad_setattr(const struct adouble *ad, const u_int16_t attribute) { u_int16_t *fflags; - u_int16_t hostattr; /* we don't save open forks indicator */ u_int16_t attr = attribute & ~htons(ATTRBIT_DOPEN | ATTRBIT_ROPEN); + /* Proactively (10.4 does indeed try to set ATTRBIT_MULTIUSER (=ATTRBIT_EXPFLDR) + for dirs with SetFile -a M ) disable all flags not defined for dirs. */ + if (ad->ad_adflags & ADFLAGS_DIR) + attr &= ~(ATTRBIT_MULTIUSER | ATTRBIT_NOWRITE | ATTRBIT_NOCOPY); + if (ad->ad_version == AD_VERSION1) { if (ad_getentryoff(ad, ADEID_FILEI)) { memcpy(ad_entry(ad, ADEID_FILEI) + FILEIOFF_ATTR, &attr, @@ -89,23 +87,17 @@ int ad_setattr(const struct adouble *ad, const u_int16_t attribute) /* Now set opaque flags in FinderInfo too */ fflags = (u_int16_t *)ad_entry(ad, ADEID_FINDERI) + FINDERINFO_FRFLAGOFF; - if (hostattr & htons(ATTRBIT_INVISIBLE)) + if (attr & htons(ATTRBIT_INVISIBLE)) *fflags |= htons(FINDERINFO_INVISIBLE); else *fflags &= htons(~FINDERINFO_INVISIBLE); -/* - See above comment at ad_getattr() -*/ -#if 0 - if ( ! (ad->ad_flags & ADFLAGS_DIR) ) { -#endif - if (hostattr & htons(ATTRBIT_MULTIUSER)) + + /* See above comment in ad_getattr() */ + if (attr & htons(ATTRBIT_MULTIUSER)) { + if ( ! (ad->ad_adflags & ADFLAGS_DIR) ) *fflags |= htons(FINDERINFO_ISHARED); - else + } else *fflags &= htons(~FINDERINFO_ISHARED); -#if 0 - } -#endif } } #endif diff --git a/libatalk/adouble/ad_open.c b/libatalk/adouble/ad_open.c index 043cd1f1..cd53ba04 100644 --- a/libatalk/adouble/ad_open.c +++ b/libatalk/adouble/ad_open.c @@ -1,5 +1,5 @@ /* - * $Id: ad_open.c,v 1.41 2009-06-10 08:37:25 franklahm Exp $ + * $Id: ad_open.c,v 1.42 2009-06-19 13:38:34 franklahm Exp $ * * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) * Copyright (c) 1990,1991 Regents of The University of Michigan. @@ -1301,6 +1301,7 @@ int ad_open( path, adflags, oflags, mode, ad ) ad->ad_inited = AD_INITED; ad->ad_refcount = 1; ad->ad_open_forks = 0; + ad->ad_adflags = adflags; } else { ad->ad_open_forks = ((ad->ad_data_fork.adf_refcount > 0) ? ATTRBIT_DOPEN : 0);