Устранение неполадок Linux – команда semanage не найдена в CentOS 7 / RHEL 7

by itisgood

В последнее время я пытаюсь заставить сервер Apache прослушивать другой порт, отличный от порта по умолчанию, равного 80.

После того, как я сделал необходимые настройки и разрешил настраиваемый порт через брандмауэр, сервер Apache все еще отказывался слушать пользовательский порт.

После небольшого количества поисковых запросов я понял, что SELinux не разрешает порт, поэтому я выполнил следующую команду, чтобы сервер Apache прослушивал другой порт.

semanage port -a -t ftp_port_t -p tcp 8090

Здесь 8090 – это порт, который я хочу, чтобы сервер Apache слушал.

Но это породило следующую ошибку:

-bash: semanage: command not found

Я понятия не имею, какой пакет предоставит команду semanage.

Итак, давайте введем следующие команды, чтобы выяснить, какой пакет предоставит эту команду.

yum provides /usr/sbin/semanage

Пример вывода

Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirror.nbrc.ac.in
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
policycoreutils-python-2.2.5-11.el7.x86_64 : SELinux policy core python
 : utilities
Repo : base
Matched from:
Filename : /usr/sbin/semanage
policycoreutils-python-2.2.5-11.el7_0.1.x86_64 : SELinux policy core python
 : utilities
Repo : updates
Matched from:
Filename : /usr/sbin/semanage

Или

yum whatprovides /usr/sbin/semanage

Пример вывода

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nbrc.ac.in
policycoreutils-python-2.2.5-11.el7.x86_64 : SELinux policy core python
 : utilities
Repo : base
Matched from:
Filename : /usr/sbin/semanage
policycoreutils-python-2.2.5-11.el7_0.1.x86_64 : SELinux policy core python
 : utilities
Repo : updates
Matched from:
Filename : /usr/sbin/semanage

Как вы видите в приведенном выше выводе, нам нужно установить пакет policycoreutils-python-2.2.5-11.el7_0.1.x86_64, чтобы использовать команду semanage.

поэтому, давайте установим пакет policycoreutils-python-2.2.5-11.el7_0.1.x86_64 с помощью команды:

yum install policycoreutils-python

Пример вывода

================================================================================
 Package Arch Version Repository Size
================================================================================
Installing:
 policycoreutils-python x86_64 2.2.5-20.el7 base 435 k
Installing for dependencies:
 audit-libs-python x86_64 2.4.1-5.el7 base 69 k
 checkpolicy x86_64 2.1.12-6.el7 base 247 k
 libcgroup x86_64 0.41-8.el7 base 64 k
 libsemanage-python x86_64 2.1.10-18.el7 base 94 k
 python-IPy noarch 0.75-6.el7 base 32 k
 setools-libs x86_64 3.3.7-46.el7 base 485 k
Updating for dependencies:
 audit x86_64 2.4.1-5.el7 base 234 k
 audit-libs x86_64 2.4.1-5.el7 base 80 k
 libsemanage x86_64 2.1.10-18.el7 base 123 k
 policycoreutils x86_64 2.2.5-20.el7 base 803 k
Transaction Summary
================================================================================
Install 1 Package (+6 Dependent packages)
Upgrade ( 4 Dependent packages)
Total download size: 2.6 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/11): audit-libs-2.4.1-5.el7.x86_64.rpm | 80 kB 00:02 
(2/11): audit-libs-python-2.4.1-5.el7.x86_64.rpm | 69 kB 00:02 
(3/11): checkpolicy-2.1.12-6.el7.x86_64.rpm | 247 kB 00:02 
(4/11): libsemanage-2.1.10-18.el7.x86_64.rpm | 123 kB 00:01 
(5/11): audit-2.4.1-5.el7.x86_64.rpm | 234 kB 00:04 
(6/11): libsemanage-python-2.1.10-18.el7.x86_64.rpm | 94 kB 00:02 
(7/11): policycoreutils-python-2.2.5-20.el7.x86_64.rpm | 435 kB 00:03 
(8/11): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:02 
(9/11): setools-libs-3.3.7-46.el7.x86_64.rpm | 485 kB 00:08 
(10/11): policycoreutils-2.2.5-20.el7.x86_64.rpm | 803 kB 00:10 
(11/11): libcgroup-0.41-8.el7.x86_64.rpm | 64 kB 00:37 
--------------------------------------------------------------------------------
Total 71 kB/s | 2.6 MB 00:37 
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Updating : audit-libs-2.4.1-5.el7.x86_64 1/15 
 Updating : libsemanage-2.1.10-18.el7.x86_64 2/15 
 Updating : policycoreutils-2.2.5-20.el7.x86_64 3/15 
 Installing : libsemanage-python-2.1.10-18.el7.x86_64 4/15 
 Installing : audit-libs-python-2.4.1-5.el7.x86_64 5/15 
 Installing : python-IPy-0.75-6.el7.noarch 6/15 
 Installing : checkpolicy-2.1.12-6.el7.x86_64 7/15 
 Installing : libcgroup-0.41-8.el7.x86_64 8/15 
 Installing : setools-libs-3.3.7-46.el7.x86_64 9/15 
 Installing : policycoreutils-python-2.2.5-20.el7.x86_64 10/15 
 Updating : audit-2.4.1-5.el7.x86_64 11/15 
 Cleanup : policycoreutils-2.2.5-11.el7_0.1.x86_64 12/15 
 Cleanup : libsemanage-2.1.10-16.el7.x86_64 13/15 
 Cleanup : audit-2.3.3-4.el7.x86_64 14/15 
 Cleanup : audit-libs-2.3.3-4.el7.x86_64 15/15 
 Verifying : setools-libs-3.3.7-46.el7.x86_64 1/15 
 Verifying : libsemanage-2.1.10-18.el7.x86_64 2/15 
 Verifying : libcgroup-0.41-8.el7.x86_64 3/15 
 Verifying : checkpolicy-2.1.12-6.el7.x86_64 4/15 
 Verifying : policycoreutils-2.2.5-20.el7.x86_64 5/15 
 Verifying : python-IPy-0.75-6.el7.noarch 6/15 
 Verifying : audit-libs-2.4.1-5.el7.x86_64 7/15 
 Verifying : libsemanage-python-2.1.10-18.el7.x86_64 8/15 
 Verifying : audit-2.4.1-5.el7.x86_64 9/15 
 Verifying : policycoreutils-python-2.2.5-20.el7.x86_64 10/15 
 Verifying : audit-libs-python-2.4.1-5.el7.x86_64 11/15 
 Verifying : audit-libs-2.3.3-4.el7.x86_64 12/15 
 Verifying : policycoreutils-2.2.5-11.el7_0.1.x86_64 13/15 
 Verifying : libsemanage-2.1.10-16.el7.x86_64 14/15 
 Verifying : audit-2.3.3-4.el7.x86_64 15/15

Installed:
 policycoreutils-python.x86_64 0:2.2.5-20.el7
Dependency Installed:
 audit-libs-python.x86_64 0:2.4.1-5.el7 
 checkpolicy.x86_64 0:2.1.12-6.el7 
 libcgroup.x86_64 0:0.41-8.el7 
 libsemanage-python.x86_64 0:2.1.10-18.el7 
 python-IPy.noarch 0:0.75-6.el7 
 setools-libs.x86_64 0:3.3.7-46.el7
Dependency Updated:
 audit.x86_64 0:2.4.1-5.el7 audit-libs.x86_64 0:2.4.1-5.el7 
 libsemanage.x86_64 0:2.1.10-18.el7 policycoreutils.x86_64 0:2.2.5-20.el7
Complete!

Теперь вы можете использовать команду semanage.

semanage

Пример вывода

usage: semanage [-h] 
 {import,export,login,user,port,interface,module,node,fcontext,boolean,permissive,dontaudit}
 ...
semanage is used to configure certain elements of SELinux policy with-out
requiring modification to or recompilation from policy source.
positional arguments:
 {import,export,login,user,port,interface,module,node,fcontext,boolean,permissive,dontaudit}
 import Output local customizations
 export Output local customizations
 login Manage login mappings between linux users and SELinux
 confined users
 user Manage SELinux confined users (Roles and levels for an
 SELinux user)
 port Manage network port type definitions
 interface Manage network interface type definitions
 module Manage SELinux policy modules
 node Manage network node type definitions
 fcontext Manage file context mapping definitions
 boolean Manage booleans to selectively enable functionality
 permissive Manage process type enforcement mode
 dontaudit Disable/Enable dontaudit rules in policy
optional arguments:
 -h, --help show this help message and exit

Как использовать команду Semanage

You may also like

Leave a Comment