Setfacl utility tests. Run these tests on a filesystem with ACL support.

Cry immediately if we are not running as root.

	$ require_root

 	$ mkdir d
	$ chown bin:bin d
	$ cd d

	$ su bin
	$ sg bin
	$ umask 027
	$ touch g
	$ ls -dl g | awk '{print $1}' | sed 's/\\.//g'
	> -rw-r-----

	$ setfacl -m m:- g
	$ ls -dl g | awk '{print $1}'
	> -rw-------+

	$ getfacl g
	> # file: g
	> # owner: bin
	> # group: bin
	> user::rw-
	> group::r--	#effective:---
	> mask::---
	> other::---
	>

	$ setfacl -x m g
	$ getfacl g
	> # file: g
	> # owner: bin
	> # group: bin
	> user::rw-
	> group::r--
	> other::---
	>

	$ setfacl -m u:daemon:rw g
	$ getfacl g
	> # file: g
	> # owner: bin
	> # group: bin
	> user::rw-
	> user:daemon:rw-
	> group::r--
	> mask::rw-
	> other::---
	>

	$ setfacl -m u::rwx,g::r-x,o:- g
	$ getfacl g
	> # file: g
	> # owner: bin
	> # group: bin
	> user::rwx
	> user:daemon:rw-
	> group::r-x
	> mask::rwx
	> other::---
	>

	$ setfacl -m u::rwx,g::r-x,o:-,m:- g
	$ getfacl g
	> # file: g
	> # owner: bin
	> # group: bin
	> user::rwx
	> user:daemon:rw-	#effective:---
	> group::r-x	#effective:---
	> mask::---
	> other::---
	>

	$ setfacl -m u::rwx,g::r-x,o:-,u:root:-,m:- g
	$ getfacl g
	> # file: g
	> # owner: bin
	> # group: bin
	> user::rwx
	> user:root:---
	> user:daemon:rw-	#effective:---
	> group::r-x	#effective:---
	> mask::---
	> other::---
	>

	$ setfacl -m u::rwx,g::r-x,o:-,u:root:-,m:- g
	$ getfacl g
	> # file: g
	> # owner: bin
	> # group: bin
	> user::rwx
	> user:root:---
	> user:daemon:rw-	#effective:---
	> group::r-x	#effective:---
	> mask::---
	> other::---
	>

	$ setfacl -m u::rwx,g::r-x,o:-,u:root:- g
	$ getfacl g
	> # file: g
	> # owner: bin
	> # group: bin
	> user::rwx
	> user:root:---
	> user:daemon:rw-
	> group::r-x
	> mask::rwx
	> other::---
	>

	$ setfacl --test -x u: g
	> setfacl: g: Malformed access ACL `user:root:---,user:daemon:rw-,group::r-x,mask::rwx,other::---': Missing or wrong entry at entry 1

	$ setfacl --test -x u:x
	> setfacl: Option -x: Invalid argument near character 3

	$ setfacl -m d:u:root:rwx g
	> setfacl: g: Only directories can have default ACLs

	$ setfacl -x m g
	> setfacl: g: Malformed access ACL `user::rwx,user:root:---,user:daemon:rw-,group::r-x,other::---': Missing or wrong entry at entry 5
	 setfacl --test -m d:u:daemon:rwx setfacl
	 setfacl --test -n -m d:u:daemon:rwx setfacl

Check if the mask is properly recalculated

	$ mkdir d
	$ setfacl --test -m u::rwx,u:bin:rwx,g::r-x,o::--- d
	> d: u::rwx,u:bin:rwx,g::r-x,m::rwx,o::---,*

	$ setfacl --test -m u::rwx,u:bin:rwx,g::r-x,m::---,o::--- d
	> d: u::rwx,u:bin:rwx,g::r-x,m::---,o::---,*

	$ setfacl --test -d -m u::rwx,u:bin:rwx,g::r-x,o::--- d
	> d: *,d:u::rwx,d:u:bin:rwx,d:g::r-x,d:m::rwx,d:o::---

	$ setfacl --test -d -m u::rwx,u:bin:rwx,g::r-x,m::---,o::--- d
	> d: *,d:u::rwx,d:u:bin:rwx,d:g::r-x,d:m::---,d:o::---

	$ su
	$ cd ..
	$ rm -r d
