- Access Control Lists (Русский)
- Contents
- Установка
- Включение ACL
- Использование
- Изменение ACL
- Просмотр ACL
- Примеры
- Вывод команды ls
- Права на выполнение личных файлов
- Access Control Lists
- Contents
- Installation
- Enable ACL
- Usage
- Set ACL
- Show ACL
- Examples
- Output of ls command
- Execution permissions for private files
- Access Control Lists in Linux
- Advantages of ACLs
- Definitions
- Handling ACLs
- Structure of ACL Entries
- ACL Entries and File Mode Permission Bits
- A Directory with Access ACL
- A Directory with a Default ACL
- Effects of a Default ACL
- Application of Default ACLs
- The ACL Check Algorithm
- Outlook
Access Control Lists (Русский)
Списки управления доступом (Access Control Lists, ACL) — расширенный, более гибкий механизм прав доступа для файловых систем, разработанный как дополнение к стандартным правам доступа UNIX. ACL позволяет задавать права доступа к объектам на диске для пользователей и групп.
Contents
Установка
Пакет acl уже установлен, так как является зависимостью systemd.
Включение ACL
Для использования ACL файловая система должна быть смонтирована с опцией acl . Файл fstab позволяет настроить постоянное монтирование с данной опцией.
В некоторых файловых системах параметр монтирования acl включён по умолчанию. К таким файловым системам относятся Btrfs и Ext2/3/4. Следующая команда позволяет проверить раздел с файловой системой ext* на наличие параметра acl :
Убедитесь, что используемая по умолчанию опция не была переопределена. Об этом будет свидетельствовать параметр noacl в соответствующей строке файла /proc/mounts .
Задать параметры монтирования файловой системы по умолчанию можно командой tune2fs -o параметр раздел , например:
Это очень удобно при работе с внешними дисками, поскольку такой диск будет монтироваться с опцией acl и на других Linux-машинах. В противном случае придётся редактировать файл /etc/fstab на каждой системе.
Использование
Изменение ACL
Для изменения прав ACL используется команда setfacl.
Задать права пользователя (в качестве пользователь можно использовать имя пользователя или его ID):
Задать права группы (в качестве группа можно использовать имя группы или её ID):
Задать права для остальных:
Настроить наследование новыми файлами и каталогами записей ACL родительского каталога (не относится к файлам/каталогам, которые копируются в каталог):
Удалить определённую запись ACL:
Удалить записи по умолчанию:
Удалить все записи ACL:
The factual accuracy of this article or section is disputed.
Просмотр ACL
Вывести права доступа ACL:
Примеры
Установить все права доступа к файлу abc для пользователя johnny :
Измененить права для пользователя johnny :
Удалить все записи ACL:
Вывод команды ls
Символ + (плюс) после прав доступа Unix в выводе команды ls -l указывает на использование ACL:
Права на выполнение личных файлов
Ниже описано, как процесс вроде веб-сервера может получить доступ к файлам в домашнем каталоге пользователя без ущерба для безопасности.
Будем считать что веб-сервер работает от пользователя http и получает доступ к домашнему каталогу /home/geoffrey пользователя geoffrey .
Санчала предоставим права на выполнение для пользователя http :
Поскольку пользователь http теперь имеет доступ к файлам в /home/geoffrey то безопаснее будет удалить доступ для остальных пользователей:
Проверим изменения с помощью getfacl :
Как видно из вывода, other больше не имеют никаких прав, но пользователь http всё ещё может обращаться к файлам.
Если необходимо будет выдать пользователю http права доступа на запись в определённые файлы/каталоги, выполните:
Источник
Access Control Lists
Access control list (ACL) provides an additional, more flexible permission mechanism for file systems. It is designed to assist with UNIX file permissions. ACL allows you to give permissions for any user or group to any disk resource.
Contents
Installation
The acl package is a dependency of systemd, it should already be installed.
Enable ACL
To enable ACL, the filesystem must be mounted with the acl option. You can use fstab to make it permanent on your system.
There is a possibility that the acl option is already active as default mount option on the filesystem. Btrfs does and Ext2/3/4 filesystems do too. Use the following command to check ext* formatted partitions for the option:
Also check that the default mount option is not overridden, in such case you will see noacl in /proc/mounts in the relevant line.
You can set the default mount options of a filesystem using the tune2fs -o option partition command, for example:
Using the default mount options instead of an entry in /etc/fstab is very useful for external drives, such partition will be mounted with acl option also on other Linux machines. There is no need to edit /etc/fstab on every machine.
Usage
Set ACL
The ACL can be modified using the setfacl command.
To set permissions for a user ( user is either the user name or ID):
To set permissions for a group ( group is either the group name or ID):
To set permissions for others:
To allow all newly created files or directories to inherit entries from the parent directory (this will not affect files which will be copied into the directory):
To remove a specific entry:
To remove the default entries:
To remove all entries (entries of the owner, group and others are retained):
The factual accuracy of this article or section is disputed.
Show ACL
To show permissions, use:
Examples
Set all permissions for user johnny to file named abc :
Change permissions for user johnny :
Remove all ACL entries:
Output of ls command
You will notice that there is an ACL for a given file because it will exhibit a + (plus sign) after its Unix permissions in the output of ls -l .
Execution permissions for private files
The following technique describes how a process like a web server can be granted access to files that reside in a user’s home directory, without compromising security by giving the whole world access.
In the following we assume that the web server runs as the user http and grant it access to geoffrey ‘s home directory /home/geoffrey .
The first step is granting execution permissions for the user http :
Since the user http is now able to access files in /home/geoffrey , others no longer need access:
Use getfacl to verify the changes:
As the above output shows, other ‘s no longer have any permissions, but the user http is still able to access the files, thus security might be considered increased.
If you need to give write access for the user http on specific directories and/or files, run:
Источник
Access Control Lists in Linux
This chapter provides a brief summary of the background and functions of POSIX ACLs for Linux file systems. Learn how the traditional permission concept for file system objects can be expanded with the help of ACLs ( Access Control Lists ) and which advantages this concept provides. |
Advantages of ACLs
Note |
[POSIX ACLs]The term «POSIX ACL» suggests that this is a true POSIX ( Portable Operating System Interface ) standard. The respective draft standards POSIX 1003.1e and POSIX 1003.2c have been withdrawn for several reasons. Nevertheless, ACLs as found on many systems belonging to the UNIX family are based on these documents and the implementation of file system ACLs as described in this chapter follows these two standards as well. They can be viewed at http://wt.xpilot.org/publications/posix.1e/
Traditionally, a file object in Linux is associated with three sets of permissions. These sets includes the read ( r ), write ( w ), and execute ( x ) permissions for each on of three types of users — the file owner, the group, and other users. In addition to that, it is possible to set the set user id , set group id , and the sticky bit. A more detailed discussion of this topic can be found in the section Users and Access Permissions of the User Guide .
This lean concept is fully adequate for most practical cases. However, for more complex scenarios or advanced applications, system administrators formerly had to use a number of tricks to circumvent the limitations of the traditional permission concept.
ACLs can be used for situations that require an extension of the traditional file permission concept. They allow assignment of permissions to individual users or groups even if these do not correspond to the original owner or the owning group. Access Control Lists are a feature of the Linux kernel and are currently supported by ReiserFS, Ext2, Ext3, JFS, and XFS. Using ACLs, complex scenarios can be realized without implementing complex permission models on the application level.
The advantages of ACLs are clearly evident in situations such as the replacement of a Windows server by a Linux server. Some of the connected workstations may continue to run under Windows even after the migration. The Linux system offers file and print services to the Windows clients with Samba.
Given than Samba supports access control lists, user permissions can be configured both on the Linux server and in Windows with a graphical user interface (only Windows NT and later). With winbindd, it is even possible to assign permissions to users that only exist in the Windows domain without any account on the Linux server. On the server side, edit the Access Control Lists using getfacl and setfacl.
Definitions
User class The conventional POSIX permission concept uses three classes of users for assigning permissions in the file system: the owner, the owning group, and other users. Three permission bits can be set for each user class, giving permission to read ( r ), write ( w ), and execute ( x ). An introduction to the user concept in Linux is provided in the User Guide in Users and Access Permissions . Access ACL The user and group access permissions for all kinds of file system objects (files and directories) are determined by means of access ACLs. Default ACL Default ACLs can only be applied to directories. They determine the permissions a file system object inherits from its parent directory when it is created. ACL entry Each ACL consists of a set of ACL entries. An ACL entry contains a type (see Table B.1), a qualifier for the user or group to which the entry refers, and a set of permissions. For some entry types, the qualifier for the group or users is undefined.
Handling ACLs
The following section explains the basic structure of an ACL and its various characteristics. The interrelation between ACLs and the traditional permission concept in the Linux file system is briefly demonstrated by means of several figures. Two examples show how you can create your own ACLs using the correct syntax. In conclusion, find information about the way ACLs are interpreted by the operating system.
Structure of ACL Entries
There are two basic classes of ACLs: A minimum ACL merely comprises the entries for the types owner, owning group, and other, which correspond to the conventional permission bits for files and directories. An extended ACL goes beyond this. It must contain a mask entry and may contain several entries of the named user and named group types. Table B.1 provides a summary of the various types of ACL entries that are possible.
The permissions defined in the entries owner and other are always effective. Except for the mask entry, all other entries ( named user , owning group , and named group ) can be either effective or masked. If permissions exist in one of the above-mentioned entries as well as in the mask, they are effective. Permissions contained only in the mask or only in the actual entry are not effective. The example in Table B.2 demonstrates this mechanism.
ACL Entries and File Mode Permission Bits
Figure B.1 and Figure B.2 illustrate the two cases of a minimum ACL and an extended ACL. The figures are structured in three blocks — the left block shows the type specifications of the ACL entries, the center block displays an example ACL, and the right block shows the respective permission bits according to the conventional permission concept as displayed by ls -l , for instance.
In both cases, the owner class permissions are mapped to the ACL entry owner . Equally, other class permissions are mapped to the respective ACL entry. However, the mapping of the group class permissions is different in both cases:
In the case of a minimum ACL — without mask — the group class permissions are mapped to the ACL entry owning group . This is shown in Figure B.1.
|