I am trying to understand the difference in behaviour between FreeBSD ACLs and Linux ACLs. In particular, the inheritance mechanism for the default ACLs.
I used the following on both Debian 9.6 and FreeBSD 12:
$ cat test_acl.sh
#!/bin/sh
set -xe
mkdir storage
setfacl -d -m u::rwx,g::rwx,o::-,m::rwx storage
touch outside
cd storage
touch inside
cd ..
ls -ld outside storage storage/inside
getfacl -d storage
getfacl storage
getfacl outside
getfacl storage/inside
umask
I get the following output from Debian 9.6:
$ ./test_acl.sh
+ mkdir storage
+ setfacl -d -m u::rwx,g::rwx,o::-,m::rwx storage
+ touch outside
+ cd storage
+ touch inside
+ cd ..
+ ls -ld outside storage storage/inside
-rw-r--r-- 1 aaa aaa 0 Dec 28 11:16 outside
drwxr-xr-x+ 2 aaa aaa 4096 Dec 28 11:16 storage
-rw-rw----+ 1 aaa aaa 0 Dec 28 11:16 storage/inside
+ getfacl -d storage
# file: storage
# owner: aaa
# group: aaa
user::rwx
group::rwx
mask::rwx
other::---
+ getfacl storage
# file: storage
# owner: aaa
# group: aaa
user::rwx
group::r-x
other::r-x
default:user::rwx
default:group::rwx
default:mask::rwx
default:other::---
+ getfacl outside
# file: outside
# owner: aaa
# group: aaa
user::rw-
group::r--
other::r--
+ getfacl storage/inside
# file: storage/inside
# owner: aaa
# group: aaa
user::rw-
group::rwx #effective:rw-
mask::rw-
other::---
+ umask
0022
Notice that the outside
and inside
files have different permissions. In particular, the outside
file has -rw-r--r--
, which is the default for this user and the inside
file has -rw-rw----
, respecting the default ACLs I assigned the storage
directory.
The output of the same script on FreeBSD 12:
$ ./test_acl.sh
+ mkdir storage
+ setfacl -d -m u::rwx,g::rwx,o::-,m::rwx storage
+ touch outside
+ cd storage
+ touch inside
+ cd ..
+ ls -ld outside storage storage/inside
-rw-r--r-- 1 aaa aaa 0 Dec 28 03:16 outside
drwxr-xr-x 2 aaa aaa 512 Dec 28 03:16 storage
-rw-r-----+ 1 aaa aaa 0 Dec 28 03:16 storage/inside
+ getfacl -d storage
# file: storage
# owner: aaa
# group: aaa
user::rwx
group::rwx
mask::rwx
other::---
+ getfacl storage
# file: storage
# owner: aaa
# group: aaa
user::rwx
group::r-x
other::r-x
+ getfacl outside
# file: outside
# owner: aaa
# group: aaa
user::rw-
group::r--
other::r--
+ getfacl storage/inside
# file: storage/inside
# owner: aaa
# group: aaa
user::rw-
group::rwx # effective: r--
mask::r--
other::---
+ umask
0022
(Note Debian's getfacl
will also show the default ACLs even when not using -d
where as FreeBSD does not, but I don't think the actual ACLs for storage
are different.)
Here, the outside
and inside
files also have different permissions, but the inside
file does not have the group write permission that the Debian version does, probably because the mask in Debian retained the w
while the mask in FreeBSD lost the w
.
Why did FreeBSD lose the w
mask but Debian retained it?
Best Answer
In short I’d say (assume) they’re using umask differently.
0022 is exactly group-other unset W. You can change umask to remove write prohibition and check the result.
Citing Solaris aka SunOS manual (and comments as well) since that seems to be pretty related: "… The umask(1) will not be applied if the directory contains default ACL entries. …"