]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/unix.c
- better error reporting, don't always return noobj.
[netatalk.git] / etc / afpd / unix.c
index c8bb933aa7305a015987492bdb136bc7645d6aeb..fa0ee0a722f0a37abe731603cd03e25c486f27e6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: unix.c,v 1.40 2003-01-07 15:55:22 rlewczuk Exp $
+ * $Id: unix.c,v 1.41 2003-01-08 15:01:36 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -123,7 +123,6 @@ struct stat         *stat;
 struct maccess *ma;
 {
 mode_t mode;
-int    ok = 0;
 
     mode = stat->st_mode;
     ma->ma_world = utombits( mode );
@@ -134,32 +133,18 @@ int    ok = 0;
 
     ma->ma_owner = utombits( mode );
 
-    /* ma_user is a union of all permissions */
-    ma->ma_user = 0;
+    /* ma_user is a union of all permissions but we must follow
+     * unix perm
+    */
     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;
+    else if ( gmem( stat->st_gid )) {
+        ma->ma_user = ma->ma_group;
+    }
+    else {
+        ma->ma_user = ma->ma_world;
+    }
 
     /*
      * There are certain things the mac won't try if you don't have
@@ -425,7 +410,7 @@ const int dropbox;
             continue;
         }
 
-        if (S_ISREG(st.st_mode)) {
+        if (!S_ISDIR(st.st_mode)) {
            if (setfilmode(dirp->d_name, mode, &st) < 0) {
                 LOG(log_error, logtype_afpd, "setdirmode: chmod %s: %s",
                     dirp->d_name, strerror(errno) );
@@ -467,7 +452,7 @@ const int dropbox;
             LOG(log_error, logtype_afpd, "setdirmode: stat %s: %s", buf, strerror(errno) );
             continue;
         }
-        if (S_ISREG(st.st_mode)) {
+        if (!S_ISDIR(st.st_mode)) {
            if (setfilmode(buf, ad_hf_mode(mode), &st) < 0) {
                /* FIXME what do we do then? */
            }