In AppArmor zero-knowledge learning six, source code construction (3) , the construction steps of libapparmor are introduced in detail, but the default parameters given by the official website are completely used. If you need to generate the target file to the specified directory instead of the default /usr, you need to make some modifications. This article will detail how to make the modifications.
The following two points must be stated:
(1) The construction of Binary Utilities must be carried out on the basis of the previous steps (configuration of environment variables and libapparmor construction). For these two steps, please refer to: AppArmor zero-knowledge learning 4. Source code construction (1) and AppArmor zero-knowledge learning 5. Source code construction (2) ;
(2) The above steps in the construction and installation of the non-default directory of libapparmor are used for making packages. Since it does not put the target file under /usr/local, it does not actually work. What really works is the libapparmor related components that were previously built according to the default parameters.
Next, start the build and install of the Binary Utilities custom install directory.
(1) enterbinutils目录
Use the cd command to enter the directory under the root directory of the apparmor source code binutils
. The actual commands and results are as follows:
penghao@Ding-Perlis-MP260S48:~/AppArmor/apparmor_2/apparmor$ cd binutils/
penghao@Ding-Perlis-MP260S48:~/AppArmor/apparmor_2/apparmor/binutils$ pwd
/home/penghao/AppArmor/apparmor_2/apparmor/binutils
penghao@Ding-Perlis-MP260S48:~/AppArmor/apparmor_2/apparmor/binutils$ ls
aa-enabled aa_enabled.c aa-exec aa_exec.c aa-features-abi aa_features_abi.c aa-status aa_status.c cJSON.c cJSON.o po
aa-enabled.1 aa-enabled.pod aa-exec.1 aa-exec.pod aa-features-abi.1 aa-features-abi.pod aa-status.8 aa-status.pod cJSON.h Makefile
(2) compile
Run the make command to compile, the actual command and results are as follows:
$ make
cc -L../libraries/libapparmor//src/.libs -g -O2 -pipe -Wall -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter -Wimplicit-fallthrough -DPACKAGE=\"aa-binutils\" -DLOCALEDIR=\"/usr/share/locale\" -I../libraries/libapparmor//include -o aa-enabled aa_enabled.c -Wl,-Bstatic -lapparmor -Wl,-Bdynamic -lpthread
cc -L../libraries/libapparmor//src/.libs -g -O2 -pipe -Wall -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter -Wimplicit-fallthrough -DPACKAGE=\"aa-binutils\" -DLOCALEDIR=\"/usr/share/locale\" -I../libraries/libapparmor//include -o aa-exec aa_exec.c -Wl,-Bstatic -lapparmor -Wl,-Bdynamic -lpthread
cc -L../libraries/libapparmor//src/.libs -g -O2 -pipe -Wall -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter -Wimplicit-fallthrough -DPACKAGE=\"aa-binutils\" -DLOCALEDIR=\"/usr/share/locale\" -I../libraries/libapparmor//include -o aa-features-abi aa_features_abi.c -Wl,-Bstatic -lapparmor -Wl,-Bdynamic -lpthread
cc -g -O2 -pipe -Wall -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter -Wimplicit-fallthrough -DPACKAGE=\"aa-binutils\" -DLOCALEDIR=\"/usr/share/locale\" -I../libraries/libapparmor//include -c -o cJSON.o cJSON.c
cc -L../libraries/libapparmor//src/.libs -g -O2 -pipe -Wall -Wsign-compare -Wmissing-field-initializers -Wformat -Wformat-security -Wunused-parameter -Wimplicit-fallthrough -DPACKAGE=\"aa-binutils\" -DLOCALEDIR=\"/usr/share/locale\" -I../libraries/libapparmor//include -o aa-status aa_status.c -Wl,-Bstatic -lapparmor -Wl,-Bdynamic -lpthread cJSON.o
/usr/bin/pod2man aa-enabled.pod --release="AppArmor 3.1.0" --center=AppArmor --stderr --section=1 > aa-enabled.1
/usr/bin/pod2man aa-exec.pod --release="AppArmor 3.1.0" --center=AppArmor --stderr --section=1 > aa-exec.1
/usr/bin/pod2man aa-features-abi.pod --release="AppArmor 3.1.0" --center=AppArmor --stderr --section=1 > aa-features-abi.1
/usr/bin/pod2man aa-status.pod --release="AppArmor 3.1.0" --center=AppArmor --stderr --section=8 > aa-status.8
make[1]: 进入目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils/po”
msgfmt -c -o af.mo af.po
af.po:7: 警告:头部缺少文件头“Language”
msgfmt -c -o de.mo de.po
msgfmt -c -o en_GB.mo en_GB.po
msgfmt -c -o es.mo es.po
es.po:7: 警告:头部缺少文件头“Language”
msgfmt -c -o fa.mo fa.po
fa.po:7: 警告:头部缺少文件头“Language”
msgfmt -c -o fi.mo fi.po
fi.po:7: 警告:头部缺少文件头“Language”
msgfmt -c -o id.mo id.po
msgfmt -c -o pt.mo pt.po
msgfmt -c -o ro.mo ro.po
ro.po:7: 警告:头部缺少文件头“Language”
msgfmt -c -o ru.mo ru.po
msgfmt -c -o sv.mo sv.po
sv.po:7: 警告:头部缺少文件头“Language”
msgfmt -c -o sw.mo sw.po
sw.po:7: 警告:头部缺少文件头“Language”
msgfmt -c -o tr.mo tr.po
tr.po:7: 警告:头部缺少文件头“Language”
make[1]: 离开目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils/po”
(3) check
Run the make check command to check. The actual commands and results are as follows:
$ make check
LANG=C podchecker -warning -warning *.pod
aa-enabled.pod pod syntax OK.
aa-exec.pod pod syntax OK.
aa-features-abi.pod pod syntax OK.
aa-status.pod pod syntax OK.
no tests atm
(4) Installation
Run the make install command to install, the actual command and results are as follows (note the parameter of DESTDIR=):
$ make install DESTDIR=/home/penghao/AppArmor/apparmor_2/output2
make[1]: 进入目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils/po”
make[1]: 对“all”无需做任何事。make[1]: 离开目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils/po”
make -C po install NAME=aa-binutils DESTDIR=/home/penghao/AppArmor/apparmor_2/output2
make[1]: 进入目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils/po”
mkdir -p /home/penghao/AppArmor/apparmor_2/output2//usr/share/locale
for lang in af de en_GB es fa fi id pt ro ru sv sw tr ; do \
mkdir -p /home/penghao/AppArmor/apparmor_2/output2//usr/share/locale/${lang}/LC_MESSAGES ; \
install -m 644 ${lang}.mo /home/penghao/AppArmor/apparmor_2/output2//usr/share/locale/${lang}/LC_MESSAGES/aa-binutils.mo ; \
done
make[1]: 离开目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils/po”
make install_manpages DESTDIR=/home/penghao/AppArmor/apparmor_2/output2
make[1]: 进入目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils”
install -d /home/penghao/AppArmor/apparmor_2/output2//usr/share/man/man1 ; install -m 644 aa-enabled.1 aa-exec.1 aa-features-abi.1 /home/penghao/AppArmor/apparmor_2/output2//usr/share/man/man1; install -d /home/penghao/AppArmor/apparmor_2/output2//usr/share/man/man8 ; install -m 644 aa-status.8 /home/penghao/AppArmor/apparmor_2/output2//usr/share/man/man8;
make[1]: 离开目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils”
ln -sf aa-status.8 /home/penghao/AppArmor/apparmor_2/output2//usr/share/man/man8/apparmor_status.8
install -m 755 -d /home/penghao/AppArmor/apparmor_2/output2/usr/bin
install -m 755 aa-enabled aa-exec aa-features-abi /home/penghao/AppArmor/apparmor_2/output2/usr/bin
install -m 755 -d /home/penghao/AppArmor/apparmor_2/output2/usr/sbin
ln -sf aa-status /home/penghao/AppArmor/apparmor_2/output2/usr/sbin/apparmor_status
install -m 755 aa-status /home/penghao/AppArmor/apparmor_2/output2/usr/sbin
(5) View generated content
Check the actual generated file and path after configuring make DESTDIR=/home/penghao/AppArmor/apparmor_2/output2:
usr
penghao@Ding-Perlis-MP260S48:~/AppArmor/apparmor_2/apparmor/binutils$ ls ../../output2/usr/
bin sbin share
penghao@Ding-Perlis-MP260S48:~/AppArmor/apparmor_2/apparmor/binutils$ tree ../../output2/
../../output2/
└── usr
├── bin
│ ├── aa-enabled
│ ├── aa-exec
│ └── aa-features-abi
├── sbin
│ ├── aa-status
│ └── apparmor_status -> aa-status
└── share
├── locale
│ ├── af
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── de
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── en_GB
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── es
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── fa
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── fi
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── id
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── pt
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── ro
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── ru
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── sv
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── sw
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ └── tr
│ └── LC_MESSAGES
│ └── aa-binutils.mo
└── man
├── man1
│ ├── aa-enabled.1
│ ├── aa-exec.1
│ └── aa-features-abi.1
└── man8
├── aa-status.8
└── apparmor_status.8 -> aa-status.8
34 directories, 23 files
Here, the generation target is placed under the output2 folder, in order to see clearly what content is generated by Binary Utilities. In the end, it still needs to be installed in the previous output directory.
Install again after changing the DESTDIR= parameter, the actual command and results are as follows:
$ make install DESTDIR=/home/penghao/AppArmor/apparmor_2/output
make[1]: 进入目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils/po”
make[1]: 对“all”无需做任何事。make[1]: 离开目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils/po”
make -C po install NAME=aa-binutils DESTDIR=/home/penghao/AppArmor/apparmor_2/output
make[1]: 进入目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils/po”
mkdir -p /home/penghao/AppArmor/apparmor_2/output//usr/share/locale
for lang in af de en_GB es fa fi id pt ro ru sv sw tr ; do \
mkdir -p /home/penghao/AppArmor/apparmor_2/output//usr/share/locale/${lang}/LC_MESSAGES ; \
install -m 644 ${lang}.mo /home/penghao/AppArmor/apparmor_2/output//usr/share/locale/${lang}/LC_MESSAGES/aa-binutils.mo ; \
done
make[1]: 离开目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils/po”
make install_manpages DESTDIR=/home/penghao/AppArmor/apparmor_2/output
make[1]: 进入目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils”
install -d /home/penghao/AppArmor/apparmor_2/output//usr/share/man/man1 ; install -m 644 aa-enabled.1 aa-exec.1 aa-features-abi.1 /home/penghao/AppArmor/apparmor_2/output//usr/share/man/man1; install -d /home/penghao/AppArmor/apparmor_2/output//usr/share/man/man8 ; install -m 644 aa-status.8 /home/penghao/AppArmor/apparmor_2/output//usr/share/man/man8;
make[1]: 离开目录“/home/penghao/AppArmor/apparmor_2/apparmor/binutils”
ln -sf aa-status.8 /home/penghao/AppArmor/apparmor_2/output//usr/share/man/man8/apparmor_status.8
install -m 755 -d /home/penghao/AppArmor/apparmor_2/output/usr/bin
install -m 755 aa-enabled aa-exec aa-features-abi /home/penghao/AppArmor/apparmor_2/output/usr/bin
install -m 755 -d /home/penghao/AppArmor/apparmor_2/output/usr/sbin
ln -sf aa-status /home/penghao/AppArmor/apparmor_2/output/usr/sbin/apparmor_status
install -m 755 aa-status /home/penghao/AppArmor/apparmor_2/output/usr/sbin
Compare the changes in output before and after installing Binary Utilities:
before installation
$ tree ../../output
../../output
└── usr
└── local
├── include
│ ├── aalogparse
│ │ └── aalogparse.h
│ └── sys
│ ├── apparmor.h
│ └── apparmor_private.h
├── lib
│ ├── libapparmor.a
│ ├── libapparmor.la
│ ├── libapparmor.so -> libapparmor.so.1.12.2
│ ├── libapparmor.so.1 -> libapparmor.so.1.12.2
│ ├── libapparmor.so.1.12.2
│ ├── perl5
│ │ └── 5.36
│ │ ├── core_perl
│ │ │ └── perllocal.pod
│ │ └── vendor_perl
│ │ ├── auto
│ │ │ └── LibAppArmor
│ │ │ └── LibAppArmor.so
│ │ └── LibAppArmor.pm
│ ├── pkgconfig
│ │ └── libapparmor.pc
│ └── python3.10
│ └── site-packages
│ ├── LibAppArmor
│ │ ├── __init__.py
│ │ ├── _LibAppArmor.cpython-310-x86_64-linux-gnu.so
│ │ ├── LibAppArmor.py
│ │ └── __pycache__
│ │ ├── __init__.cpython-310.pyc
│ │ └── LibAppArmor.cpython-310.pyc
│ └── LibAppArmor-3.1.0-py3.10.egg-info
│ ├── dependency_links.txt
│ ├── PKG-INFO
│ ├── SOURCES.txt
│ └── top_level.txt
└── share
└── man
├── man2
│ ├── aa_change_hat.2
│ ├── aa_change_profile.2
│ ├── aa_find_mountpoint.2
│ ├── aa_getcon.2
│ ├── aa_query_label.2
│ └── aa_stack_profile.2
└── man3
├── aa_features.3
├── aa_kernel_interface.3
├── aa_policy_cache.3
└── aa_splitcon.3
22 directories, 31 files
After installation
$ tree ../../output
../../output
└── usr
├── bin
│ ├── aa-enabled
│ ├── aa-exec
│ └── aa-features-abi
├── local
│ ├── include
│ │ ├── aalogparse
│ │ │ └── aalogparse.h
│ │ └── sys
│ │ ├── apparmor.h
│ │ └── apparmor_private.h
│ ├── lib
│ │ ├── libapparmor.a
│ │ ├── libapparmor.la
│ │ ├── libapparmor.so -> libapparmor.so.1.12.2
│ │ ├── libapparmor.so.1 -> libapparmor.so.1.12.2
│ │ ├── libapparmor.so.1.12.2
│ │ ├── perl5
│ │ │ └── 5.36
│ │ │ ├── core_perl
│ │ │ │ └── perllocal.pod
│ │ │ └── vendor_perl
│ │ │ ├── auto
│ │ │ │ └── LibAppArmor
│ │ │ │ └── LibAppArmor.so
│ │ │ └── LibAppArmor.pm
│ │ ├── pkgconfig
│ │ │ └── libapparmor.pc
│ │ └── python3.10
│ │ └── site-packages
│ │ ├── LibAppArmor
│ │ │ ├── __init__.py
│ │ │ ├── _LibAppArmor.cpython-310-x86_64-linux-gnu.so
│ │ │ ├── LibAppArmor.py
│ │ │ └── __pycache__
│ │ │ ├── __init__.cpython-310.pyc
│ │ │ └── LibAppArmor.cpython-310.pyc
│ │ └── LibAppArmor-3.1.0-py3.10.egg-info
│ │ ├── dependency_links.txt
│ │ ├── PKG-INFO
│ │ ├── SOURCES.txt
│ │ └── top_level.txt
│ └── share
│ └── man
│ ├── man2
│ │ ├── aa_change_hat.2
│ │ ├── aa_change_profile.2
│ │ ├── aa_find_mountpoint.2
│ │ ├── aa_getcon.2
│ │ ├── aa_query_label.2
│ │ └── aa_stack_profile.2
│ └── man3
│ ├── aa_features.3
│ ├── aa_kernel_interface.3
│ ├── aa_policy_cache.3
│ └── aa_splitcon.3
├── sbin
│ ├── aa-status
│ └── apparmor_status -> aa-status
└── share
├── locale
│ ├── af
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── de
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── en_GB
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── es
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── fa
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── fi
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── id
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── pt
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── ro
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── ru
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── sv
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ ├── sw
│ │ └── LC_MESSAGES
│ │ └── aa-binutils.mo
│ └── tr
│ └── LC_MESSAGES
│ └── aa-binutils.mo
└── man
├── man1
│ ├── aa-enabled.1
│ ├── aa-exec.1
│ └── aa-features-abi.1
└── man8
├── aa-status.8
└── apparmor_status.8 -> aa-status.8
55 directories, 54 files