差分
このページの2つのバージョン間の差分を表示します。
| 次のリビジョン | 前のリビジョン | ||
| ja:documentation:pandorafms:cybersecurity:09_selinux_configuration [2025/08/08 22:30] – 作成 junichi | ja:documentation:pandorafms:cybersecurity:09_selinux_configuration [2025/08/30 23:18] (現在) – [概要] junichi | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | a | + | ====== SELinux 設定 ====== |
| + | |||
| + | {{indexmenu_n> | ||
| + | |||
| + | [[ja: | ||
| + | |||
| + | |||
| + | |||
| + | ===== 概要 ===== | ||
| + | |||
| + | In Pandora FMS, the installation should always be done with <wrap : | ||
| + | |||
| + | Pandora FMS では、インストールは常に Security-Enhanced Linux (**SELinux**) を無効にして行う必要があります。 インストール後、環境によって有効にする必要がある場合の設定について詳しく説明します。 | ||
| + | |||
| + | <wrap #ks2 /> | ||
| + | |||
| + | ===== Rocky Linux 8 ===== | ||
| + | |||
| + | <wrap #ks2_1 /> | ||
| + | ==== Audit2allow のインストール ==== | ||
| + | |||
| + | To create this type of rules, **Audit2allow** is used, which will be in charge of allowing the necessary actions. | ||
| + | |||
| + | **Audit2allow** を利用したルールを作成します。これは必要なアクションを許可する役割を持ちます。 | ||
| + | |||
| + | Before starting to create the rules for the policies, you may need to install | ||
| + | |||
| + | ポリシーのルール作成を開始する前に、**Audit2allow** を使用できるようにいくつかのパッケージをインストールする必要がある場合があります。 | ||
| + | |||
| + | Enter in the command terminal with **root** key or equivalent rights (prefix the command **sudo**): | ||
| + | |||
| + | **root** または同等の権限でコマンドラインから入力します (コマンドの先頭に **sudo** を付けます): | ||
| + | |||
| + | <code bash> | ||
| + | dnf install selinux-policy-devel -y | ||
| + | dnf install policycoreutils-python-utils -y | ||
| + | </ | ||
| + | |||
| + | <wrap #ks2_2 /> | ||
| + | ==== SELinux ログディレクトリの場所 ==== | ||
| + | |||
| + | The errors returned by **SELinux** can be found in the following paths: | ||
| + | |||
| + | **SELinux** が返すエラーは、以下にあります。 | ||
| + | |||
| + | * ''/ | ||
| + | * ''/ | ||
| + | |||
| + | In case of updating Pandora FMS by **OUM** you should modify the **logrotate** file [[: | ||
| + | |||
| + | **OUM** によって Pandora FMS を更新する場合は、[[: | ||
| + | |||
| + | To check more clearly what **SELinux** blocks, it is recommended to delete the previous //logs// and wait for them to be generated again with new records. | ||
| + | |||
| + | **SELinux** がブロックするものをより明確に確認するには、以前の //logs// を削除し、新しいレコードで再度生成されるまで待つことをお勧めします。 | ||
| + | |||
| + | **syslog** must be stopped (this service could also be called **rsyslog**). Enter in the command terminal with **root** key or equivalent rights (prefix the command **sudo**): | ||
| + | |||
| + | **syslog** を停止する必要があります (このサービスは **rsyslog** とも呼ばれます)。**root** または同等の権限でコマンドターミナルに入力します (コマンドの前に **sudo** を付けます)。 | ||
| + | |||
| + | <code bash> | ||
| + | systemctl stop syslog | ||
| + | </ | ||
| + | |||
| + | The '' | ||
| + | |||
| + | '' | ||
| + | |||
| + | <code bash> | ||
| + | rm / | ||
| + | </ | ||
| + | |||
| + | Restart **syslog** (this service could also be called **rsyslog**): | ||
| + | |||
| + | **syslog** を再起動します (このサービスは **rsyslog** とも呼ばれます)。 | ||
| + | |||
| + | <code bash> | ||
| + | systemctl start syslog | ||
| + | </ | ||
| + | |||
| + | <wrap #ks2_3 /> | ||
| + | |||
| + | ==== SELinux 設定 ==== | ||
| + | |||
| + | To configure **SELinux** to the desired value, modify its configuration file ''/ | ||
| + | |||
| + | **SELinux** を設定するには、設定ファイル ''/ | ||
| + | |||
| + | < | ||
| + | # This file controls the state of SELinux on the system. | ||
| + | # SELINUX= can take one of these three values: | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | SELINUX=enforcing | ||
| + | # SELINUXTYPE= can take one of these two values: | ||
| + | # | ||
| + | # mls - Multi Level Security protection. | ||
| + | SELINUXTYPE=targeted | ||
| + | </ | ||
| + | |||
| + | * If you need **SELinux** to run in restrictive mode, allowing to execute only what appears within the module rules, you must set it to '' | ||
| + | * If instead you need to print warnings (// | ||
| + | |||
| + | * **SELinux** を制限モードで実行し、モジュールルール内に表示されているものだけを実行できるようにする必要がある場合は、これを '' | ||
| + | * アクションをブロックするのではなく、警告 (// | ||
| + | |||
| + | <wrap #ks2_4 /> | ||
| + | |||
| + | ==== ポリシールールを作成するためのエントリーの検索 ==== | ||
| + | |||
| + | To display the latest //logs// entries, enter the command terminal with **root** key or equivalent rights (prefix the command with **sudo**): | ||
| + | |||
| + | 最新の //ログ// エントリを表示するには、**root** または同等の権限でコマンドターミナルを入力します (コマンドの前に **sudo** を付けます)。 | ||
| + | |||
| + | <code bash> | ||
| + | tail -f / | ||
| + | </ | ||
| + | |||
| + | You may notice that errors will be displayed, for example: | ||
| + | |||
| + | 次のようなエラーが表示される場合があります。 | ||
| + | |||
| + | < | ||
| + | type=AVC msg=audit(1431437562.755: | ||
| + | </ | ||
| + | |||
| + | To convert these errors into rules that **SELinux** can interpret, you must execute: | ||
| + | |||
| + | これらのエラーを **SELinux** が解釈できるルールに変換するには、以下を実行する必要があります。 | ||
| + | |||
| + | <code bash> | ||
| + | grep collections / | ||
| + | </ | ||
| + | |||
| + | This will create two files in the current directory: | ||
| + | |||
| + | これにより、現在のディレクトリに 2 つのファイルが作成されます。 | ||
| + | |||
| + | < | ||
| + | pandora.pp | ||
| + | pandora.te | ||
| + | </ | ||
| + | |||
| + | To activate the new rule you must execute: | ||
| + | |||
| + | 新しいルールを有効にするには、以下を実行する必要があります。 | ||
| + | |||
| + | <code bash> | ||
| + | sudo semodule -i pandora.pp | ||
| + | </ | ||
| + | |||
| + | Repeat the process to add the missing rules. After adding all the rules, **SELinux** will stop reporting errors. | ||
| + | |||
| + | 不足しているルールを追加するには、このプロセスを繰り返します。すべてのルールを追加すると、**SELinux** はエラーの報告をしなくなります。 | ||
| + | |||
| + | <wrap #ks2_5 /> | ||
| + | |||
| + | ==== Pandora FMS の適切な動作に必要なルール ==== | ||
| + | |||
| + | For Pandora FMS to be able to execute all the services correctly, rules should be created for the following features: | ||
| + | |||
| + | Pandora FMS が実行するすべてのサービスが正しく動作するようにしたい場合は、次の操作を許可するいくつかのルールを作成する必要があります。 | ||
| + | |||
| + | * Create, update and delete collections. | ||
| + | * Sending e-mail messages using scheduled tasks (**Cronjob**). | ||
| + | * Remote agent configuration. | ||
| + | * Monitoring **snmptrapd**. | ||
| + | * Monitoring **NetFlow**. | ||
| + | |||
| + | * コレクションの作成、更新、削除 | ||
| + | * 計画タスクによるメール送信 (cronジョブ) | ||
| + | * エージェントのリモート設定 | ||
| + | * **snmptrapd** 監視 | ||
| + | * **NetFlow** 監視 | ||
| + | |||
| + | Otherwise, **SELinux** will block any action associated with these features. | ||
| + | |||
| + | そうでないと、**SELinux** はこれらの操作に関連するアクションをブロックします。 | ||
| + | |||
| + | A way to unite all these rules in one, to be able to use Pandora FMS completely, would be: | ||
| + | |||
| + | これらすべてのルールを 1 つに統合して、Pandora FMS を完全に使用できるようにする方法は次のとおりです。 | ||
| + | |||
| + | <code bash> | ||
| + | grep -e data_in -e collections -e var_spool_t -e zip -e md5 -e denied / | ||
| + | </ | ||
| + | |||
| + | Then you should repeat the step described above to activate the rule. This would cover all possible conflicts between Pandora FMS and **SELinux**. Enter in the command terminal with **root** key or equivalent rights (prefix the command **sudo**): | ||
| + | |||
| + | 次に、上記の手順を繰り返してルールを有効にします。これにより、Pandora FMS と **SELinux** 間のすべての競合が解消されます。**root** または同等の権限 (コマンドの前に **sudo** を付けます) を使用してコマンドターミナルに入力します。 | ||
| + | |||
| + | <code bash> | ||
| + | sudo semodule -i pandora.pp | ||
| + | </ | ||
| + | |||
| + | <wrap #ks2_5_1 /> | ||
| + | |||
| + | === 実践的なまとめ === | ||
| + | |||
| + | The rules to use **SELinux** with Pandora FMS are summarized, //taking into account that for each particular case the values and parameters should be changed in a customized way// such as '' | ||
| + | |||
| + | Pandora FMS で **SELinux** を使用するためのルールがまとめられています。特定のケースごとに、値とパラメータを '' | ||
| + | |||
| + | The **setsebool** command is a tool for setting // | ||
| + | |||
| + | **setsebool** コマンドは、**SELinux** の // | ||
| + | |||
| + | <code bash> | ||
| + | setsebool -P httpd_unified 1 | ||
| + | setsebool -P httpd_read_user_content 1 | ||
| + | setsebool -P httpd_can_network_connect 1 | ||
| + | setsebool -P httpd_execmem 1 | ||
| + | setsebool -P httpd_can_network_connect_db 1 | ||
| + | setsebool -P httpd_can_connect_ldap 1 | ||
| + | setsebool -P authlogin_nsswitch_use_ldap 1 | ||
| + | setsebool -P nis_enabled 1 | ||
| + | setsebool -P httpd_setrlimit 1 | ||
| + | </ | ||
| + | |||
| + | The **chcon** command changes the **SELinux** context of files. The '' | ||
| + | |||
| + | **chcon** コマンドは、ファイルの **SELinux** コンテキストを変更します。'' | ||
| + | |||
| + | <code bash> | ||
| + | chcon -R -t httpd_sys_content_rw_t / | ||
| + | chcon -R -t httpd_sys_content_rw_t / | ||
| + | chcon -R -t httpd_sys_content_rw_t /tmp/ | ||
| + | </ | ||
| + | |||
| + | The following rules are added, always remembering the necessary customization for each case. Enter in the command terminal with **root** key or equivalent rights (prefix the command **sudo**): | ||
| + | |||
| + | 以下のルールが追加され、それぞれのケースで必要なカスタマイズが常に適用されます。**root** または同等の権限でコマンドターミナルに入力します (コマンドの前に **sudo** を付けます)。 | ||
| + | |||
| + | <code bash> | ||
| + | echo ' | ||
| + | echo ' | ||
| + | echo ' | ||
| + | </ | ||
| + | |||
| + | The following command is used to create the rules in a file named '' | ||
| + | |||
| + | 次のコマンドは、'' | ||
| + | |||
| + | <code bash> | ||
| + | audit2allow -a -M rules_apply | ||
| + | </ | ||
| + | |||
| + | The rules created in the previous step with the **semodule** command are applied: | ||
| + | |||
| + | 前の手順で **semodule** コマンドを使用して作成されたルールが適用されます。 | ||
| + | |||
| + | <code bash> | ||
| + | semodule -i rules_apply.pp | ||
| + | </ | ||
| + | |||
| + | <wrap #ks3 /> | ||
| + | |||
| + | [[ja: | ||
| + | |||
| + | ===== (OBSOLETE) CentOS 7 ===== | ||
| + | |||
| + | ==== Audit2allow のインストール ==== | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | |||
| + | CentOS 7 will soon reach its end of life (**EOL**). //This documentation is retained for historical purposes.// | ||
| + | |||
| + | </ | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | |||
| + | CentOS 7 はまもなくサポート終了(**EOL**)になります。 // | ||
| + | |||
| + | </ | ||
| + | |||
| + | To create this type of rules use **Audit2allow**, | ||
| + | |||
| + | **Audit2allow** を利用したルールを作成します。これは必要なアクションを許可する役割を持ちます。 | ||
| + | |||
| + | Before you start creating the rules for the policies, you may need to install a number of packages to be able to use Audit2allow. enter in the command terminal with root or equivalent rights (prefix the command with **sudo**): | ||
| + | |||
| + | ポリシーのルール作成を開始する前に、Audit2allow を使用できるようにいくつかのパッケージをインストールする必要がある場合があります。 root または同等の権限でコマンドラインから入力します (コマンドの先頭に **sudo** を付けます): | ||
| + | |||
| + | < | ||
| + | |||
| + | yum install selinux-policy-devel -y | ||
| + | yum install policycoreutils-python -y | ||
| + | |||
| + | </ | ||
| + | |||
| + | ==== SELinux ディレクトリの場所 ==== | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | |||
| + | CentOS 7 will soon reach its end of life (**EOL**). //This documentation is retained for historical purposes.// | ||
| + | |||
| + | </ | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | |||
| + | CentOS 7 はまもなくサポート終了(**EOL**)になります。 // | ||
| + | |||
| + | </ | ||
| + | |||
| + | SELinux が返すエラーは、以下にあります。 | ||
| + | |||
| + | * / | ||
| + | * / | ||
| + | |||
| + | **IMPORTANT: | ||
| + | |||
| + | **重要: | ||
| + | |||
| + | In versions prior to 747, the audit log path is: **/ | ||
| + | |||
| + | バージョン 747 までは、監査ログのパスは **/ | ||
| + | |||
| + | If updating from **OUM** | ||
| + | |||
| + | **OUM** からアップデートした場合は、**logrotate** [[: | ||
| + | |||
| + | In order to check the cleanest way, we highly recomend to remove previous logs and wait until it are generated again with new records. | ||
| + | |||
| + | 確認をしやすくするために、すでに出ているログを削除し新たなログが出るまで待つことを強くお勧めします。 | ||
| + | |||
| + | syslog を停止します。(rsyslog の場合もあります) | ||
| + | |||
| + | < | ||
| + | |||
| + | # / | ||
| + | |||
| + | </ | ||
| + | |||
| + | audit.log とシステムのメッセージログファイルを削除します。 | ||
| + | |||
| + | < | ||
| + | # rm / | ||
| + | |||
| + | </ | ||
| + | |||
| + | syslog を再開します。 | ||
| + | |||
| + | < | ||
| + | # / | ||
| + | |||
| + | </ | ||
| + | |||
| + | ==== SELinux 設定 ==== | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | |||
| + | CentOS 7 will soon reach its end of life (**EOL**). //This documentation is retained for historical purposes.// | ||
| + | |||
| + | </ | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | |||
| + | CentOS 7 はまもなくサポート終了(**EOL**)になります。 // | ||
| + | |||
| + | </ | ||
| + | |||
| + | SELinux を希望の内容で設定するには、設定ファイルを編集します。 | ||
| + | |||
| + | < | ||
| + | # This file controls the state of SELinux on the system. | ||
| + | # SELinux= can take one of these three values: | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | SELinux=enforcing | ||
| + | # SELinuxTYPE= can take one of these two values: | ||
| + | # | ||
| + | # mls - Multi Level Security protection. | ||
| + | SELinuxTYPE=targeted | ||
| + | </ | ||
| + | |||
| + | プログラムの実行に制限を付けるには、SELinux を " | ||
| + | |||
| + | ==== ポリシールールを作成するためのエントリーの検索 ==== | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | |||
| + | CentOS 7 will soon reach its end of life (**EOL**). //This documentation is retained for historical purposes.// | ||
| + | |||
| + | </ | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | |||
| + | CentOS 7 はまもなくサポート終了(**EOL**)になります。 // | ||
| + | |||
| + | </ | ||
| + | |||
| + | 最新のログを見るにはつぎのようにします。 | ||
| + | |||
| + | < | ||
| + | # tail -f / | ||
| + | |||
| + | </ | ||
| + | |||
| + | 次のようないくつかのエラーがみつかります。 | ||
| + | |||
| + | < | ||
| + | # type=AVC msg=audit(1431437562.755: | ||
| + | |||
| + | </ | ||
| + | |||
| + | これらのエラーを SELinux ルールに変換します。 | ||
| + | |||
| + | < | ||
| + | # grep collections / | ||
| + | |||
| + | </ | ||
| + | |||
| + | 実行すると 2つの新たなファイルが作成されます。 | ||
| + | |||
| + | < | ||
| + | - pandora.pp | ||
| + | - pandora.te | ||
| + | </ | ||
| + | |||
| + | 新たなルールを有効化するには、次のようにします。 | ||
| + | |||
| + | < | ||
| + | # sudo semodule -i pandora.pp | ||
| + | |||
| + | </ | ||
| + | |||
| + | エラーが出たものをルールに追加する対応を繰り返します。その後、SELinux からエラーの出力がなくなります。 | ||
| + | |||
| + | ==== Pandora FMS の適切な動作に必要なルール ==== | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | |||
| + | CentOS 7 will soon reach its end of life (**EOL**). //This documentation is retained for historical purposes.// | ||
| + | |||
| + | </ | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | |||
| + | CentOS 7 はまもなくサポート終了(**EOL**)になります。 // | ||
| + | |||
| + | </ | ||
| + | |||
| + | Pandora FMS が実行するすべてのサービスが正しく動作するようにしたい場合は、次の操作を許可するいくつかのルールを作成する必要があります。 | ||
| + | |||
| + | - コレクションの作成、更新、削除 | ||
| + | |||
| + | - プログラムタスクによるメール送信 (cronジョブ) | ||
| + | |||
| + | - エージェントのリモート設定 | ||
| + | |||
| + | 逆にいうと、SELinux はこれらの操作に関連するアクションをブロックします。 | ||
| + | |||
| + | SELinux が有効化された状態で Pandora FMS を利用するためのルールを追加するには、次のようにします。 | ||
| + | |||
| + | # grep -e data_in -e collections -e var_spool_t -e zip -e md5 -e denied / | ||
| + | |||
| + | その後、ルールを有効化するための前述の対応を行う必要があります。 | ||
| + | |||
| + | # sudo semodule -i pandora.pp | ||
| + | |||
| + | |||
| + | [[ja: | ||