自学内容网 自学内容网

centos7 semanage 离线安装 SELinux

centos7 semanage 离线安装

还是参考一下 换成阿里云的源 之后 ,在线更新不,不要用离线安装
centos7 更新 yum源 为 阿里云 LTS
https://blog.csdn.net/wowocpp/article/details/142517908

CentOS7安装时使用"基础服务器"选项安装, 后发现没有semanage命令.

ss -tnlp

可以通过 getenforce 命令查看 SELinux服务的运行状态。# setenforce 0

getenforce

Permissive

使用yum查询选项搜索

1、使用yum查找提供此功能的的软件包:

# yum provides /usr/sbin/semanage
或者

# yum whatprovides /usr/sbin/semanage

[root@localhost ~]# yum provides semanage
按照搜索结果安装对应包即可解决

[root@localhost ~]# yum install -y policycoreutils-python

ping www.baidu.com
不用加 sudo
yum provides semanage  
/usr/sbin/semanage
yum install -y policycoreutils-python-2.5-34.el7.x86_64
semanage 
semanage fcontext -l|grep mysqld_db_t

ls /opt/datadir/mysql/
ls
semanage fcontext -a -t mysqld_db_t "/opt/datadir/mysql(/.*)?"
restorecon -Rv /opt/datadir/mysql
semanage fcontext -l|grep mysqld_db_t

3.修改SELinux

添加修改的端口号到SELinux:semanage port -a -t ssh_port_t -p tcp 22492

并检查是否添加成功:semanage port -l | grep ssh,如图出现修改端口号,即为成功。

通过semanage管理SELinux

不用加 sudo
yum provides semanage
cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
在上面的系统里面运行

[jack@localhost ~]$ yum provides semanage
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
mysql-connectors-community/x86_64/filelists_db                                                                                                                                         |  56 kB  00:00:00     
mysql-tools-community/x86_64/filelists_db                                                                                                                                              | 824 kB  00:00:00     
policycoreutils-python-2.5-34.el7.x86_64 : SELinux policy core python utilities
Repo        : base
Matched from:
Filename    : /usr/sbin/semanage



policycoreutils-python-2.5-34.el7.x86_64 : SELinux policy core python utilities
Repo        : @base
Matched from:
Filename    : /sbin/semanage



policycoreutils-python-2.5-34.el7.x86_64 : SELinux policy core python utilities
Repo        : @base
Matched from:
Filename    : /usr/sbin/semanage


把 policycoreutils-python-2.5-34.el7.x86_64 给下载下来

先强制卸载 然后再安装上去
sudo rpm -e --nodeps policycoreutils-python-2.5-34.el7.x86_64

sudo yum install --downloadonly --downloaddir=/home/jack/tmp policycoreutils-python-2.5-34.el7.x86_64
安装
sudo rpm -ivh policycoreutils-python-2.5-34.el7.x86_64.rpm

yum repolist

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
repo id                                                                                                repo name                                                                                        status
base/7/x86_64                                                                                          CentOS-7 - Base                                                                                  10,072
extras/7/x86_64                                                                                        CentOS-7 - Extras                                                                                   526
mysql-connectors-community/x86_64                                                                      MySQL Connectors Community                                                                          258
mysql-tools-community/x86_64                                                                           MySQL Tools Community                                                                               108
mysql57-community/x86_64                                                                               MySQL 5.7 Community Server                                                                          696
updates/7/x86_64                                                                                       CentOS-7 - Updates                                                                                6,173
repolist: 17,833

sudo yum search policycoreutils-python

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
==================================================================================== N/S matched: policycoreutils-python =====================================================================================
policycoreutils-python.x86_64 : SELinux policy core python utilities

  Name and summary matches only, use "search all" for everything.

sudo yum deplist policycoreutils-python

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
package: policycoreutils-python.x86_64 2.5-34.el7
  dependency: /usr/bin/python
   provider: python.x86_64 2.7.5-94.el7_9
  dependency: audit-libs-python >= 2.1.3-4
   provider: audit-libs-python.x86_64 2.8.5-4.el7
  dependency: checkpolicy
   provider: checkpolicy.x86_64 2.5-8.el7
  dependency: libapol.so.4()(64bit)
   provider: setools-libs.x86_64 3.3.8-4.el7
  dependency: libapol.so.4(VERS_4.0)(64bit)
   provider: setools-libs.x86_64 3.3.8-4.el7
  dependency: libc.so.6(GLIBC_2.4)(64bit)
   provider: glibc.x86_64 2.17-326.el7_9.3
  dependency: libcgroup
   provider: libcgroup.x86_64 0.41-21.el7
   provider: libcgroup.i686 0.41-21.el7
  dependency: libpthread.so.0()(64bit)
   provider: glibc.x86_64 2.17-326.el7_9.3
  dependency: libpthread.so.0(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-326.el7_9.3
  dependency: libpython2.7.so.1.0()(64bit)
   provider: python-libs.x86_64 2.7.5-94.el7_9
  dependency: libqpol.so.1()(64bit)
   provider: setools-libs.x86_64 3.3.8-4.el7
  dependency: libqpol.so.1(VERS_1.2)(64bit)
   provider: setools-libs.x86_64 3.3.8-4.el7
  dependency: libqpol.so.1(VERS_1.4)(64bit)
   provider: setools-libs.x86_64 3.3.8-4.el7
  dependency: libselinux-python
   provider: libselinux-python.x86_64 2.5-15.el7
  dependency: libselinux.so.1()(64bit)
   provider: libselinux.x86_64 2.5-15.el7
  dependency: libsemanage-python >= 2.5-14
   provider: libsemanage-python.x86_64 2.5-14.el7
  dependency: libsepol.so.1()(64bit)
   provider: libsepol.x86_64 2.5-10.el7
  dependency: libsepol.so.1(LIBSEPOL_1.0)(64bit)
   provider: libsepol.x86_64 2.5-10.el7
  dependency: policycoreutils = 2.5-34.el7
   provider: policycoreutils.x86_64 2.5-34.el7
  dependency: python(abi) = 2.7
   provider: python.x86_64 2.7.5-94.el7_9
  dependency: python-IPy
   provider: python-IPy.noarch 0.75-6.el7
  dependency: rtld(GNU_HASH)
   provider: glibc.x86_64 2.17-326.el7_9.3
   provider: glibc.i686 2.17-326.el7_9.3
  dependency: setools-libs >= 3.3.8-4
   provider: setools-libs.x86_64 3.3.8-4.el7
   provider: setools-libs.i686 3.3.8-4.el7

111


原文地址:https://blog.csdn.net/wowocpp/article/details/142515687

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!