Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 212Security · Permissions

How to share a folder with a group using ACLs

The finance team needs read-write access to /srv/finance, the auditors only read access, and new files must get the same rights automatically. Normal Unix permissions allow only one owner and one group. ACLs (access control lists) add more users and groups to a file or folder, and default ACLs pass the rights on to new files. This how-to sets up such a shared folder and shows how to read and remove ACLs.

  • 5 Lessen
  • 11 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

212.1

The quick answer

mkdir -p /srv/finance
chgrp finance /srv/finance
chmod 2770 /srv/finance
setfacl -m g:auditors:rx /srv/finance
setfacl -d -m g:finance:rwx,g:auditors:rx /srv/finance
getfacl /srv/finance

212.2

Step by step

  1. Base rights (lines 1–3) — group finance owns the folder; 2770 = full access for owner and group, nothing for others, plus the setgid bit (the 2): new files belong to the group finance, not to the user's own group.
  2. Extra group (line 4) — auditors may list and read. x on a folder means "may enter it".
  3. Default ACL (line 5) — new files and folders inside get these entries automatically. Without it, files created later have only the normal rights.
  4. Read the ACL — ls -l shows a + after the rights when an ACL exists; getfacl shows all entries:
getfacl output
# file: srv/finance
# owner: root
# group: finance
# flags: -s-
user::rwx
group::rwx
group:auditors:r-x
mask::rwx
other::---
default:user::rwx
default:group::rwx
default:group:finance:rwx
default:group:auditors:r-x
default:mask::rwx
default:other::---
  1. Existing files — ACLs are not applied backwards. Give the auditors read access to what is already there (capital X = execute only for folders):
setfacl -R -m g:auditors:rX /srv/finance
  1. The mask — the upper limit for named users and groups. A chmod g-w on a file lowers the mask, and then the ACL write right does not work any more ("effective: r--" in getfacl).
  2. Remove — one entry: setfacl -x g:auditors /srv/finance; all ACLs: setfacl -b /srv/finance.
  3. Keep ACLs in copies and backups — cp -a, rsync -A, tar --acls; otherwise they are lost.

212.3

Check that it worked

As a finance user, touch /srv/finance/report.ods works and the new file shows group finance and the auditors entry in getfacl; as an auditor, reading works but touch /srv/finance/x fails with Permission denied; other users cannot even list the folder.

212.4

Common problems

ProblemCauseFix
Operation not supportedFile system without ACL support.ext4/XFS support ACLs; check mount options and NFS version.
New files lack the ACLNo default ACL on the folder.setfacl -d -m … on the folder.
ACL says rwx but writing failsMask lowered (effective:r--).setfacl -m m::rwx FILE; avoid chmod g-w on shared files.
New files have the user's own groupNo setgid bit.chmod g+s on the folder.
ACLs gone after restoreBackup tool did not keep them.rsync -A, tar --acls, cp -a.
User added to the group still deniedOld login session without the new group.Log out and in again (or newgrp).

212.5

Go further

1What does a default ACL do?

New files and folders created inside the folder get the default ACL entries automatically.

2What is the ACL mask?

The upper limit for named users and groups; rights above the mask are not effective.

Alle commando's in dit hoofdstuk