Lines 1-63
Link Here
|
1 |
--- etc/afpd/acls.c.orig 2011-07-30 18:08:35.000000000 -0400 |
|
|
2 |
+++ etc/afpd/acls.c 2011-07-30 18:19:19.000000000 -0400 |
3 |
@@ -1060,7 +1060,59 @@ static int set_acl(const struct vol *vol |
4 |
#ifdef HAVE_ACL_FROM_MODE |
5 |
EC_NULL_LOG_ERR(acc_acl = acl_from_mode(st.st_mode), AFPERR_MISC); |
6 |
#else |
7 |
-#error "Missing acl_from_mode() replacement" |
8 |
+ /* Implement the non POSIX.1e function acl_from_mode |
9 |
+ * |
10 |
+ * Taken from http://people.freebsd.org/~markus/stuff/kacl.diff |
11 |
+ */ |
12 |
+ { |
13 |
+ acl_t new_acl = acl_init( 3 ); |
14 |
+ acl_entry_t entry; |
15 |
+ acl_permset_t permset = 0; |
16 |
+ int error = 0; |
17 |
+ |
18 |
+ /* Add owner entry */ |
19 |
+ if ( ( error = acl_create_entry( &new_acl, &entry ) ) == 0 ) { |
20 |
+ /* Set owner permissions */ |
21 |
+ acl_set_tag_type( entry, ACL_USER_OBJ ); |
22 |
+ acl_get_permset( entry, &permset ); |
23 |
+ acl_clear_perms( permset ); |
24 |
+ if ( st.st_mode & S_IRUSR ) acl_add_perm( permset, ACL_READ ); |
25 |
+ if ( st.st_mode & S_IWUSR ) acl_add_perm( permset, ACL_WRITE ); |
26 |
+ if ( st.st_mode & S_IXUSR ) acl_add_perm( permset, ACL_EXECUTE ); |
27 |
+ acl_set_permset( entry, permset ); |
28 |
+ |
29 |
+ /* Add group entry */ |
30 |
+ if ( ( error = acl_create_entry( &new_acl, &entry ) ) == 0 ) { |
31 |
+ /* Set group permissions */ |
32 |
+ acl_set_tag_type( entry, ACL_GROUP_OBJ ); |
33 |
+ acl_get_permset( entry, &permset ); |
34 |
+ acl_clear_perms( permset ); |
35 |
+ if ( st.st_mode & S_IRGRP ) acl_add_perm( permset, ACL_READ ); |
36 |
+ if ( st.st_mode & S_IWGRP ) acl_add_perm( permset, ACL_WRITE ); |
37 |
+ if ( st.st_mode & S_IXGRP ) acl_add_perm( permset, ACL_EXECUTE ); |
38 |
+ acl_set_permset( entry, permset ); |
39 |
+ |
40 |
+ /* Add other entry */ |
41 |
+ if ( ( error = acl_create_entry( &new_acl, &entry ) ) == 0 ) { |
42 |
+ /* Set other permissions */ |
43 |
+ acl_set_tag_type( entry, ACL_OTHER ); |
44 |
+ acl_get_permset( entry, &permset ); |
45 |
+ acl_clear_perms( permset ); |
46 |
+ if ( st.st_mode & S_IROTH ) acl_add_perm( permset, ACL_READ ); |
47 |
+ if ( st.st_mode & S_IWOTH ) acl_add_perm( permset, ACL_WRITE ); |
48 |
+ if ( st.st_mode & S_IXOTH ) acl_add_perm( permset, ACL_EXECUTE ); |
49 |
+ acl_set_permset( entry, permset ); |
50 |
+ } |
51 |
+ } |
52 |
+ } |
53 |
+ |
54 |
+ if ( error ) { |
55 |
+ acl_free( &new_acl ); |
56 |
+ EC_NULL_LOG_ERR(acc_acl = NULL, AFPERR_MISC); |
57 |
+ } |
58 |
+ else |
59 |
+ acc_acl = new_acl; |
60 |
+ } |
61 |
#endif |
62 |
/* adds the clients aces */ |
63 |
EC_ZERO_ERR(map_aces_darwin_to_posix(daces, &def_acl, &acc_acl, ace_count), AFPERR_MISC); |