欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

SELinux系統(tǒng)的基本操作方法-創(chuàng)新互聯(lián)

這篇文章為大家?guī)?lái)有關(guān)SELinux系統(tǒng)的基本操作方法。大部分命令以及方法都是大家經(jīng)常用到的,為此分享給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧。

創(chuàng)新互聯(lián)堅(jiān)信:善待客戶(hù),將會(huì)成為終身客戶(hù)。我們能堅(jiān)持多年,是因?yàn)槲覀円恢笨芍档眯刨?lài)。我們從不忽悠初訪客戶(hù),我們用心做好本職工作,不忘初心,方得始終。10年網(wǎng)站建設(shè)經(jīng)驗(yàn)創(chuàng)新互聯(lián)是成都老牌網(wǎng)站營(yíng)銷(xiāo)服務(wù)商,為您提供成都網(wǎng)站建設(shè)、做網(wǎng)站、網(wǎng)站設(shè)計(jì)、HTML5、網(wǎng)站制作、品牌網(wǎng)站設(shè)計(jì)重慶小程序開(kāi)發(fā)公司服務(wù),給眾多知名企業(yè)提供過(guò)好品質(zhì)的建站服務(wù)。

1、什么是SELinux

SELinux(Security-Enhanced Linux) 是美國(guó)國(guó)家安全局(NSA)對(duì)于強(qiáng)制訪問(wèn)控制的實(shí)現(xiàn),是Linux歷史上最杰出的新安全子系統(tǒng)。NSA是在Linux社區(qū)的幫助下開(kāi)發(fā)了一種訪問(wèn)控制體系,在這種訪問(wèn)控制體系的限制下,進(jìn)程只能訪問(wèn)那些在他的任務(wù)中所需要文件。SELinux默認(rèn)安裝在Fedora和Red Hat Enterprise Linux上,也可以作為其他發(fā)行版上容易安裝的包得到。
SELinux是2.6版本的Linux內(nèi)核中提供的強(qiáng)制訪問(wèn)控制(MAC)系統(tǒng)。對(duì)于目前可用的 Linux安全模塊來(lái)說(shuō),SELinux 是功能最全面,而且測(cè)試最充分的,它是在 20 年的 MAC 研究基礎(chǔ)上建立的。SELinux在類(lèi)型強(qiáng)制服務(wù)器中合并了多級(jí)安全性或一種可選的多類(lèi)策略,并采用了基于角色的訪問(wèn)控制概念。
大部分使用 SELinux 的人使用的都是SELinux就緒的發(fā)行版,例如 Fedora、Red Hat Enterprise Linux(RHEL)、Debian或 Centos。它們都是在內(nèi)核中啟用SELinux的,并且提供一個(gè)可定制的安全策略,還提供很多用戶(hù)層的庫(kù)和工具,它們都可以使用 SELinux 的功能。
SELinux是一種基于 域-類(lèi)型 模型(domain-type)的強(qiáng)制訪問(wèn)控制(MAC)安全系統(tǒng),它由NSA編寫(xiě)并設(shè)計(jì)成內(nèi)核模塊包含到內(nèi)核中,相應(yīng)的某些安全相關(guān)的應(yīng)用也被打了SELinux的補(bǔ)丁,最后還有一個(gè)相應(yīng)的安全策略。任何程序?qū)ζ滟Y源享有完全的控制權(quán)。假設(shè)某個(gè)程序打算把含有潛在重要信息的文件扔到/tmp目錄下,那么在DAC情況下沒(méi)人能阻止他。SELinux提供了比傳統(tǒng)的UNIX權(quán)限更好的訪問(wèn)控制

2、SELinux的運(yùn)行模式
●  主體 (Subject):
SELinux 主要想要管理的就是程序,因此你可以將『主體』跟 process 劃上等號(hào);

●   目標(biāo) (Object):
主體程序能否存取的『目標(biāo)資源』一般就是文件系統(tǒng)。因此這個(gè)目標(biāo)項(xiàng)目可以等文件系統(tǒng)劃上等號(hào);

●   策略 (Policy):
由于程序與檔案數(shù)量龐大,因此 SELinux 會(huì)依據(jù)某些服務(wù)來(lái)制訂基本的存取安全性政策。這些政策內(nèi)還會(huì)有詳細(xì)的規(guī)則 (rule) 來(lái)指定不同的服務(wù)開(kāi)放某些資源的存取與否。在目前的 CentOS 6.x 里面僅有提供兩個(gè)主要的政策如下,一般來(lái)說(shuō),使用預(yù)設(shè)的 target 政策即可。
     targeted:針對(duì)網(wǎng)絡(luò)服務(wù)限制較多,針對(duì)本機(jī)限制較少,是預(yù)設(shè)的政策;
     strict:完整的 SELinux 限制,限制方面較為嚴(yán)格。

●  安全性本文 (security context):
我們剛剛談到了主體、目標(biāo)與政策面,但是主體能不能存取目標(biāo)除了要符合政策指定之外,主體與目標(biāo)的安全性本文必須一致才能夠順利存取。 這個(gè)安全性本文 (security context) 有點(diǎn)類(lèi)似文件系統(tǒng)的 rwx 啦!安全性本文的內(nèi)容與設(shè)定是非常重要的! 如果設(shè)定錯(cuò)誤,你的某些服務(wù)(主體程序)就無(wú)法存取文件系統(tǒng)(目標(biāo)資源),當(dāng)然就會(huì)一直出現(xiàn)“權(quán)限不符”的錯(cuò)誤訊息了!
SELinux系統(tǒng)的基本操作方法
(1)主體程序必須要通過(guò) SELinux 政策內(nèi)的規(guī)則放行后,就可以與目標(biāo)資源進(jìn)行安全性本文的比對(duì)。
(2)若比對(duì)失敗則無(wú)法存取目標(biāo),若比對(duì)成功則可以開(kāi)始存取目標(biāo)。

3、安全性本文(Security Context)
[root@localhost ~]# ll -Z
total 4
-rw-------. 1 root root system_u:object_r:admin_home_t:s0 1193 Feb  9 09:16 anaconda-ks.cfg

●  身份標(biāo)識(shí) (Identify): 相當(dāng)于賬號(hào)方面的身份識(shí)別!主要的身份識(shí)別則有底下三種常見(jiàn)的類(lèi)型:
root:表示 root 的賬號(hào)身份,如同上面的表格顯示的是 root 家目錄下的數(shù)據(jù)!
system_u:表示系統(tǒng)程序方面的識(shí)別,通常就是程序;
user_u:代表的是一般使用者賬號(hào)相關(guān)的身份。

●  角色 (Role): 透過(guò)角色字段,我們可以知道這個(gè)數(shù)據(jù)是屬于程序、檔案資源還是代表使用者。一般的角色有:
object_r:代表的是檔案或目錄等檔案資源,這應(yīng)該是最常見(jiàn)的;
     system_r:代表的就是程序啦!不過(guò),一般使用者也會(huì)被指定成為 system_r !

●  類(lèi)型 (Type): 在預(yù)設(shè)的 targeted 政策中, Identify 與 Role 字段基本上是不重要的!重要的在于這個(gè)類(lèi)型 (type) 字段! 基本上,一個(gè)主體程序能不能讀取到這個(gè)檔案資源,與類(lèi)型字段有關(guān)!而類(lèi)型字段在檔案與程序的定義不太相同,分別是:
type:在檔案資源 (Object) 上面稱(chēng)為類(lèi)型 (Type);
domain:在主體程序 (Subject) 則稱(chēng)為領(lǐng)域 (domain) 了!
domain 需要與 type 搭配,則該程序才能夠順利的讀取檔案資源啦!

4、SELinux的啟動(dòng)、關(guān)閉與查看
SELinux主配置文件介紹:
[root@localhost ~]# cat /etc/selinux/config
SELINUX=enforcing
目前SELinux支持三種模式,分別如下:
●  enforcing:強(qiáng)制模式:代表SELinux正在運(yùn)行中,且已經(jīng)正確開(kāi)始限制domain/type了。
●  permissive:寬容模式:代表SELinux正在運(yùn)行中,不過(guò)僅會(huì)有警告信息并不會(huì)實(shí)際限制domain/type的訪問(wèn)。這種模式可以用來(lái)作為SELinux的調(diào)試之用。
●  disabled:關(guān)閉:SELinux并沒(méi)有實(shí)際運(yùn)行。
SELINUXTYPE=targeted

查看SELinux:
[root@localhost ~]# getenforce
Permissive

[root@localhost ~]# sestatus [-vb]
參數(shù):
-v:檢查列于/etc/sestatus.conf內(nèi)的文件與程序的安全上下文內(nèi)容;
-b:將目前策略的規(guī)則布爾值列出,及某些規(guī)則(rule)是否要啟動(dòng)(0/1)之意;

[root@localhost ~]# sestatus
SELinux status:         enabled
SELinuxfs mount:         /sys/fs/selinux
SELinux root directory:     /etc/selinux
Loaded policy name:       targeted
Current mode:          permissive
Mode from config file:      enforcing
Policy MLS status:        enabled
Policy deny_unknown status:   allowed
Memory protection checking:   actual (secure)
Max kernel policy version:    31

[root@localhost ~]# setenforce [0|1]
參數(shù):
0:轉(zhuǎn)成permissive寬容模式;
1:轉(zhuǎn)成Enforcing強(qiáng)制模式;

啟動(dòng)selinux:
配置文件中啟動(dòng)selinux(需要重啟系統(tǒng))
[root@localhost ~]# cat /etc/selinux/config
SELINUX=enforcing

命令行啟動(dòng)selinux
[root@localhost ~]# setenforce 1

關(guān)閉selinux:
配置文件中關(guān)閉selinux(需要重啟系統(tǒng))
[root@localhost ~]# cat /etc/selinux/config
SELINUX=disabled

命令行啟動(dòng)selinux
[root@localhost ~]# setenforce 0

5、SELinux網(wǎng)絡(luò)服務(wù)運(yùn)行范例
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# echo "123456" > /var/www/html/index.html
[root@localhost ~]# systemctl restart httpd
SELinux系統(tǒng)的基本操作方法
此時(shí)你的瀏覽器會(huì)通過(guò)httpd這個(gè)進(jìn)程擁有的httpd_t這個(gè)domain去讀取/var/www/html/index.html這個(gè)文件。
查看文件的權(quán)限和SELinux的安全上下文數(shù)據(jù):
[root@localhost ~]# ll -Z /var/www/html/index.html
-rw-r--r--. 1 root root unconfined_u:object_r:httpd_sys_content_t:s0 7 Feb 22 20:42 /var/www/html/index.html

創(chuàng)建錯(cuò)誤的SELinux安全上下文:
[root@localhost ~]# echo "My httpd" > index.html
[root@localhost ~]# rm -rf /var/www/html/index.html
[root@localhost ~]# mv index.html /var/www/html/
SELinux系統(tǒng)的基本操作方法
查看index.html的權(quán)限:
[root@localhost ~]# ll -Z /var/www/html/index.html
-rw-r--r--. 1 root root unconfined_u:object_r:admin_home_t:s0 9 Feb 22 20:50 /var/www/html/index.html

修改安全上下文:
chcon命令介紹(修改方式):
[root@localhost ~]# chcon [-R] [-t type] [-u user] [-r role] 文件
[root@localhost ~]# chcon [-R] --reference=范例文件 文件
參數(shù):
-R:連同該目錄下的子目錄也同時(shí)修改;
-t:后面接安全上下文的類(lèi)型字段!例如:httpd_sys_content_t;
-u:后面接身份識(shí)別,例如system_u;
-r:后面接角色,例如system_r;
--reference=范例文件:拿某個(gè)文件當(dāng)范例來(lái)修改后續(xù)接的文件的類(lèi)型!

范例一:以/etc/passwd為依據(jù),將index.html修改成該類(lèi)型
[root@localhost ~]# ll -Z /etc/passwd
-rw-r--r--. 1 root root system_u:object_r:passwd_file_t:s0 1133 Feb 22 20:42 /etc/passwd
[root@localhost ~]# chcon --reference=/etc/passwd /var/www/html/index.html
[root@localhost ~]# ll -Z /var/www/html/index.html
-rw-r--r--. 1 root root system_u:object_r:passwd_file_t:s0 9 Feb 22 20:50 /var/www/html/index.html

范例二:將剛才的index.html類(lèi)型改為httpd_sys_content_t的類(lèi)型
[root@localhost ~]# chcon -t httpd_sys_content_t /var/www/html/index.html
[root@localhost ~]# ll -Z /var/www/html/index.html
-rw-r--r--. 1 root root system_u:object_r:httpd_sys_content_t:s0 9 Feb 22 20:50 /var/www/html/index.html

chcon是通過(guò)直接指定的方式來(lái)處理安全上下文的類(lèi)型數(shù)據(jù),我們都知道系統(tǒng)默認(rèn)的目錄都有特殊的SELinux安全上下文,而restorecon就是恢復(fù)模式的安全上下文的命令。

restorecon(還原方式)
[root@localhost ~]# restorecon [-Rv] 文件或目錄
參數(shù):
-R:連同子目錄一起修改。
-v:將過(guò)程顯示到屏幕上。

范例一:將剛才錯(cuò)誤的index.html以默認(rèn)的安全上下文改正過(guò)來(lái)
[root@localhost ~]# restorecon -Rv /var/www/html/index.html
Relabeled /var/www/html/index.html from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
[root@localhost ~]# ll -Z /var/www/html/index.html
-rw-r--r--. 1 root root unconfined_u:object_r:httpd_sys_content_t:s0 7 Feb 22 21:07 /var/www/html/index.html

6、SELinux日志
setroubleshoot:將錯(cuò)誤信息寫(xiě)入/var/log/message
[root@localhost ~]# cat /var/log/messages | grep setroubleshoot
Feb 22 21:28:27 localhost setroubleshoot[12759]: failed to retrieve rpm info for /var/www/html/index.html
Feb 22 21:28:27 localhost setroubleshoot[12759]: SELinux is preventing /usr/sbin/httpd from getattr access on the file /var/www/html/index.html. For complete SELinux messages run: sealert -l cf1dacbd-e06f-4c52-bbd4-abc3d3cde551

[root@localhost ~]# sealert -l cf1dacbd-e06f-4c52-bbd4-abc3d3cde551
SELinux is preventing /usr/sbin/httpd from getattr access on the file /var/www/html/index.html.  
#<==就是剛才/var/log/messages的信息

*  Plugin restorecon (99.5 confidence) suggests  ****

If you want to fix the label.
/var/www/html/index.html default label should be httpd_sys_content_t.
Then you can run restorecon. The access attempt may have been stopped due to insufficient permissions to access a parent directory in which case try to change the following command accordingly.
Do

/sbin/restorecon -v /var/www/html/index.html

#<==若要允許訪問(wèn),你需要執(zhí)行如上操作。
*  Plugin catchall (1.49 confidence) suggests  **

If you believe that httpd should be allowed getattr access on the index.html 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:

ausearch -c 'httpd' --raw | audit2allow -M my-httpd

semodule -X 300 -i my-httpd.pp

Additional Information:
Source Context         system_u:system_r:httpd_t:s0
Target Context         unconfined_u:object_r:admin_home_t:s0
Target Objects         /var/www/html/index.html [ file ]
Source             httpd
Source Path          /usr/sbin/httpd
Port              <Unknown>
Host              localhost.localdomain
Source RPM Packages      
Target RPM Packages      
Policy RPM           selinux-policy-3.14.1-61.el8.noarch
Selinux Enabled        True
Policy Type          targeted
Enforcing Mode         Enforcing
Host Name           localhost.localdomain
Platform            Linux localhost.localdomain 4.18.0-80.el8.x86_64
#1 SMP Tue Jun 4 09:19:46 UTC 2019 x86_64 x86_64
Alert Count          10
First Seen           2020-02-22 21:28:26 EST
Last Seen           2020-02-22 21:28:41 EST
Local ID            cf1dacbd-e06f-4c52-bbd4-abc3d3cde551

Raw Audit Messages
type=AVC msg=audit(1582424921.167:319): avc:  denied  { getattr } for  pid=11426 comm="httpd" path="/var/www/html/index.html" dev="dm-0" ino=33926150 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file permissive=0

Hash: httpd,httpd_t,admin_home_t,file,getattr

與setroubleshoot不同的是,audit會(huì)將許多的SELinux信息都記錄下來(lái),不只是錯(cuò)誤信息而已,因此日志文件/var/log/audit/audit.log非常龐大。
[root@localhost ~]# audit2why < /var/log/audit/audit.log
type=USER_AVC msg=audit(1581914928.322:67): pid=783 uid=81 auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  denied  { send_msg } for msgtype=error error_name=org.freedesktop.NetworkManager.AlreadyEnabledOrDisabled dest=:1.16 spid=885 tpid=1415 scontext=system_u:system_r:NetworkManager_t:s0 tcontext=system_u:system_r:vmtools_unconfined_t:s0 tclass=dbus permissive=0  exe="/usr/bin/dbus-daemon" sauid=81 hostname=? addr=? terminal=?'UID="dbus" AUID="unset" SAUID="dbus"

Was caused by:
   Missing type enforcement (TE) allow rule.

   You can use audit2allow to generate a loadable module to allow this access.

7、SELinux的策略與規(guī)則管理
一個(gè)主體進(jìn)程能否讀取到目標(biāo)文件資源的重點(diǎn)在于SELinux的策略以及策略?xún)?nèi)的各項(xiàng)規(guī)則,然后再通過(guò)該規(guī)則的定義去處理各目標(biāo)文件的安全上下文,尤其是“類(lèi)型”的部分。

●  策略查詢(xún)
CentOS 8.x默認(rèn)使用targeted策略,那么這個(gè)策略提供多少相關(guān)規(guī)則呢?
可以通過(guò)seinfo來(lái)查詢(xún)。
[root@localhost ~]# yum -y install setools-console.x86_64   #<==安裝命令
[root@localhost ~]# seinfo [-Atrub]
參數(shù):
-A:列出SELinux的狀態(tài)、規(guī)則布爾值、身份識(shí)別、角色、類(lèi)型等所有信息;
-t:列出SELinux的所有類(lèi)型(type)種類(lèi);
-r:列出SELinux的所有角色(role)種類(lèi);
-u:列出SELinux的所有身份標(biāo)識(shí)(user)種類(lèi);
-b:列出所有規(guī)則的種類(lèi)(布爾值)。

范例一:列出SELinux在此策略下的統(tǒng)計(jì)狀態(tài)
[root@localhost ~]# seinfo
Statistics for policy file: /sys/fs/selinux/policy
Policy Version:       31 (MLS enabled)   #<==列出策略所在文件與版本
Target Policy:        selinux
Handle unknown classes:   allow
Classes:       129   Permissions:     452
Sensitivities:     1   Categories:     1024
Types:        4914   Attributes:      251
Users:         8   Roles:         14
Booleans:       324   Cond. Expr.:     370
Allow:       111263   Neverallow:       0
Auditallow:      159   Dontaudit:     10271
Type_trans:    237483   Type_change:      74
Type_member:      35   Range_trans:     6015
Role allow:      39   Role_trans:      424
Constraints:      71   Validatetrans:     0
MLS Constrain:     72   MLS Val. Tran:     0
Permissives:      0   Polcap:         5
Defaults:        7   Typebounds:       0
Allowxperm:       0   Neverallowxperm:    0
Auditallowxperm:    0   Dontauditxperm:     0
Initial SIDs:     27   Fs_use:        33
Genfscon:       105   Portcon:       627
Netifcon:        0   Nodecon:        0

范例二:列出與httpd有關(guān)的規(guī)則(booleana)有哪些
[root@localhost ~]# seinfo -b | grep httpd
httpd_anon_write
httpd_builtin_scripting
httpd_can_check_spam
httpd_can_connect_ftp
httpd_can_connect_ldap
httpd_can_connect_mythtv
httpd_can_connect_zabbix
......(下面省略)......

如果查詢(xún)到相關(guān)的類(lèi)型或者是布爾值后,想要知道詳細(xì)的規(guī)則時(shí),就得要使用sesearch這個(gè)命令了!
[root@localhost ~]# sesearch [-A] [-s 主體類(lèi)型] [-t 目標(biāo)類(lèi)型] [-b 布爾值]
參數(shù):
-A:列出該類(lèi)型或布爾值的所有相關(guān)信息;
-t:后面還要接類(lèi)型,例如-t httpd_t;
-b:后面還要接布爾值的規(guī)則,例如-b httpd_enable_ftp_server;

范例一:找出目標(biāo)文件資源類(lèi)型為httpd_sys_content_t的有關(guān)信息
[root@localhost ~]# sesearch -a -t httpd_sys_content_t

范例二:找出主體進(jìn)程為httpd_t且目標(biāo)文件類(lèi)型為httpd相關(guān)的所有信息
[root@localhost ~]# sesearch -s httpdt -t httpd* -a

范例三:我知道有個(gè)布爾值為httpd_enable_homedirs,請(qǐng)問(wèn)該布爾值設(shè)置了多少規(guī)則?
[root@localhost ~]# sesearch -b httpd_enable_homedirs -A

●  布爾值的查詢(xún)與修改
上面我們通過(guò)sesearch知道了,其實(shí)Subject與Object能否有訪問(wèn)的權(quán)限是與布爾值有關(guān)的,那么系統(tǒng)有多少布爾值可以通過(guò)“seinfo -b”來(lái)查詢(xún),但是每個(gè)布爾值是啟動(dòng)還是關(guān)閉的呢?
這就來(lái)查詢(xún)一下吧:
[root@localhost ~]# getsebool [-a] [布爾值條款]
參數(shù):
-a:列出目前系統(tǒng)上面的所有布爾值條款設(shè)置為開(kāi)啟或關(guān)閉值

范例一:查詢(xún)本系統(tǒng)內(nèi)所有的布爾值設(shè)置狀況
[root@localhost ~]# getsebool -a
abrt_anon_write --> off
abrt_handle_event --> off
abrt_upload_watch_anon_write --> on
antivirus_can_scan_system --> off
antivirus_use_jit --> off
auditadm_exec_content --> on
......(下面省略)......

關(guān)閉和啟動(dòng)某個(gè)布爾值:
[root@localhost ~]# setsebool [-P] 布爾值=[0|1]
參數(shù):
-P:直接將設(shè)置值寫(xiě)入配置文件,該設(shè)置數(shù)據(jù)將來(lái)會(huì)生效的!

范例一:查詢(xún)httpd_enable_homedirs是否為關(guān)閉,若不為關(guān)閉,請(qǐng)關(guān)閉它!
[root@localhost ~]# getsebool httpd_enable_homedirs
httpd_enable_homedirs --> on
[root@localhost ~]# setsebool -P httpd_enable_homedirs=0
[root@localhost ~]# getsebool httpd_enable_homedirs
httpd_enable_homedirs --> off

●  默認(rèn)目錄的安全上下文查詢(xún)與修改
使用semanage查看目錄的默認(rèn)安全上下文:
[root@localhost ~]# semanage {login,user,port,interface,fcontext,translation} -l
[root@localhost ~]# semanage fcontext -{a|d|m} [-frst] file_spec
參數(shù):
fcontext:主要用在安全上下文方面的用途,-l為查詢(xún)的意思;
-a:增加的意思,你可以增加一些目錄的默認(rèn)安全上下文類(lèi)型設(shè)置;
-m:修改的意思;
-d:刪除的意思;

范例一:查詢(xún)一下/var/www/html的默認(rèn)安全上下文設(shè)置
[root@localhost ~]# semanage fcontext -l
......(前面省略)......
/var/www(/.*)?                all files      system_u:object_r:httpd_sys_content_t:s0
......(后面省略)......

范例二:利用semanage設(shè)置/srv/samba目錄的默認(rèn)安全上下文為public_content_t
[root@localhost ~]# mkdir /srv/samba
[root@localhost ~]# ll -Zd /srv/samba/
drwxr-xr-x. 2 root root unconfined_u:object_r:var_t:s0 6 Feb 22 22:46 /srv/samba/
[root@localhost ~]# semanage fcontext -l|grep '/srv'
/srv                      all files      system_u:object_r:var_t:s0
/srv/([^/]/)?ftp(/.)?               all files      system_u:object_r:public_content_t:s0
/srv/([^/]/)?rsync(/.)?              all files      system_u:object_r:public_content_t:s0
/srv/([^/]/)?www(/.)?             all files      system_u:object_r:httpd_sys_content_t:s0
/srv/([^/]/)?www/logs(/.)?            all files      system_u:object_r:httpd_log_t:s0
/srv/.                       all files      system_u:object_r:var_t:s0
/srv/gallery2(/.
)?                all files      system_u:object_r:httpd_sys_content_t:s0
/srv/gallery2/smarty(/.)?            all files      system_u:object_r:httpd_sys_rw_content_t:s0
/srv/lib/gitosis(/.
)?               all files      system_u:object_r:gitosis_var_lib_t:s0
/srv/loopback-device(/.)?             all files      system_u:object_r:swift_data_t:s0
/srv/node(/.
)?                   all files      system_u:object_r:swift_data_t:s0
#上面則是默認(rèn)的/srv下面的安全上下文數(shù)據(jù),不過(guò),并沒(méi)有指定到/srv/samba

[root@localhost ~]# semanage fcontext -a -t public_content_t "/srv/samba(/.)?"
[root@localhost ~]# semanage fcontext -l | grep '/srv/samba(/.
)?'
/srv/samba(/.*)?                  all files      system_u:object_r:public_content_t:s0
[root@localhost ~]# cat /etc/selinux/targeted/contexts/files/file_contexts.local

This file is auto-generated by libsemanage

Do not edit directly.

/srv/samba(/.*)?   system_u:object_r:public_content_t:s0
#其實(shí)就是寫(xiě)這個(gè)文件
[root@localhost ~]# ll -Zd /srv/samba
drwxr-xr-x. 2 root root unconfined_u:object_r:var_t:s0 6 Feb 22 22:46 /srv/samba
[root@localhost ~]# restorecon -Rv /srv/samba
[root@localhost ~]# ll -Zd /srv/samba
drwxr-xr-x. 2 root root unconfined_u:object_r:public_content_t:s0 6 Feb 22 22:46 /srv/samba
#有默認(rèn)值,以后用restorecon來(lái)修改比較簡(jiǎn)單!

看完上述內(nèi)容,你們對(duì)SELinux系統(tǒng)大概了解了嗎?希望你們學(xué)會(huì)SELinux系統(tǒng)的基本操作方法,如果想了解更多相關(guān)文章內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。

本文名稱(chēng):SELinux系統(tǒng)的基本操作方法-創(chuàng)新互聯(lián)
網(wǎng)站鏈接:http://www.chinadenli.net/article38/igipp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營(yíng)銷(xiāo)靜態(tài)網(wǎng)站App設(shè)計(jì)域名注冊(cè)ChatGPT品牌網(wǎng)站設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

營(yíng)銷(xiāo)型網(wǎng)站建設(shè)