AppArmor Сравнение версий

Различия

Здесь показаны различия между двумя версиями данной страницы.

Ссылка на это сравнение

Следующая версия
Предыдущая версия
wiki:руководство_по_ubuntu_server:безопасность:apparmor [2012/06/21 22:20]
создано
wiki:руководство_по_ubuntu_server:безопасность:apparmor [2012/06/22 21:07] (текущий)
[Ссылки]
Строка 8: Строка 8:
 =====AppArmor===== =====AppArmor=====
  
-AppArmor ​is a Linux Security Module implementation of name-based mandatory access controls. AppArmor ​confines individual programs to a set of listed files and posix 1003.1e ​draft capabilities.+**AppArmor** это реализация Модуля безопасности линукс по управлению доступом на основе имен. AppArmor ​ограничивает отдельные программы набором перечисленных файлов и возможностями в соответствии с правилами Posix 1003.1e.
  
-AppArmor ​is installed and loaded by defaultIt uses profiles of an application to determine what files and permissions the application requiresSome packages will install their own profilesand additional profiles can be found in the apparmor-profiles ​package.+**AppArmor** устанавливается и загружается по умолчаниюОн использует профили приложений для определения какие файлы и права доступа требуются приложениюНекоторые пакеты устанавливают свои собственные профилиа дополнительные профили можно найти в пакете **apparmor-profiles**.
  
-To install the apparmor-profiles ​package from a terminal prompt:+Для установки пакета **apparmor-profiles** наберите в терминале: 
 +<​code>​sudo apt-get install apparmor-profiles</​code>​
  
-sudo apt-get install apparmor-profiles +Профили ​AppArmor ​имеют два режима выполнения
- +  -- **Фиксации/Обучения**нарушения профиля разрешаются и сохраняются в журналеПолезно для тестирования и разработки новых профилей 
-AppArmor ​profiles have two modes of execution+  -- **Предписаний/Ограничений**принуждает следовать политике профиля,​ при этом также записывает нарушения в журнал.
- +
-    Complaining/Learningprofile violations are permitted and logged. Useful for testing and developing new profiles+
- +
-    Enforced/Confinedenforces profile policy as well as logging the violation. +
- +
-    Using AppArmor +
-    Profiles +
-    References+
  
 ====Использование AppArmor==== ====Использование AppArmor====
  
-The apparmor-utils ​package contains command line utilities that you can use to change the AppArmor execution modefind the status of a profilecreate new profilesetc.+Пакет ​apparmor-utils ​содержит утилиты командной строкикоторые можно использовать для изменения режима выполнения AppArmorпоиска статуса профилясоздания новых профилей и т.п.
  
-    ​apparmor_status ​is used to view the current status of AppArmor ​profiles.+ 1. **apparmor_status** используется для просмотра текущего статуса профиля AppArmor. 
 +<​code>​sudo apparmor_status</​code>​ 
 + 2. **aa-complain** переводит профиль в режим обучения (complain). 
 +<​code>​sudo aa-complain /path/to/​bin</​code>​ 
 + 3. **aa-enforce** переводит профиль в режим ограничений (enforce). 
 +<​code>​sudo aa-enforce /​path/​to/​bin</​code>​ 
 + 4. Профили ​AppArmor ​расположены в каталоге /​etc/​apparmor.d. Его можно использовать для управления режимом всех профилей. 
 +Введите следующую команду для перевода всех профилей в режим обучения:​ 
 +<​code>​sudo aa-complain /​etc/​apparmor.d/​*</​code>​ 
 +Перевод всех профилей в режим ограничений:​ 
 +<​code>​sudo aa-enforce /​etc/​apparmor.d/​*</​code>​ 
 + 5. Команда **apparmor_parser** используется для загрузки профиля в ядро. Она также может использоваться для повторной загрузки загруженного профиля при использовании опции '​-r'​. Для загрузки введите:​ 
 +<​code>​cat /​etc/​apparmor.d/​profile.name | sudo apparmor_parser -a</​code>​ 
 +Для перезагрузки:​ 
 +<​code>​cat /​etc/​apparmor.d/​profile.name | sudo apparmor_parser -r</​code>​ 
 + 6. /​etc/​init.d/​apparmor служит для перезагрузки всех профилей:​ 
 +<​code>​sudo /​etc/​init.d/​apparmor reload</​code>​ 
 + 7. Директория /​etc/​apparmor.d/​disable может использоваться совместно с опцией **apparmor_parser -R**  для отключения профиля. 
 +<​code>​ 
 +sudo ln -s /​etc/​apparmor.d/​profile.name /​etc/​apparmor.d/​disable/​ 
 +sudo apparmor_parser -R /​etc/​apparmor.d/​profile.name 
 +</​code>​ 
 +Для активации отключенного профиля удалите символическую ссылку на профиль в /​etc/​apparmor.d/​disable/​. Затем загрузите профиль используя опцию '​-a'​. 
 +<​code>​ 
 +sudo rm /​etc/​apparmor.d/​disable/​profile.name 
 +cat /​etc/​apparmor.d/​profile.name | sudo apparmor_parser -a 
 +</​code>​ 
 + 8. AppArmor можно отключить,​ а модуль ядра выгрузить следующей командой:​ 
 +<​code>​ 
 +sudo /​etc/​init.d/​apparmor stop 
 +sudo update-rc.d -f apparmor remove 
 +</​code>​ 
 + 9. Для повторной активации AppArmor введите:​ 
 +<​code>​ 
 +sudo /​etc/​init.d/​apparmor start 
 +sudo update-rc.d apparmor defaults 
 +</​code>​
  
-    sudo apparmor_status +<​note>​Замените ​**profile.name** на имя вашего профилякоторым вы хотите управлятьТакже необходимо заменить ​/​path/​to/​bin/ ​на реальный путь выполненяемого файлаНапример,​ для команды ​ping используйте ​/bin/ping</​note>​
- +
-    aa-complain places a profile into complain mode. +
- +
-    sudo aa-complain /​path/​to/​bin +
- +
-    aa-enforce places a profile into enforce mode. +
- +
-    sudo aa-enforce /​path/​to/​bin +
- +
-    The /​etc/​apparmor.d directory is where the AppArmor profiles are located. It can be used to manipulate the mode of all profiles. +
- +
-    Enter the following to place all profiles into complain mode: +
- +
-    sudo aa-complain /​etc/​apparmor.d/​* +
- +
-    To place all profiles in enforce mode: +
- +
-    sudo aa-enforce /​etc/​apparmor.d/​* +
- +
-    apparmor_parser is used to load a profile into the kernel. It can also be used to reload a currently loaded profile using the -r option. To load a profile: +
- +
-    cat /​etc/​apparmor.d/​profile.name ​| sudo apparmor_parser -a +
- +
-    To reload a profile: +
- +
-    cat /​etc/​apparmor.d/​profile.name | sudo apparmor_parser -r +
- +
-    /​etc/​init.d/​apparmor can be used to reload all profiles: +
- +
-    sudo /​etc/​init.d/​apparmor reload +
- +
-    The /​etc/​apparmor.d/​disable directory can be used along with the apparmor_parser -R option to disable a profile. +
- +
-    sudo ln -s /​etc/​apparmor.d/​profile.name /​etc/​apparmor.d/​disable/​ +
-    sudo apparmor_parser -R /​etc/​apparmor.d/​profile.name +
- +
-    To re-enable a disabled profile remove the symbolic link to the profile in /​etc/​apparmor.d/​disable/​. Then load the profile using the -a option. +
- +
-    sudo rm /​etc/​apparmor.d/​disable/​profile.name +
-    cat /​etc/​apparmor.d/​profile.name | sudo apparmor_parser -a +
- +
-    AppArmor can be disabledand the kernel module unloaded by entering the following:​ +
- +
-    sudo /etc/init.d/apparmor stop +
-    sudo update-rc.d -f apparmor remove +
- +
-    To re-enable AppArmor enter: +
- +
-    sudo /​etc/​init.d/​apparmor start +
-    sudo update-rc.d apparmor defaults +
- +
-Replace profile.name with the name of the profile you want to manipulate. Also, replace ​/​path/​to/​bin/ ​with the actual executable file pathFor example for the ping command use /bin/ping+
  
 ====Профили==== ====Профили====
  
-AppArmor ​profiles are simple text files located in /​etc/​apparmor.d/​. ​The files are named after the full path to the executable they profile replacing the "/" ​with "​."​. ​For example ​/​etc/​apparmor.d/​bin.ping ​is the AppArmor ​profile for the /​bin/​ping ​command.+Профили **AppArmor** - это простые текстовые файлы, которые расположены в /​etc/​apparmor.d/​. ​Файлы профиля называются соответственно полному пути до исполняемого файла, которым они управляют,​ с заменой символа ​"/" ​на "​."​. ​Например ​/​etc/​apparmor.d/​bin.ping ​ - это профиль ​AppArmor ​для команды ​/bin/ping.
  
-There are two main type of rules used in profiles:+Существует два основных типа правил,​ используемых в профиле:
  
-    ​Path entries: ​which detail which files an application can access in the file system+ 1. **Записи путей** (Path entries)которые описывают к каким файлам приложение имеет доступ в файловой системе
- + 2. **Записи разрешений** (Capability entries)определяют какие права ограничиваемый процесс имеет право использовать.
-    ​Capability entries: ​determine what privileges a confined process is allowed to use. +
- +
-As an example take a look at /​etc/​apparmor.d/​bin.ping:​+
  
 +В качестве примера посмотрим /​etc/​apparmor.d/​bin.ping:​
 +<​code>​
 #include <​tunables/​global>​ #include <​tunables/​global>​
 /bin/ping flags=(complain) { /bin/ping flags=(complain) {
Строка 111: Строка 87:
   /​etc/​modules.conf r,   /​etc/​modules.conf r,
 } }
 +</​code>​
  
-    ​#include <​tunables/​global>: ​include statements from other filesThis allows statements pertaining to multiple applications to be placed in a common file.+  -- **#include <​tunables/​global>​**включает операторы из других файловЭто позволяет операторам,​ относящимся к нескольким приложениям находится в одном общем файле. 
 +  -- **/bin/ping flags=(complain)**:​ путь к программе,​ управляемой профилем,​ также устанавливающий режим обучения. 
 +  -- **capability net_raw,**: разрешает приложению доступ к возможностям CAP_NET_RAW Posix.1e. 
 +  -- **/bin/ping mixr,**: разрешает приложению доступ на чтение и выполнение файла.
  
-    /bin/ping flags=(complain):​ path to the profiled programalso setting the mode to complain. +<​note>​После редактирования файла профиляон должен быть перезагруженДля детальной информации обратитесь к разделу [[wiki:руководство_по_ubuntu_server:безопасность:​apparmor#​использование_apparmor|Использование ​AppArmor]]</​note>​
- +
-    capability net_raw,allows the application access to the CAP_NET_RAW Posix.1e capability. +
- +
-    /bin/ping mixr,allows the application read and execute access to the file. +
- +
-After editing a profile file the profile must be reloaded. See Using AppArmor ​for details.+
  
 ===Создание профиля=== ===Создание профиля===
  
-    Design a test planTry to think about how the application should be exercisedThe test plan should be divided into small test casesEach test case should have a small description and list the steps to follow.+ 1. **Разработка плана тестирования**Попробуйте подумать о том как приложение будет выполняться. План тестирования стоит разделить на маленькие тестовые блоки. Каждый тестовый блок должен иметь краткое описание и перечень шагов выполнения. 
 +Некоторые стандартные тестовые блоки:​ 
 +  -- Запуск программы. 
 +  -- Остановка программы. 
 +  -- Перезагрузка программы. 
 +  -- Тестирование всех команд,​ поддерживаемых сценарием инициализации.
  
-    Some standard test cases are:+ 2. **Создание нового профиля**Используйте **aa-genprof** для создания нового профиля. Команда в терминале:​ 
 +<​code>​sudo aa-genprof executable</​code>​ 
 +Например:​ 
 +<​code>​sudo aa-genprof slapd</​code>​
  
-        Starting the program. + 3Чтобы получить ваш новый профиль в составе пакета **apparmor-profiles**зарегистрируйте проблему в Launchpad ​для пакета [[https://​bugs.launchpad.net/​ubuntu/​+source/​apparmor/​+filebug|AppArmor]]
- +  -- Включите ваш план тестирования и тестовые блоки
-        Stopping the program. +  -- Присоедините ваш новый профиль к зарегистрированной проблеме.
- +
-        Reloading the program. +
- +
-        Testing all the commands supported by the init script. +
- +
-    Generate the new profile: Use aa-genprof to generate a new profile. From a terminal: +
- +
-    sudo aa-genprof executable +
- +
-    For example: +
- +
-    sudo aa-genprof slapd +
- +
-    To get your new profile included in the apparmor-profiles ​packagefile a bug in Launchpad ​against the AppArmor ​package+
- +
-        Include your test plan and test cases+
- +
-        Attach your new profile to the bug.+
  
 ===Обновление профилей=== ===Обновление профилей===
  
-When the program is misbehavingaudit messages are sent to the log filesThe program ​aa-logprof ​can be used to scan log files for AppArmor ​audit messagesreview them and update the profilesFrom a terminal+Когда программа ведет себя неправильнопроанализируйте сообщения отправленные в файлы журналовПрограмма **aa-logprof** может быть использована для сканирования файлов журнала **AppArmor** для проверки сообщенийих рассмотрения (анализа) и обновления профилейКоманда в терминале
- +<​code>​sudo aa-logprof</​code>​
-sudo aa-logprof+
  
 ====Ссылки==== ====Ссылки====
  
-    See the AppArmor Administration Guide for advanced configuration options+  -- Смотрите [[http://​www.novell.com/​documentation/​apparmor/​apparmor201_sp10_admin/​index.html?​page=/​documentation/​apparmor/​apparmor201_sp10_admin/​data/​book_apparmor_admin.html|AppArmor Administration Guide]] для дополнительных опций настройки
- +  -- Для уточнения использования ​AppArmor ​с другими выпусками ​Ubuntu ​смотрите страницу [[https://​help.ubuntu.com/​community/​AppArmor|AppArmor Community Wiki]]
-    For details using AppArmor ​with other Ubuntu ​releases see the AppArmor Community Wiki page+  -- Страница [[http://​en.opensuse.org/​SDB:​AppArmor_geeks|OpenSUSE AppArmor]] - еще одно знакомство с AppArmor. 
- +  -- Хорошее место для вопросов поддержки ​AppArmor ​и вовлечения в сообщество ​Ubuntu Server ​- IRC канал **#​ubuntu-server** на [[http://freenode.net/​|freenode]].
-    The OpenSUSE AppArmor ​page is another introduction to AppArmor. +
- +
-    A great place to ask for AppArmor ​assistance, and get involved with the Ubuntu Server ​community, is the #​ubuntu-server ​IRC channel on freenode. +
  
 ---- ----