]> arthur.barton.de Git - netatalk.git/commitdiff
Dynamic ACL support detection
authorFrank Lahm <franklahm@googlemail.com>
Mon, 1 Nov 2010 06:52:05 +0000 (07:52 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Mon, 1 Nov 2010 06:52:05 +0000 (07:52 +0100)
etc/afpd/acls.c
etc/afpd/acls.h
etc/afpd/volume.c

index 5367dfee9ea5e3fe999da3257efb01b7338970e3..6530384ada3c40e01cc90a329aa06b7ea598bd51 100644 (file)
@@ -1434,6 +1434,10 @@ int afp_setacl(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size
     return ret;
 }
 
+/********************************************************************
+ * ACL funcs interfacing with other parts
+ ********************************************************************/
+
 /*!
  * map ACL to user maccess
  *
@@ -1477,3 +1481,37 @@ int acltoownermode(char *path, struct stat *st, uid_t uid, struct maccess *ma)
 EC_CLEANUP:
     EC_EXIT;
 }
+
+/*!
+ * Check whether a volume supports ACLs
+ *
+ * @param vol  (r) volume
+ *
+ * @returns        0 if not, 1 if yes
+ */
+int check_vol_acl_support(const struct vol *vol)
+{
+    int ret = 1;
+
+#ifdef HAVE_SOLARIS_ACLS
+    ace_t *aces = NULL;
+    if (get_nfsv4_acl(vol->v_path, &aces) == -1)
+        ret = 0;
+#endif
+#ifdef HAVE_POSIX_ACLS
+    acl_t acl = NULL;
+    if ((acl = acl_get_file(vol->v_path, ACL_TYPE_ACCESS)) == NULL)
+        ret = 0;
+#endif
+
+#ifdef HAVE_SOLARIS_ACLS
+    if (aces) free(aces);
+#endif
+#ifdef HAVE_POSIX_ACLS
+    if (acl) acl_free(acl);
+#endif /* HAVE_POSIX_ACLS */
+
+    LOG(log_debug, logtype_afpd, "Volume \"%s\" ACL support: %s",
+        vol->v_path, ret ? "yes" : "no");
+    return ret;
+}
index 97db2b80704850c250f89e31cb8cacfdccc6ff55..cb6f35e736d1ea86b54c2e75e8b024daadaeb1ed 100644 (file)
@@ -114,4 +114,5 @@ extern int acl_ldap_readconfig(char *name);
 
 /* Misc funcs */
 extern int acltoownermode(char *path, struct stat *st,uid_t uid, struct maccess *ma);
+extern int check_vol_acl_support(const struct vol *vol);
 #endif
index 7eee85ee63b9ac6b8ce05914b3f6e4691689f2e8..257ca3ec8b73948f9ea80529176b0f8b134b0cda 100644 (file)
@@ -59,6 +59,7 @@ char *strchr (), *strrchr ();
 #include "mangle.h"
 #include "fork.h"
 #include "hash.h"
+#include "acls.h"
 
 extern int afprun(int root, char *cmd, int *outfd);
 
@@ -730,7 +731,8 @@ static int creatvol(AFPObj *obj, struct passwd *pwd,
     volume->v_vid = ++lastvid;
     volume->v_vid = htons(volume->v_vid);
 #ifdef HAVE_ACLS
-    volume->v_flags |= AFPVOL_ACLS;
+    if (check_vol_acl_support(volume))
+        volume->v_flags |= AFPVOL_ACLS;
 #endif
 
     /* handle options */