语法高亮,滚动条美化,设置页面调整

This commit is contained in:
fofolee
2019-04-19 02:41:09 +08:00
parent 1e8f76c000
commit 359d29ee0b
1590 changed files with 12328 additions and 11441 deletions

View File

@@ -3,28 +3,28 @@
<h2 id="补充说明">补充说明</h2>
<p><strong>semanage命令</strong> 是用来查询与修改SELinux默认目录的安全上下文。SELinux的策略与规则管理相关命令seinfo命令、sesearch命令、getsebool命令、setsebool命令、semanage命令。</p>
<h3 id="语法">语法</h3>
<pre><code>semanage {login|user|port|interface|fcontext|translation} -l
<pre><code class="language-bash">semanage {login|user|port|interface|fcontext|translation} -l
semanage fcontext -{a|d|m} [-frst] file_spec</code></pre>
<h3 id="选项">选项</h3>
<pre><code>-l查询。
<pre><code class="language-bash">-l查询。
fcontext主要用在安全上下文方面。
-a增加你可以增加一些目录的默认安全上下文类型设置。
-m修改。
-d删除。</code></pre>
<h3 id="实例">实例</h3>
<p>查询一下<code>/var/www/html</code>的默认安全性本文的设置:</p>
<pre><code>semanage fcontext -l
<pre><code class="language-bash">semanage fcontext -l
SELinux fcontext type Context
....(前面省略)....
/var/www(/.*)? all files system_u:object_r:httpd_sys_content_t:s0
....(後面省略)....</code></pre>
<p>如上面例子所示,我们可以查询的到每个目录的安全性本文!而目录的设定可以使用正则表达式去指定一个范围。那么如果我们想要增加某些自定义目录的安全性本文呢?举例来说,我想要色设置<code>/srv/samba</code>成为 <code>public_content_t</code>的类型时,应该如何设置呢?</p>
<p>用semanage命令设置<code>/srv/samba</code>目录的默认安全性本文为<code>public_content_t</code></p>
<pre><code>mkdir /srv/samba
<pre><code class="language-bash">mkdir /srv/samba
ll -Zd /srv/samba
drwxr-xr-x root root root:object_r:var_t /srv/samba</code></pre>
<p>如上所示,默认的情况应该是<code>var_t</code>这个咚咚的!</p>
<pre><code>semanage fcontext -l | grep &#39;/srv&#39;
<pre><code class="language-bash">semanage fcontext -l | grep &#39;/srv&#39;
/srv/.* all files system_u:object_r:var_t:s0
/srv/([^/]*/)?ftp(/.*)? all files system_u:object_r:public_content_t:s0
/srv/([^/]*/)?www(/.*)? all files system_u:object_r:httpd_sys_content_t:s0
@@ -32,15 +32,15 @@ drwxr-xr-x root root root:object_r:var_t /srv/samba</code></pre>
/srv/gallery2(/.*)? all files system_u:object_r:httpd_sys_content_t:s0
/srv directory system_u:object_r:var_t:s0 //看这里!</code></pre>
<p>上面则是默认的<code>/srv</code>底下的安全性本文资料,不过,并没有指定到<code>/srv/samba</code></p>
<pre><code>semanage fcontext -a -t public_content_t &quot;/srv/samba(/.*)?&quot;
<pre><code class="language-bash">semanage fcontext -a -t public_content_t &quot;/srv/samba(/.*)?&quot;
semanage fcontext -l | grep &#39;/srv/samba&#39;
/srv/samba(/.*)? all files system_u:object_r:public_content_t:s0</code></pre>
<pre><code>cat /etc/selinux/targeted/contexts/files/file_contexts.local
<pre><code class="language-bash">cat /etc/selinux/targeted/contexts/files/file_contexts.local
# This file is auto-generated by libsemanage
# Please use the semanage command to make changes
/srv/samba(/.*)? system_u:object_r:public_content_t:s0 #写入这个档案
</code></pre>
<pre><code>restorecon -Rv /srv/samba* #尝试恢复默认值
<pre><code class="language-bash">restorecon -Rv /srv/samba* #尝试恢复默认值
ll -Zd /srv/samba
drwxr-xr-x root root system_u:object_r:public_content_t /srv/samba/ #有默认值以后用restorecon命令来修改比较简单</code></pre>
<p>semanage命令的功能很多这里主要用到的仅有fcontext这个选项的用法而已。如上所示你可以使用semanage来查询所有的目录默认值也能够使用它来增加默认值的设置</p>