]> arthur.barton.de Git - netatalk.git/commitdiff
Fix #2802236. https://sourceforge.net/support/tracker.php?aid=2802236
authorfranklahm <franklahm>
Fri, 19 Jun 2009 13:38:32 +0000 (13:38 +0000)
committerfranklahm <franklahm>
Fri, 19 Jun 2009 13:38:32 +0000 (13:38 +0000)
etc/afpd/directory.c
etc/afpd/directory.h
include/atalk/adouble.h
libatalk/adouble/ad_attr.c
libatalk/adouble/ad_open.c

index 4abaae91c48593ddbbb4b52f214f7d157aa24135..ad7741a796bd6227f0172b546a28a89cd305fa46 100644 (file)
@@ -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!
index 51e619962f74d629d2248ab3b153200d2eeedc9d..aae48aec2b74c8a698faacca3850732b8084e7cb 100644 (file)
@@ -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 */
 
index c1f293e7ce047cab859aca57120f9a82b8690f85..3d880ed4bd6a9d80c8cda3991c51a5b0b614db37 100644 (file)
@@ -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 */
index 7a4ff2e37b8cd585d065bd6e7bbaddf5fa2ce573..3cd55c5d92015169b0fa9f7f1e26ad105a14ed11 100644 (file)
@@ -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 <directory>. 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 <dir> ) 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
index 043cd1f1629a8fa514128db766fb25db1b6d781f..cd53ba04c24e98418adbf87172856d65205cd732 100644 (file)
@@ -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);