Translated message

A translation of this page exists in English.

CLI での SELinux の基本的なトラブルシューティング

更新 -

[本文]
SELinux は、システム上で実行されているすべてのプロセスを分離して、権限昇格を利用した攻撃を軽減します。権限昇格とは、あるプロセスが本来持つべき以上のアクセス権を獲得することを意味します。

これを防ぐために、SELinux はすべてのプロセスに対して Mandatory Access Control (MAC) メカニズムを適用します。SELinux ポリシーと呼ばれるセキュリティーポリシーで指定されたルールに従って、すべてのプロセス、ファイル、またはディレクトリーにラベルを付けます。

SELinux ポリシーは、プロセスが相互にやり取りする方法と、プロセスがファイルやディレクトリーにアクセスする方法も指定します。SELinux は、SELinux ポリシーで明示的に許可されていないすべてのアクションを拒否します。

SELinux がアクションを拒否する最も一般的な原因は次のとおりです。

  • プロセス、ファイル、またはディレクトリーが、誤った SELinux コンテキストでラベル付けされている
  • 制限付きプロセスが、デフォルトの SELinux ポリシーで期待されるものとは異なる方法で設定されている
  • SELinux ポリシーまたはアプリケーションにバグがある

コマンドラインでの SELinux AVC メッセージのトラブルシューティング

SELinux がアクションを拒否すると、Access Vector Cache (AVC) メッセージが /var/log/audit/audit.log および /var/log/messages ファイルに記録されるか、journald デーモンが記録します。実行しようとしたアクションが SELinux によって拒否されたと思われる場合は、次の基本的なトラブルシューティング手順に従ってください。

  1. ausearch ユーティリティーを使用して最近の AVC メッセージを検索し、SELinux がアクションを拒否することを確認します。

    # ausearch -m AVC,USER_AVC -ts recent
    time->Thu Feb 18 14:24:24 2016
    type=AVC msg=audit(1455805464.059:137): avc:  denied  { append } for  pid=861 comm="httpd" name="error_log" dev="sdb1" ino=20747 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=file permissive=0
    

    -m オプションは、ausearch が返す情報の種類を指定します。-ts オプションは、タイムスタンプを指定します。たとえば、-ts recent は過去 10 分間の AVC メッセージを返し、-ts today は 1 日全体のメッセージを返します。

  2. journalctl ユーティリティーを使用して、AVC メッセージの詳細情報を表示します。

    # journalctl -t setroubleshoot --since= [time]
    

    [time] を、最初の手順で見つけた AVC メッセージの時刻に置き換えます。この例では、SELinux は httpd プロセスが /var/log/httpd/error_log ファイルにアクセスするのを防ぎました。

        # journalctl -t setroubleshoot --since=14:20
    -- Logs begin at Fri 2016-01-15 01:17:17 UTC, end at Thu 2016-02-18 14:25:21 UTC. --
    Feb 18 14:24:24 fedora.23.virt setroubleshoot[866]: SELinux is preventing httpd from append access on the file error_log. For complete SELinux messages. run sealert -l e9d8fa2e-3608-4ffa-9e72-31a1b85e460b
    
  3. AVC メッセージをさらに調べるには、sealert ユーティリティーを使用します。

    # sealert -l [message_ID]
    

    [message_ID] を AVC メッセージの番号に置き換えます。出力は、次の例のようになります。

    • この例では、SELinux タイプの var_log_t で誤ってラベル付けされていたため、SELinux は httpd プロセスが /var/log/httpd/error_log ファイルにアクセスするのを阻止しました。

      # sealert -l e9d8fa2e-3608-4ffa-9e72-31a1b85e460b
          SELinux is preventing httpd from open access on the file /var/log/httpd/error_log.
      
      ***** Plugin restorecon (99.5 confidence) suggests   **************************
      
      If you want to fix the label.
          /var/log/httpd/error.log default label should be httpd_log_t.
          Then you can run restorecon.
          Do
          # /sbin/restorecon -v /var/log/httpd/error_log
      
      [trimmed for clarity]
      
    • この例では、mozilla_plugin_can_network_connect および mozilla_plugin_use_bluejeans ブール値が有効になっていないため、SELinux は plugin-containe プロセスが TCP プロトコルを使用してネットワークに接続すること、および Bluejeans サービスを使用することを阻止しました。

      # sealert -l fc46b9d4-e5a1-4738-95a7-26616d0858b0
      SELinux is preventing plugin-containe from name_connect access on the tcp_socket port 5000.
      
      *****  Plugin catchall_boolean (9.19 confidence) suggests   ******************
      
      If you want to allow mozilla plugin domain to connect to the network using TCP.
      Then you must tell SELinux about this by enabling the 'mozilla_plugin_can_network_connect' boolean.
      You can read 'mozilla_selinux' man page for more details.
      Do
      setsebool -P mozilla_plugin_can_network_connect 1
      
      *****  Plugin catchall_boolean (9.19 confidence) suggests   ******************
      
      If you want to allow mozilla plugin to use Bluejeans.
      Then you must tell SELinux about this by enabling the 'mozilla_plugin_use_bluejeans' boolean.
      You can read 'mozilla_selinux' man page for more details.
      Do
      setsebool -P mozilla_plugin_use_bluejeans 1
      
      [trimmed for clarity]
      
    • この例では、 passwd による user_home_t SELinux タイプのラベルが付いたファイルへの書き込みを許可するルールが SELinux ポリシーにないため、SELinux は passwd プロセスによる /home/user/output.txt ファイルへのアクセスを拒否しました。

      # sealert -l 1dd524dd-1784-44ef-b6d1-fff9238ed927
      
      SELinux is preventing passwd from write access on the file /home/user/output.txt.
      
      *****  Plugin catchall (100. confidence) suggests   **************************
      
      If you believe that passwd should be allowed write access on the output.txt file by default.
      Then you should report this as a bug.
      You can generate a local policy module to allow this access.
      Do
      allow this access for now by executing:
      # grep passwd /var/log/audit/audit.log | audit2allow -M mypol
      # semodule -i mypol.pp
      
      [trimmed for clarity]
      
  4. sealert の提案に従ってアクションを実行します。たとえば、restorecon ユーティリティーを使用して、誤ってラベル付けされたファイルを修正したり、特定のブール値を有効にしたりします。sealert が適切なヒントを提供しない場合、または提案を実装する方法がわからない場合、サポートにお問い合わせください。SELinux ポリシーにバグがあると思われる場合は、バグを報告 してください。

  5. SELinux が拒否する前に実行を試みたアクションを繰り返します。それでも SELinux がアクションを阻止する場合は バグを報告 してください。

追加情報:

Comments