ホームページ > php教程 > php手册 > selinux | nginx | nginx selinux策略配置

selinux | nginx | nginx selinux策略配置

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
リリース: 2016-06-06 19:39:17
オリジナル
1340 人が閲覧しました

们可以通过ls-Z这个命令来查看我们文件的上下文信息,也就是SELinux信息,我们发现其比传统的ls命令多出来了system_u:object_r:admin_home_t:s0这个东西,我们现在就来分析一下这段语句所代表的含义 system_u:object_r:admin_home_t:s0 这条语句通过:划分成

们可以通过 ls -Z 这个命令来查看我们文件的上下文信息,也就是SELinux信息,我们发现其比传统的 ls 命令多出来了 system_u:object_r:admin_home_t:s0 这个东西,我们现在就来分析一下这段语句所代表的含义

system_u:object_r:admin_home_t:s0

这条语句通过:划分成了四段,第一段 system_u 代表的是用户,第二段 object_r 表示的是角色,第三段是SELinux中最重要的信息,admin_home 表示的是类型,最后一段 s0 是跟MLS、MCS相关的东西,暂时不需要管
①system_u  指的是SElinux用户,root表示root账户身份,user_u表示普通用户无特权用户,system_u表示系统进程,通过用户可以确认身份类型,一般搭配角色使用。身份和不同的角色搭配时有权限不同,虽然可以使用su命令切换用户但对于SElinux的用户并没有发生改变,账户之间切换时此用户身份不变,在targeted策略环境下用户标识没有实质性作用。

②object_r  object_r一般为文件目录的角色、system_r一般为进程的角色,在targeted策略环境中用户的角色一般为system_r。用户的角色类似用户组的概念,不同的角色具有不同的身份权限,一个用户可以具备多个角色,但是同一时间只能使用一个角色。在targeted策略环境下角色没有实质作用,在targeted策略环境中所有的进程文件的角色都是system_r角色。

③admin_home  文件和进程都有一个类型,SElinux依据类型的相关组合来限制存取权限。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

ls -Z -d /usr/share/nginx/html

drwxr-xr-x. root root system_u:object_r:usr_t:s0       /usr/share/nginx/html

 

 

ls -z -d /data/web/default

 

drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /data/web/default

 

 

//==============================================================================//

 

chcon -R -u system_u /data/web/default/

 

chcon -R -t usr_t /data/web/default/

ログイン後にコピー

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

SYNOPSIS

       chcon [OPTION]... CONTEXT FILE...

       chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...

       chcon [OPTION]... --reference=RFILE FILE...

 

DESCRIPTION

       Change the security context of each FILE to CONTEXT.  With --reference,

       change the security context of each FILE to that of RFILE.

 

       -h, --no-dereference

              affect symbolic links instead of any referenced file

 

       --reference=RFILE

              use RFILE's security context rather than  specifying  a  CONTEXT

              value

 

       -R, --recursive

              operate on files and directories recursively

 

       -v, --verbose

              output a diagnostic for every file processed

 

       -u, --user=USER

              set user USER in the target security context

 

       -r, --role=ROLE

              set role ROLE in the target security context

 

       -t, --type=TYPE

              set type TYPE in the target security context

 

       -l, --range=RANGE

              set range RANGE in the target security context

 

       The  following  options modify how a hierarchy is traversed when the -R

       option is also specified.  If more than  one  is  specified,  only  the

       final one takes effect.

 

       -H     if  a  command  line argument is a symbolic link to a directory,

              traverse it

 

       -L     traverse every symbolic link to a directory encountered

 

       -P     do not traverse any symbolic links (default)

 

       --help display this help and exit

 

       --version

              output version information and exit

ログイン後にコピー

関連ラベル:
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
人気のおすすめ
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート