]> arthur.barton.de Git - netatalk.git/commitdiff
Return correct user/group type when mapping UUIDs to names.
authorFrank Lahm <franklahm@googlemail.com>
Fri, 12 Aug 2011 07:24:46 +0000 (09:24 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Fri, 12 Aug 2011 07:24:46 +0000 (09:24 +0200)
For directories add DARWIN_ACE_DELETE ACE if DARWIN_ACE_ADD_SUBDIRECTORY is set.
From Laura Müller.

NEWS
etc/afpd/acls.c
etc/afpd/directory.c
include/atalk/uuid.h
libatalk/acl/uuid.c

diff --git a/NEWS b/NEWS
index 081a34d3cc3ec17a201e7f4b5931315ce0abf0b8..06d9875af9c8b295f2f5b0b6079976a0bd12d0d2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,9 @@ Changes in 2.2.1
 * FIX: afpd: .volinfo file not created on first volume access if user in rolist
 * FIX: afpd: possible crash at startup when registering with Avahi when Avahi is
        not running
+* FIX: afpd: return correct user/group type when mapping UUIDs to names
+* FIX: afpd: for directories add DARWIN_ACE_DELETE ACE if DARWIN_ACE_ADD_SUBDIRECTORY
+       is set
 * FIX: cnid_dbd: increase BerkeleyDB locks and lockobjs
 * FIX: cnid_dbd: implement -d option, deletes CNID db
 * FIX: suse: initscript return better status
index b27b90b0448deb46d48b8af75de5e72f67b64651..c55f8c06919143a9cf5aedfee3810b063b33f532 100644 (file)
@@ -1168,6 +1168,7 @@ static int check_acl_access(const struct vol *vol,
     uuidtype_t     uuidtype;
     struct stat    st;
     bstring        parent = NULL;
+    int            is_dir;
 
     LOG(log_maxdebug, logtype_afpd, "check_acl_access(dir: \"%s\", path: \"%s\", curdir: \"%s\", 0x%08x)",
         cfrombstr(dir->d_fullpath), path, getcwdpath(), requested_rights);
@@ -1188,7 +1189,9 @@ static int check_acl_access(const struct vol *vol,
         goto EC_CLEANUP;
     }
 
-    if ((strcmp(path, ".") == 0) && (curdir->d_rights_cache != 0xffffffff)) {
+    is_dir = !strcmp(path, ".");
+
+    if (is_dir && (curdir->d_rights_cache != 0xffffffff)) {
         /* its a dir and the cache value is valid */
         allowed_rights = curdir->d_rights_cache;
         LOG(log_debug, logtype_afpd, "check_access: allowed rights from dircache: 0x%08x", allowed_rights);
@@ -1230,13 +1233,22 @@ static int check_acl_access(const struct vol *vol,
             EC_ZERO_LOG(solaris_acl_rights(cfrombstr(parent), &st, &parent_rights));
 #endif
 #ifdef HAVE_POSIX_ACLS
-            EC_ZERO_LOG(posix_acl_rights(path, &st, &allowed_rights));
+            EC_ZERO_LOG(posix_acl_rights(path, &st, &parent_rights));
 #endif
             if (parent_rights & (DARWIN_ACE_WRITE_DATA | DARWIN_ACE_DELETE_CHILD))
                 allowed_rights |= DARWIN_ACE_DELETE; /* man, that was a lot of work! */
         }
+
+        if (is_dir) {
+            /* Without DARWIN_ACE_DELETE set OS X 10.6 refuses to rename subdirectories in a
+             * directory.
+             */
+            if (allowed_rights & DARWIN_ACE_ADD_SUBDIRECTORY)
+                allowed_rights |= DARWIN_ACE_DELETE;
+
+            dir->d_rights_cache = allowed_rights;
+        }
         LOG(log_debug, logtype_afpd, "allowed rights: 0x%08x", allowed_rights);
-        curdir->d_rights_cache = allowed_rights;
     }
 
     if ((requested_rights & allowed_rights) != requested_rights) {
index 7505ca646bd8907ddc64d79c1053760b4245c980..3d10cf6bb4e80025a576e479a7088fc063c4b7e4 100644 (file)
@@ -2604,12 +2604,12 @@ int afp_mapname(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, siz
 
         case 2 : /* unicode */
         case 4 :
-            LOG(log_debug, logtype_afpd, "afp_mapname: gettgrnam for name: %s",ibuf);
+            LOG(log_debug, logtype_afpd, "afp_mapname: getgrnam for name: %s",ibuf);
             if (NULL == ( gr = (struct group *)getgrnam( ibuf ))) {
                 return( AFPERR_NOITEM );
             }
             id = gr->gr_gid;
-            LOG(log_debug, logtype_afpd, "afp_mapname: gettgrnam for name: %s -> id: %d",ibuf, id);
+            LOG(log_debug, logtype_afpd, "afp_mapname: getgrnam for name: %s -> id: %d",ibuf, id);
             id = htonl(id);
             memcpy( rbuf, &id, sizeof( id ));
             *rbuflen = sizeof( id );
index ebaf2b851d392e9115356a8487eb878f6de60a11..93bad6b31df7358b598e6b72003173d2e0136c5a 100644 (file)
@@ -21,8 +21,8 @@
 typedef unsigned char *uuidp_t;
 typedef unsigned char atalk_uuid_t[UUID_BINSIZE];
 
-typedef enum {UUID_USER   = 0,
-              UUID_GROUP  = 1,
+typedef enum {UUID_USER   = 1,
+              UUID_GROUP  = 2,
               UUID_ENOENT = 4} /* used as bit flag */
     uuidtype_t;
 #define UUIDTYPESTR_MASK 3
index 3bf591e5c07148bb00f2b8a6dde15c1df2d36f5a..7c0cf12e4fec035d9e81808aeeed5d5da49ad8c5 100644 (file)
@@ -33,7 +33,7 @@
 #include "aclldap.h"
 #include "cache.h"
 
-char *uuidtype[] = {"USER", "GROUP", "LOCAL"};
+char *uuidtype[] = {"", "USER", "GROUP", "LOCAL"};
 
 /********************************************************
  * Public helper function