您好,欢迎访问一九零五行业门户网

selinux | nginx | nginx selinux策略配置

们可以通过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_robject_r一般为文件目录的角色、system_r一般为进程的角色,在targeted策略环境中用户的角色一般为system_r。用户的角色类似用户组的概念,不同的角色具有不同的身份权限,一个用户可以具备多个角色,但是同一时间只能使用一个角色。在targeted策略环境下角色没有实质作用,在targeted策略环境中所有的进程文件的角色都是system_r角色。
③admin_home文件和进程都有一个类型,selinux依据类型的相关组合来限制存取权限。
ls -z -d /usr/share/nginx/htmldrwxr-xr-x. root root system_u:object_r:usr_t:s0 /usr/share/nginx/htmlls -z -d /data/web/defaultdrwxr-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/
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
其它类似信息

推荐信息