シンボリックリンクは SELinux type_transition を許可しません。

シンボリックリンクは SELinux type_transition を許可しません。

SELinux type_transition を使用してシンボリックリンクにアクセスする試みは許可されません。私は、ユーザーが/usr/bin/にあるシンボリックリンクにアクセスでき、バイナリがユーザーディレクトリの親ディレクトリに配置されるようにするシナリオを実装したいということです。元のバイナリ(実行可能)ファイルと対応するシンボリックリンクは同じSELinuxコンテキストを持ち、ユーザーは元のバイナリファイルを含むディレクトリへのアクセス権を持っていませんが、実行、読み取り、およびその他の操作(以下を参照)にアクセスできます。ファイルの場所により、ユーザーはディレクトリを開いたり検索したりできません。ユーザーが「seuser_test_libre_writer_two_t」と入力した場合、この特定のアプリケーション(バイナリ)のポリシーは次のとおりです。

policy_module(test, 1.0.0)
require {
  type seuser_test_libre_writer_two_t;
  class file { getattr relabelto unlink execute append read setattr 
               write create open rename execute_no_trans entrypoint 
               ioctl lock };
  class dir { getattr relabelfrom relabelto read open setattr write 
              create rename search rmdir add_name };
  class process { transition rlimitinh siginh sigchld noatsecure };
  class lnk_file { read getattr };
  role seuser_test_libre_writer_two_r;
}

type selinux_object_hw_test_t;
type selinux_file_hw_test_exec_t;

role seuser_test_libre_writer_two_r types selinux_object_hw_test_t;

type_transition seuser_test_libre_writer_two_t 
                selinux_file_hw_test_exec_t: process 
                selinux_file_hw_test_exec_t;

allow seuser_test_libre_writer_two_t selinux_file_hw_test_exec_t: 
process { transition };

allow selinux_file_hw_test_exec_t selinux_file_hw_test_exec_t: file { 
      execute read write };
allow seuser_test_libre_writer_two_t selinux_file_hw_test_exec_t: file 
      { execute getattr open read };

allow selinux_file_hw_test_exec_t selinux_object_hw_test_t: dir { 
      search getattr };
allow seuser_test_libre_writer_two_t selinux_file_hw_test_exec_t: 
      lnk_file { read };

サッカークラブ:

/opt/test -d gen_context(system_u:object_r:selinux_object_hw_test_t)

/usr/bin/hello_world_link -l 
gen_context(system_u:object_r:selinux_file_hw_test_exec_t)
/opt/test/hw -- 
gen_context(system_u:object_r:selinux_file_hw_test_exec_t)

私のアプリケーションを実行しようとすると、/var/log/audit/audit.logはアクセスを拒否し、avcはソースファイルを含むディレクトリへのユーザーアクセスを許可するように要求します。

type=AVC msg=audit(1545644823.820:11488): avc:  denied  { search } for     pid=12976 comm="bash" name="test" dev="dm-0" ino=2102570 scontext=seuser_test_libre_writer_two_u:seuser_test_libre_writer_two_r:seuser_test_libre_writer_two_t:s0 tcontext=system_u:object_r:selinux_object_hw_test_t:s0 tclass=dir

SELinux "type_transition"をシンボリックリンクで使用できますか?

このリンクを確認しました。」Linuxでシンボリックリンクを使用する方法は?「、」あるディレクトリから別のディレクトリにファイルをコピーするときにファイルのSELinuxラベルを維持する「、」SELinux:ホームディレクトリは、ホームディレクトリ内のファイルのシンボリックリンク、httpdです。「そして」SymlinkのあるパスにSELinuxファイルコンテキストを適用できません。「しかし、それらは問題と完全には関係ありません。

ベストアンサー1

これは不可能です。ラッパーまたは元のバイナリの実際のコピーを作成する必要があります。

おすすめ記事