]> arthur.barton.de Git - netatalk.git/commitdiff
possible partiel fix for endless loop (broken pipe) and endless refresh.
authordidg <didg>
Sat, 14 Dec 2002 04:01:01 +0000 (04:01 +0000)
committerdidg <didg>
Sat, 14 Dec 2002 04:01:01 +0000 (04:01 +0000)
etc/afpd/directory.c
etc/afpd/unix.c

index 28e9be7d46a1fba7eb530969b024981c5fc20440..1bc84cbe74f9f70d992a72a3410f29e089de783a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.52 2002-11-26 08:22:38 didg Exp $
+ * $Id: directory.c,v 1.53 2002-12-14 04:01:01 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -857,15 +857,18 @@ char      **cpath;
         if ( len == 0 ) {
             if ( !extend && movecwd( vol, dir ) < 0 ) {
                /* it's tricky:
-                  movecwd failed so dir is not there anymore.
+                  movecwd failed some of dir path is not there anymore.
                   FIXME Is it true with other errors?
                   if path == '\0' ==> the cpath parameter is that dir,
                   and maybe we are trying to recreate it! So we can't 
                   fail here.
                   
                */
-                   if ( dir->d_did == DIRDID_ROOT_PARENT) 
-                               return NULL;                    
+               if (dir->d_did == DIRDID_ROOT_PARENT) 
+                       return NULL;
+               if (errno != ENOENT && errno != ENOTDIR)
+                   return NULL;                
+
                cdir = dir->d_parent;
                dir_invalidate(vol, dir);
                if (*path != '\0' || u == NULL) {
@@ -943,8 +946,10 @@ char       **cpath;
                        /* dir is not valid anymore 
                           we delete dir from the cache and abort.
                        */
-                       if ( dir->d_did != DIRDID_ROOT_PARENT) 
+                       if ( dir->d_did != DIRDID_ROOT_PARENT && 
+                             (errno == ENOENT || errno == ENOTDIR)) {
                            dir_invalidate(vol, dir);
+                       }
                         return NULL;
                     }
                     cdir = extenddir( vol, dir, &ret );
@@ -955,6 +960,7 @@ char        **cpath;
             }
 
             if ( cdir == NULL ) {
+
                 if ( len > 0 ) {
                     return NULL;
                 }
@@ -983,6 +989,7 @@ struct dir  *dir;
         return( 0 );
     }
     if ( dir->d_did == DIRDID_ROOT_PARENT) {
+        errno = 0;     /* errno is checked in file.c */
         return( -1 );
     }
 
index 13db7e5d1491ab3b07392a5756041908357cd840..cf4b10e26761c6bfbb7889dfd4b32d1be75e5cd9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.c,v 1.38 2002-09-29 15:42:14 didg Exp $
+ * $Id: unix.c,v 1.39 2002-12-14 04:01:01 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -123,6 +123,7 @@ struct stat         *stat;
 struct maccess *ma;
 {
 mode_t mode;
+int    ok = 0;
 
     mode = stat->st_mode;
     ma->ma_world = utombits( mode );
@@ -136,11 +137,28 @@ mode_t mode;
     /* ma_user is a union of all permissions */
     ma->ma_user = 0;
     if ( (uuid == stat->st_uid) || (uuid == 0)) {
+        ok = 1;
         ma->ma_user = ma->ma_owner | AR_UOWN;
     }
     if ( gmem( stat->st_gid )) {
+        ok = 1;
         ma->ma_user |= ma->ma_group;
     } 
+    if (ok) {
+       /* We are the directory owner or we are in the group owner.
+        * If we don't have a perm we need to remove it from ma_world.
+        *
+        * eg if perms are rwx--Sr-x and I'm not the user owner but I'm in the group
+        * I DON'T have read and search access on the directory.
+       */
+       if (!(ma->ma_user & AR_UWRITE))
+          ma->ma_world &= ~AR_UWRITE;
+       if (!(ma->ma_user & AR_UREAD))
+          ma->ma_world &= ~AR_UREAD;
+       if (!(ma->ma_user & AR_USEARCH))
+          ma->ma_world &= ~AR_USEARCH;
+    }
+
     ma->ma_user |= ma->ma_world;
 
     /*
@@ -164,6 +182,7 @@ mode_t mode;
  *
  * Note: the previous method, using access(), does not work correctly
  * over NFS.
+ * FIXME what about ACL?
  */
 void accessmode( path, ma, dir, st )
 char           *path;