]> arthur.barton.de Git - netatalk.git/commitdiff
Merge pull request #1 from knu/freebsd_fix
authorfranklahm <franklahm@googlemail.com>
Sat, 30 Jul 2011 14:33:53 +0000 (07:33 -0700)
committerfranklahm <franklahm@googlemail.com>
Sat, 30 Jul 2011 14:33:53 +0000 (07:33 -0700)
Fixes for building on FreeBSD

configure.in
etc/afpd/acls.c
etc/cnid_dbd/cnid_metad.c
etc/cnid_dbd/comm.c

index d6a758b0bb8c464df9f8a5f28c0a5413cbe350b5..4d3ed242899ee381b12bc63050a4caff7f486046 100644 (file)
@@ -1071,7 +1071,7 @@ if test x"$with_acl_support" = x"yes" ; then
                                [netatalk_cv_HAVE_ACL_GET_PERM_NP=no])
                                LIBS=$acl_LIBS
                        ])
-                       if test x"netatalk_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
+                       if test x"$netatalk_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
                                AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
                        fi
 
index 18490fcfaaa7417fc5ce13bb89e7ce261bca5681..b27b90b0448deb46d48b8af75de5e72f67b64651 100644 (file)
@@ -1035,6 +1035,63 @@ EC_CLEANUP:
 #endif /* HAVE_SOLARIS_ACLS */
 
 #ifdef HAVE_POSIX_ACLS
+#ifndef HAVE_ACL_FROM_MODE
+static acl_t acl_from_mode(mode_t mode)
+{
+    acl_t acl;
+    acl_entry_t entry;
+    acl_permset_t permset;
+
+    if (!(acl = acl_init(3)))
+        return NULL;
+
+    if (acl_create_entry(&acl, &entry) != 0)
+        goto error;
+    acl_set_tag_type(entry, ACL_USER_OBJ);
+    acl_get_permset(entry, &permset);
+    acl_clear_perms(permset);
+    if (mode & S_IRUSR)
+        acl_add_perm(permset, ACL_READ);
+    if (mode & S_IWUSR)
+        acl_add_perm(permset, ACL_WRITE);
+    if (mode & S_IXUSR)
+        acl_add_perm(permset, ACL_EXECUTE);
+    acl_set_permset(entry, permset);
+
+    if (acl_create_entry(&acl, &entry) != 0)
+        goto error;
+    acl_set_tag_type(entry, ACL_GROUP_OBJ);
+    acl_get_permset(entry, &permset);
+    acl_clear_perms(permset);
+    if (mode & S_IRGRP)
+        acl_add_perm(permset, ACL_READ);
+    if (mode & S_IWGRP)
+        acl_add_perm(permset, ACL_WRITE);
+    if (mode & S_IXGRP)
+        acl_add_perm(permset, ACL_EXECUTE);
+    acl_set_permset(entry, permset);
+
+    if (acl_create_entry(&acl, &entry) != 0)
+        goto error;
+    acl_set_tag_type(entry, ACL_OTHER);
+    acl_get_permset(entry, &permset);
+    acl_clear_perms(permset);
+    if (mode & S_IROTH)
+        acl_add_perm(permset, ACL_READ);
+    if (mode & S_IWOTH)
+        acl_add_perm(permset, ACL_WRITE);
+    if (mode & S_IXOTH)
+        acl_add_perm(permset, ACL_EXECUTE);
+    acl_set_permset(entry, permset);
+
+    return acl;
+
+error:
+    acl_free(acl);
+    return NULL;
+}
+#endif
+
 static int set_acl(const struct vol *vol,
                    const char *name,
                    int inherit _U_,
@@ -1057,11 +1114,8 @@ static int set_acl(const struct vol *vol,
     /* for files def_acl will be NULL */
 
     /* create access acl from mode */
-#ifdef HAVE_ACL_FROM_MODE
     EC_NULL_LOG_ERR(acc_acl = acl_from_mode(st.st_mode), AFPERR_MISC);
-#else
-#error "Missing acl_from_mode() replacement"
-#endif
+
     /* adds the clients aces */
     EC_ZERO_ERR(map_aces_darwin_to_posix(daces, &def_acl, &acc_acl, ace_count), AFPERR_MISC);
 
index 201902d66af1019f44f25adea5c0e82729449f1d..86d904bdf7becb45ce689afaae9ae3d7f6385668 100644 (file)
@@ -40,6 +40,7 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/time.h>
+#include <sys/resource.h>
 #include <sys/wait.h>
 #include <sys/uio.h>
 #include <sys/un.h>
index 083d27a7d8022129c9c8f8ffb4f22571e5ce8842..ddbc9855294e72b511f1042566666d71f8dafc7c 100644 (file)
 #ifndef _GNU_SOURCE
 # define _GNU_SOURCE
 #endif
+#ifndef __BSD_VISIBLE
+/* for u_short, u_char, etc. */
+# define __BSD_VISIBLE 1
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>