AppArmor零知识学习十、源码构建(7)

本文内容参考:

AppArmor / apparmor · GitLab

接前一篇文章:AppArmor零知识学习九、源码构建(6)

上一篇文章在进行apparmor源码构建的第五步——Utilties的构建和安装时,在make check这一步出现了问题。解决了dbus-python包的相关问题,但又出现了一个新的问题:ModuleNotFoundError: No module named 'psutil'。本文探索如何解决这个问题并继续往下推进。

还是先使用最常规方法,使用pip install命令尝试进行下载安装,实际命令及结果如下所示:

$ sudo pip install psutil
[sudo] penghao 的密码:Collecting psutil
  Downloading psutil-5.9.4-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (280 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 280.2/280.2 kB 1.3 MB/s eta 0:00:00
Installing collected packages: psutil
Successfully installed psutil-5.9.4
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip is available: 23.0 -> 23.1
[notice] To update, run: pip install --upgrade pip

下载安装了psutil包之后,再次执行之前的完整make check命令。实际命令及结果如下所示:

$ make check PYFLAKES=/usr/bin/pyflakes3
LANG=C podchecker -warning -warning *.pod
aa-audit.pod pod syntax OK.
aa-autodep.pod pod syntax OK.
aa-cleanprof.pod pod syntax OK.
aa-complain.pod pod syntax OK.
aa-decode.pod pod syntax OK.
aa-disable.pod pod syntax OK.
aa-easyprof.pod pod syntax OK.
aa-enforce.pod pod syntax OK.
aa-genprof.pod pod syntax OK.
aa-logprof.pod pod syntax OK.
aa-mergeprof.pod pod syntax OK.
aa-notify.pod pod syntax OK.
aa-remove-unknown.pod pod syntax OK.
aa-sandbox.pod pod syntax OK.
aa-unconfined.pod pod syntax OK.
logprof.conf.pod pod syntax OK.
Checking aa-easyprof
Checking aa-genprof
Checking aa-logprof
Checking aa-cleanprof
Checking aa-mergeprof
Checking aa-autodep
Checking aa-audit
Checking aa-complain
Checking aa-enforce
Checking aa-disable
Checking aa-notify
Checking aa-unconfined
Checking apparmor
Checking test/common_test.py
Checking test/test-aa-cli-bootstrap.py
Checking test/test-aa-decode.py
Checking test/test-aa-easyprof.py
Checking test/test-aa-notify.py
Checking test/test-aa.py
Checking test/test-aare.py
Checking test/test-abi.py
Checking test/test-alias.py
Checking test/test-baserule.py
Checking test/test-boolean.py
Checking test/test-capability.py
Checking test/test-change_profile.py
Checking test/test-common.py
Checking test/test-config.py
Checking test/test-dbus.py
Checking test/test-example.py
Checking test/test-file.py
Checking test/test-include.py
Checking test/test-libapparmor-test_multi.py
Checking test/test-logparser.py
Checking test/test-minitools.py
Checking test/test-mount_parse.py
Checking test/test-mqueue.py
Checking test/test-network.py
Checking test/test-notify.py
Checking test/test-parser-simple-tests.py
Checking test/test-pivot_root_parse.py
Checking test/test-profile-list.py
Checking test/test-profiles.py
Checking test/test-profile-storage.py
Checking test/test-ptrace.py
Checking test/test-regex_matches.py
Checking test/test-rlimit.py
Checking test/test-severity.py
Checking test/test-signal.py
Checking test/test-translations.py
Checking test/test-unix_parse.py
Checking test/test-userns.py
Checking test/test-variable.py
make[1]: 进入目录“/home/penghao/AppArmor/apparmor/utils/test”

=== test-aa-cli-bootstrap.py ===
.....
----------------------------------------------------------------------
Ran 5 tests in 0.108s

OK

=== test-aa-decode.py ===
..........
----------------------------------------------------------------------
Ran 10 tests in 0.312s

OK

=== test-aa-easyprof.py ===
.........................................
# vim:syntax=apparmor
# test-template
# AppArmor policy for foo
# ###AUTHOR###
# ###COPYRIGHT###
# ###COMMENT###

#include <tunables/global>

# No template variables specified

"/opt/bin/foo" {
  #include <abstractions/base>

  # No abstractions specified

  # No policy groups specified

  # No read paths specified

  # No write paths specified
bzzzt


..........................................................................................WARN: Manifest definition is potentially unsafe
found 'user-tmp' abstraction
..WARN: Manifest definition is potentially unsafe
profile_name 'bin/*'
..WARN: Manifest definition is potentially unsafe
@{VAR1}=f*o
WARN: Manifest definition is potentially unsafe
@{VAR2}=*foo
WARN: Manifest definition is potentially unsafe
@{VAR3}=fo*
WARN: Manifest definition is potentially unsafe
@{VAR4}=b{ar
WARN: Manifest definition is potentially unsafe
@{VAR5}=b{a,r}
WARN: Manifest definition is potentially unsafe
@{VAR6}=b}ar
WARN: Manifest definition is potentially unsafe
@{VAR7}=bar[0-9]
WARN: Manifest definition is potentially unsafe
@{VAR8}=b{ar
WARN: Manifest definition is potentially unsafe
@{VAR9}=foo/bar
..
----------------------------------------------------------------------
Ran 137 tests in 1.176s

OK

=== test-aa-notify.py ===
.....
----------------------------------------------------------------------
Ran 5 tests in 0.539s

OK

=== test-aa.py ===
..Traceback (most recent call last):
  File "/home/penghao/AppArmor/apparmor/utils/test/./fake_ldd", line 60, in <module>
    raise Exception('unknown parameter in fake_ldd: ' + sys.argv[1])
Exception: unknown parameter in fake_ldd: invalid
..................................................................................
Execute target /tmp/aa-test-l6k33qd1/file-not-found does not exist!
.
Execute target /dev/null is not a file!
...................................................................
----------------------------------------------------------------------
Ran 152 tests in 0.886s

OK

=== test-aare.py ===
............................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 220 tests in 0.011s

OK

=== test-abi.py ===
....................................................
----------------------------------------------------------------------
Ran 52 tests in 0.002s

OK

=== test-alias.py ===
..........................................
----------------------------------------------------------------------
Ran 42 tests in 0.001s

OK

=== test-baserule.py ===
............
----------------------------------------------------------------------
Ran 12 tests in 0.002s

OK

=== test-boolean.py ===
...............................................
----------------------------------------------------------------------
Ran 47 tests in 0.002s

OK

=== test-capability.py ===
.............................................................................WARN: unknown capability: foo
..............
----------------------------------------------------------------------
Ran 91 tests in 0.011s

OK

=== test-change_profile.py ===
...............................................................................................................................
----------------------------------------------------------------------
Ran 127 tests in 0.005s

OK

=== test-common.py ===
.........
----------------------------------------------------------------------
Ran 9 tests in 0.000s

OK

=== test-config.py ===
..
----------------------------------------------------------------------
Ran 2 tests in 0.008s

OK

=== test-dbus.py ===
..............................................................................................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 334 tests in 0.015s

OK

=== test-example.py ===
.......
----------------------------------------------------------------------
Ran 7 tests in 0.000s

OK

=== test-file.py ===
..............................................................................................................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 350 tests in 0.039s

OK

=== test-include.py ===
.......................................................................................
----------------------------------------------------------------------
Ran 87 tests in 0.136s

OK

=== test-libapparmor-test_multi.py ===
Testing libapparmor test_multi tests...
......................................................................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 310 tests in 0.063s

OK

=== test-logparser.py ===
.......
----------------------------------------------------------------------
Ran 7 tests in 0.000s

OK

=== test-minitools.py ===
......Traceback (most recent call last):
  File "/home/penghao/AppArmor/apparmor/utils/test/./../aa-unconfined", line 130, in <module>
    attr = read_proc_current("/proc/%s/attr/apparmor/current" % pid)
  File "/home/penghao/AppArmor/apparmor/utils/test/./../aa-unconfined", line 106, in read_proc_current
    for line in current:
OSError: [Errno 22] Invalid argument


An unexpected error occurred!

For details, see /tmp/apparmor-bugreport-7ljjs2lf.txt
Please consider reporting a bug at https://gitlab.com/apparmor/apparmor/-/issues
and attach this file.
E
======================================================================
ERROR: test_unconfined (__main__.MinitoolsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/penghao/AppArmor/apparmor/utils/test/test-minitools.py", line 192, in test_unconfined
    output = subprocess.check_output(
  File "/usr/lib/python3.10/subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'python3 ./../aa-unconfined --configdir ./' returned non-zero exit status 1.

----------------------------------------------------------------------
Ran 7 tests in 2.551s

FAILED (errors=1)
make[1]: *** [Makefile:85:check] 错误 1
make[1]: 离开目录“/home/penghao/AppArmor/apparmor/utils/test”
make: *** [Makefile:103:check] 错误 2

到这一步,我们暂时不再纠缠于这个问题,直接执行安装的步骤,看看是否能够成功。

(4)安装

运行make install命令进行安装。实际命令及结果如下所示:

$ sudo make install
install -d //etc/apparmor
install -m 644 logprof.conf severity.db notify.conf //etc/apparmor
install -d //usr/sbin
# aa-easyprof is installed by python-tools-setup.py
install -m 755 aa-genprof aa-logprof aa-cleanprof aa-mergeprof aa-autodep aa-audit aa-complain aa-enforce aa-disable aa-notify aa-unconfined aa-decode aa-remove-unknown //usr/sbin
make -C po install DESTDIR=/ NAME=apparmor-utils
make[1]: 进入目录“/home/penghao/AppArmor/apparmor/utils/po”
mkdir -p ///usr/share/locale
for lang in  af  be  bo  bs  cs  de  en_GB  es  fa  fr  gl  hi  id  it  ko  oc  pl  pt_BR  pt  ro  ru  sv  tr  ug  uk  zh_CN ; do \
        mkdir -p ///usr/share/locale/${lang}/LC_MESSAGES ; \
        install -m 644 ${lang}.mo ///usr/share/locale/${lang}/LC_MESSAGES/apparmor-utils.mo ; \
done
make[1]: 离开目录“/home/penghao/AppArmor/apparmor/utils/po”
make install_manpages DESTDIR=/
make[1]: 进入目录“/home/penghao/AppArmor/apparmor/utils”
install -d ///usr/share/man/man5 ; install -m 644 logprof.conf.5 ///usr/share/man/man5;   install -d ///usr/share/man/man8 ; install -m 644 aa-easyprof.8 aa-genprof.8 aa-logprof.8 aa-cleanprof.8 aa-mergeprof.8 aa-autodep.8 aa-audit.8 aa-complain.8 aa-enforce.8 aa-disable.8 aa-notify.8 aa-unconfined.8 aa-decode.8 aa-remove-unknown.8 ///usr/share/man/man8; 
make[1]: 离开目录“/home/penghao/AppArmor/apparmor/utils”
make -C vim install DESTDIR=/
make[1]: 进入目录“/home/penghao/AppArmor/apparmor/utils/vim”
install -d //usr/share/apparmor
install -m 644 apparmor.vim //usr/share/apparmor
make install_manpages DESTDIR=/
make[2]: 进入目录“/home/penghao/AppArmor/apparmor/utils/vim”
install -d ///usr/share/man/man5 ; install -m 644 apparmor.vim.5 ///usr/share/man/man5; 
make[2]: 离开目录“/home/penghao/AppArmor/apparmor/utils/vim”
make[1]: 离开目录“/home/penghao/AppArmor/apparmor/utils/vim”
/bin/python3 python-tools-setup.py install --prefix=/usr --root=/ --version=3.1.0
running install
/usr/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running build
running build_py
running install_lib
running install_egg_info
running egg_info
writing apparmor.egg-info/PKG-INFO
writing dependency_links to apparmor.egg-info/dependency_links.txt
writing top-level names to apparmor.egg-info/top_level.txt
reading manifest file 'apparmor.egg-info/SOURCES.txt'
writing manifest file 'apparmor.egg-info/SOURCES.txt'
removing '/usr/lib/python3.10/site-packages/apparmor-3.1.0-py3.10.egg-info' (and everything under it)
Copying apparmor.egg-info to /usr/lib/python3.10/site-packages/apparmor-3.1.0-py3.10.egg-info
running install_scripts

似乎make check不通过对于Utilties编译和安装没有影响。

至此,Utilties就构建并安装完成了。

猜你喜欢

转载自blog.csdn.net/phmatthaus/article/details/130205233