]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/acls.c
Merge master
[netatalk.git] / etc / afpd / acls.c
index 60c95a5166bbc4bee3a505ef69098ca2a12bb97e..40281bcc9b079260922af9db90b38a0c879f5069 100644 (file)
@@ -550,6 +550,7 @@ static int posix_acls_to_uaperms(const char *path, struct stat *sb, struct macce
     acl_t acl = NULL;
     uid_t *uid;
     gid_t *gid;
+    uid_t whoami = geteuid();
 
     u_char group_rights = 0x00;
     u_char acl_rights = 0x00;
@@ -566,7 +567,7 @@ static int posix_acls_to_uaperms(const char *path, struct stat *sb, struct macce
             case ACL_USER:
                 EC_NULL_LOG(uid = (uid_t *)acl_get_qualifier(entry));
 
-                if (*uid == uuid) {
+                if (*uid == uuid && !(whoami == sb->st_uid)) {
                     LOG(log_maxdebug, logtype_afpd, "ACL_USER: %u", *uid);
                     acl_rights |= acl_permset_to_uarights(entry);
                 }
@@ -577,14 +578,14 @@ static int posix_acls_to_uaperms(const char *path, struct stat *sb, struct macce
                 group_rights = acl_permset_to_uarights(entry);
                 LOG(log_maxdebug, logtype_afpd, "ACL_GROUP_OBJ: %u", sb->st_gid);
 
-                if (gmem(sb->st_gid))
+                if (gmem(sb->st_gid) && !(whoami == sb->st_uid))
                     acl_rights |= group_rights;
                 break;
 
             case ACL_GROUP:
                 EC_NULL_LOG(gid = (gid_t *)acl_get_qualifier(entry));
 
-                if (gmem(*gid)) {
+                if (gmem(*gid) && !(whoami == sb->st_uid)) {
                     LOG(log_maxdebug, logtype_afpd, "ACL_GROUP: %u", *gid);
                     acl_rights |= acl_permset_to_uarights(entry);
                 }
@@ -984,7 +985,7 @@ static int get_and_map_acl(char *name, char *rbuf, size_t *rbuflen)
     EC_INIT;
     int mapped_aces = 0;
     int dirflag;
-    uint32_t *darwin_ace_count = (u_int32_t *)rbuf;
+    uint32_t *darwin_ace_count = (uint32_t *)rbuf;
 #ifdef HAVE_SOLARIS_ACLS
     int ace_count = 0;
     ace_t *aces = NULL;
@@ -1430,7 +1431,7 @@ static int check_acl_access(const struct vol *vol,
             if (allowed_rights & DARWIN_ACE_ADD_SUBDIRECTORY)
                 allowed_rights |= DARWIN_ACE_DELETE;
 
-            dir->d_rights_cache = allowed_rights;
+            curdir->d_rights_cache = allowed_rights;
         }
         LOG(log_debug, logtype_afpd, "allowed rights: 0x%08x", allowed_rights);
     }
@@ -1715,14 +1716,13 @@ int afp_setacl(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size
  * This is the magic function that makes ACLs usable by calculating
  * the access granted by ACEs to the logged in user.
  */
-int acltoownermode(char *path, struct stat *st, struct maccess *ma)
+int acltoownermode(const struct vol *vol, char *path, struct stat *st, struct maccess *ma)
 {
     EC_INIT;
     uint32_t rights = 0;
 
     if ( ! (AFPobj->options.flags & OPTION_ACL2MACCESS)
-         || (current_vol == NULL)
-         || ! (current_vol->v_flags & AFPVOL_ACLS))
+         || ! (vol->v_flags & AFPVOL_ACLS))
          return 0;
 
     LOG(log_maxdebug, logtype_afpd, "acltoownermode(\"%s/%s\", 0x%02x)",