LPIC-3 333.1: Discretionary access control
Setuid, setgid and the sticky bit, ACLs with masks and defaults, ACL backups, extended attributes and file capabilities.
Before you start
The lab creates the group projects and the users alice (in
projects) and bob (not in it), with the password Lab-Pass-1. Work in
/srv/dac, which doesn't exist yet. Install the ACL and extended
attribute tools (acl, attr) if they're missing.
Tasks
- Make
/srv/dac/id-suid, a copy ofidowned bybobwith the setuid bit, so that whenaliceruns it her effective user isbob. Then remove the owner's execute bit and look at the mode. - Make a shared directory
/srv/dac/shared, owned by root and groupprojects, mode 3770 (setgid and sticky). Asalice, createalice.txtin it; addbobtoprojectsand, asbob, createbob.txtand try to deletealice.txt. Then takebobout ofprojectsagain. - Make
/srv/dac/plan.txt, owned byaliceand groupprojects, mode 640. Givebobread and write access with an ACL, then limit it with the mask so thatbobcan read the file but not write it. - Give the directory
/srv/dac/reportsa default ACL that givesbobread and groupprojectsread and write, and createreports/q3.txtin it. Then remove the default ACL again. - Back up the ACLs of
reports(recursively) andplan.txtto/srv/dac/acl-backup.txt, clearplan.txt's ACL and restore it from the backup. Copyplan.txttoplain-copy.txtwith a plaincpand tofull-copy.txtkeeping its ACL. - As
alice, set the extended attributeuser.reviewedto2026-10-23onshared/alice.txt. Giveid-suidthe file capabilitycap_net_raw(permitted and effective) and find where it's stored. Try the immutable flag onplan.txt, and take it off again.
Hints
cp,chown,chmod 4755,chmod u-x;sudo -u alice ./id-suid;find ... -perm -4000.install -d -m 3770 -g projects,sudo -u alice touch,usermod -aG,gpasswd -d.setfacl -m u:bob:rw,setfacl -m m::r,getfacl;sudo -u bob cat.setfacl -m d:u:bob:r,d:g:projects:rw,setfacl -k.getfacl -R reports plan.txt > acl-backup.txt,setfacl -b,setfacl --restore=acl-backup.txt(from/srv/dac);cpandcp -a.setfattr -n user.reviewed -v ...,getfattr -d,getfattr -d -m - -e hex;setcap cap_net_raw=ep,getcap;chattr +i,lsattr,chattr -i.