Chapter 7: Permissions and ACLs
Exercise: Permissions and ACLs review
Set up a small analysis team on servera: a shared directory whose files stay in the team's group, a script only the team can run, a public drop box, and one outsider who may read a single report and nothing else.
Permissions and ACLs review
- Build a setgid team directory with the right owners and modes.
- Protect a public directory with the sticky bit.
- Grant one user narrow access with ACLs and a default ACL.
Before you start: reset the servers and complete this chapter's lessons. You work on servera, as root (sudo -i); lab start and lab grade run on workstation.
On servera:
- Create the group
analystswith GID 36000, and the usersdanaandevanas members of it. Createvisitor, who is not a member. - Create
/srv/analysis, owned by root with groupanalysts, mode 2770. - As
dana, create/srv/analysis/summary.txtcontaining the lineQuarterly summary. It must belong todanaandanalystswith mode 660. - Create
/srv/analysis/bin/report.sh, owned bydana, groupanalysts, mode 750. - Create
/srv/dropbox, where everyone can create files but delete only their own (mode 1777). - With ACLs, let
visitorreadsummary.txt, and nothing else.visitormust also be able to pass through/srv/analysis, and files created there in future must grantvisitorread access.
Start the exercise
[student@workstation ~]$ lab start sa-perms-review
[student@workstation ~]$ ssh student@servera
[student@servera ~]$ sudo -i
[root@servera ~]#Create the people and the directory
[root@servera ~]# groupadd -g 36000 analysts
[root@servera ~]# useradd -m -G analysts dana
[root@servera ~]# useradd -m -G analysts evan
[root@servera ~]# useradd -m visitor
[root@servera ~]# install -d -o root -g analysts -m 2770 /srv/analysis
[root@servera ~]# install -d -m 1777 /srv/dropboxCreate the report and the script
[root@servera ~]# su - dana -c 'umask 007; echo "Quarterly summary" > /srv/analysis/summary.txt'
[root@servera ~]# su - dana -c 'umask 007; mkdir /srv/analysis/bin; echo "echo report" > /srv/analysis/bin/report.sh'
[root@servera ~]# chmod 750 /srv/analysis/bin/report.sh
[root@servera ~]# ls -lR /srv/analysis
/srv/analysis:
total 8
drwxrws---. 2 dana analysts 4096 Oct 3 16:20 bin
-rw-rw----. 1 dana analysts 18 Oct 3 16:20 summary.txt
...output omitted...Because /srv/analysis is setgid, the group is analysts without any chgrp. The umask 007 gives the team write access.
Give visitor narrow access
[root@servera ~]# setfacl -m u:visitor:r /srv/analysis/summary.txt
[root@servera ~]# setfacl -m u:visitor:x /srv/analysis
[root@servera ~]# setfacl -d -m u:visitor:r /srv/analysis
[root@servera ~]# su - visitor -c 'cat /srv/analysis/summary.txt'
Quarterly summary
[root@servera ~]# su - visitor -c 'ls /srv/analysis'
ls: cannot open directory '/srv/analysis': Permission deniedvisitor has x only on the directory: they can open a file whose name they know, but cannot list the directory. Run getfacl on both paths to review the entries.
Grade
Leave servera, then on workstation:
Check your work with lab grade sa-perms-review, then put the exercise away with lab finish sa-perms-review.