# Permissioner: Setting File Ownerships and Permissions
The unix tools `chown` and `chmod` allow to set ownership and permissions of
files and entire directory trees. However, multiple calls to those tools
are needed when setting complex ownerships and permissions of nested directory
trees. In case the change of ownerships and permissions shall be very fast for
file, e.g., because the directory tree is accessed in parallel to the change,
using multiple calls is not suitable.
For example, let's assume, multiple users write files to a shared directory
`shared/` in order to implement a primitive ad-hoc file sharing. The users
all have the group `fileshare`. All files copied to the shared directory
shall be readable, writable and deletable by all other users in the group.
However, there is one directory, called `shared/perm`, in which files should
stay permanently and be only readable for all users. This could be implemented
by executing the following commands periodically in a `cron`-job:
```
chown -R nobody:fileshare shared
chmod -R ug+rwX shared
chmod -R g-w shared/perm
```
However, while the sequence of the three commands is executing, strange and
unwanted ownerships and permissions may occur. If the directory tree is large,
it can lead to problems accessing the files in parallel.
Permissioner can help to reduce the problems by touching each file only once,
and setting its ownership and permissions very quickly, before advancing to the
next file.
Using the configuration file `fileshare.cfg` with the content
```
tree nobody fileshare ug+rwX shared
tree nobody fileshare u+rwX,g+wX,g-w shared/perm
```
in the call
```
bin/permissionerc fileshare.cfg
```
has the same effect, but achieves the same outcome while touching every file
just once - thus avoiding the transient strange state of files.
This is only a simple example to illustrate the functionality of
permissioner. There are various other tools to properly implement a file
sharing service. The sketched setup is only an ad-hoc hack and not a proper
solution.