Skip to contentSkip to conversation

ima-evm-utils: Add as new package, version 1.2.1

PATCH New Petr Vorel 3 participants 3 messages Oct 29, 2019

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH v3 1/1 ima-evm-utils: Add as new package, version 1.2.1

+ add myself as a maintainer.

Adding build and install hooks to run make in src subdirectory (root directory asciidoc and xsltproc for manpage).

---
Changes v2->v3 (Yann):
* Use autoreconf (IMA_EVM_UTILS_AUTORECONF) instead calling ./autogen.sh

BTW I wonder if this upstream shell script build-static.sh is working:

gcc -static -o evmctl.static -include config.h src/evmctl.c src/libimaevm.c -lcrypto -lkeyutils -ldl

Because keyutils requires dynamic linking:
/home/br-test-pkg/br-arm-full-static/host/bin/arm-linux-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I. -DPKGBUILD="\"2019-10-29\"" -DPKGVERSION="\"keyutils-1.6\"" -DAPIVERSION="\"libkeyutils-1.8\"" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -UNO_GLIBC_KEYERR -o keyutils.o -c keyutils.c
keyutils.c:18:10: fatal error: dlfcn.h: No such file or directory
#include <dlfcn.h>

Kind regards,
Petr

 DEVELOPERS                               |  1 +
 package/Config.in                        |  1 +
 package/ima-evm-utils/Config.in          | 15 ++++++++++++
 package/ima-evm-utils/ima-evm-utils.hash |  3 +++
 package/ima-evm-utils/ima-evm-utils.mk   | 29 ++++++++++++++++++++++++
 5 files changed, 49 insertions(+)
 create mode 100644 package/ima-evm-utils/Config.in
 create mode 100644 package/ima-evm-utils/ima-evm-utils.hash
 create mode 100644 package/ima-evm-utils/ima-evm-utils.mk
DEVELOPERS +1 -0
index f41ac5f096..caf3ea26d4 100644
@@ -1891,6 +1891,7 @@ N:	Petr Kulhavy <[email protected]>
 F:	package/linuxptp/
 
 N:	Petr Vorel <[email protected]>
+F:	package/ima-evm-utils/
 F:	package/iproute2/
 F:	package/iputils/
 F:	package/linux-backports/
package/Config.in +1 -0
index a1ac5069aa..a5147ee7fa 100644
@@ -2169,6 +2169,7 @@ endmenu
 
 menu "Security"
 	source "package/checkpolicy/Config.in"
+	source "package/ima-evm-utils/Config.in"
 	source "package/optee-benchmark/Config.in"
 	source "package/optee-client/Config.in"
 	source "package/optee-examples/Config.in"
package/ima-evm-utils/Config.in new file +15 -0
new file mode 100644
index 0000000000..10dea5243b
@@ -0,0 +1,15 @@
+config BR2_PACKAGE_IMA_EVM_UTILS
+	bool "ima-evm-utils"
+	depends on BR2_USE_MMU # keyutils dependency: fork()
+	depends on !BR2_STATIC_LIBS # keyutils dependency: dlopen
+	select BR2_PACKAGE_OPENSSL
+	select BR2_PACKAGE_KEYUTILS
+	help
+	  Linux Integrity Measurement Architecture (IMA)
+	  Extended Verification Module (EVM) tools.
+
+	  https://sourceforge.net/p/linux-ima/wiki/Home/
+
+comment "ima-evm-utils needs dynamic library support"
+	depends on BR2_USE_MMU
+	depends on BR2_STATIC_LIBS
package/ima-evm-utils/ima-evm-utils.hash new file +3 -0
new file mode 100644
index 0000000000..24be627d20
@@ -0,0 +1,3 @@
+# Locally computed
+sha256 ad8471b58c4df29abd51c80d74b1501cfe3289b60d32d1b318618a8fd26c0c0a  ima-evm-utils-1.2.1.tar.gz
+sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643  COPYING
package/ima-evm-utils/ima-evm-utils.mk new file +29 -0
new file mode 100644
index 0000000000..a0d3703929
@@ -0,0 +1,29 @@
+################################################################################
+#
+# ima-evm-utils
+#
+################################################################################
+
+IMA_EVM_UTILS_VERSION = 1.2.1
+IMA_EVM_UTILS_SITE = http://downloads.sourceforge.net/project/linux-ima/ima-evm-utils
+IMA_EVM_UTILS_LICENSE = GPL-2.0
+IMA_EVM_UTILS_LICENSE_FILES = COPYING
+IMA_EVM_UTILS_DEPENDENCIES = host-pkgconf keyutils openssl
+
+IMA_EVM_UTILS_AUTORECONF = YES
+
+# build just sources in src subdirectory as root directory requires asciidoc
+# and xsltproc for manpage
+define IMA_EVM_UTILS_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(IMA_EVM_UTILS_MAKE_ENV) $(MAKE) -C $(@D)/src all
+endef
+define IMA_EVM_UTILS_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(IMA_EVM_UTILS_MAKE_ENV) $(MAKE) \
+		DESTDIR="$(STAGING_DIR)" -C $(@D)/src install
+endef
+define IMA_EVM_UTILS_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(IMA_EVM_UTILS_MAKE_ENV) $(MAKE) \
+		DESTDIR="$(TARGET_DIR)" -C $(@D)/src install
+endef
+
+$(eval $(autotools-package))
Signature · 1 line
2.23.0
#1 lore raw

PATCH v3 1/1 ima-evm-utils: Add as new package, version 1.2.1

Petr,

Quoted 7 lines · Petr Vorel

+ add myself as a maintainer.

Adding build and install hooks to run make in src subdirectory (root directory asciidoc and xsltproc for manpage).

$ ./utils/test-pkg -p ima-evm-utils -k -d dl -d ima_testbuild
                             br-arm-full [1/6]: OK
                  br-arm-cortex-a9-glibc [2/6]: OK
                   br-arm-cortex-m4-full [3/6]: SKIPPED
                          br-x86-64-musl [4/6]: OK
                      br-arm-full-static [5/6]: SKIPPED
                            sourcery-arm [6/6]: OK
6 builds, 2 skipped, 0 build failed, 0 legal-info failed
#2 lore raw

PATCH v3 1/1 ima-evm-utils: Add as new package, version 1.2.1

In reply to Petr Vorel
Quoted 6 lines · Petr Vorel

+ add myself as a maintainer.

Adding build and install hooks to run make in src subdirectory (root directory asciidoc and xsltproc for manpage).

Applied to master with slight changes (see below), thanks.

Regards,
Arnout

Quoted 9 lines

---
Changes v2->v3 (Yann):
* Use autoreconf (IMA_EVM_UTILS_AUTORECONF) instead calling ./autogen.sh

BTW I wonder if this upstream shell script build-static.sh is working:

gcc -static -o evmctl.static -include config.h src/evmctl.c src/libimaevm.c -lcrypto -lkeyutils -ldl

Because keyutils requires dynamic linking:

-static doesn't mean to *only* link statically. It means to prefer static
libraries. That's why it's still possible to link with -ldl as well.

However, BR2_STATIC_LIBS means that no shared libraries will be allowed on the
target. You could say that we should have an option BR2_PREFER_STATIC that links with -static but doesn't remove the .so files. But that just wastes space on the target, because *most* so files will not be used, and it's hard to find out which ones *are* used (because they could be dlopen'ed).

Quoted 2 lines

/home/br-test-pkg/br-arm-full-static/host/bin/arm-linux-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I. -DPKGBUILD="\"2019-10-29\"" -DPKGVERSION="\"keyutils-1.6\"" -DAPIVERSION="\"libkeyutils-1.8\"" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -static -UNO_GLIBC_KEYERR -o keyutils.o -c keyutils.c
keyutils.c:18:10: fatal error: dlfcn.h: No such file or directory

Note that this fails because the uclibc was configured for static only, so it
didn't install the dlfcn.h header or libdl.so.

Quoted 4 lines

#include <dlfcn.h>

Kind regards,
Petr

[snip]

package/ima-evm-utils/ima-evm-utils.mk line 16

Quoted 2 lines
package/ima-evm-utils/ima-evm-utils.mk new file +2 -0
+# build just sources in src subdirectory as root directory requires asciidoc
+# and xsltproc for manpage

I reworded this a bit.

package/ima-evm-utils/ima-evm-utils.mk line 18

Quoted 2 lines
package/ima-evm-utils/ima-evm-utils.mk new file +2 -0
+define IMA_EVM_UTILS_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(IMA_EVM_UTILS_MAKE_ENV) $(MAKE) -C $(@D)/src all

IME_EVM_UTILS_MAKE_ENV is empty, so it's no use here. I removed that.

Quoted 1 line

+endef

I added an empty line here for improved readability.

Regards,
Arnout

Quoted 11 lines
package/ima-evm-utils/ima-evm-utils.mk new file +10 -0
+define IMA_EVM_UTILS_INSTALL_STAGING_CMDS
+	$(TARGET_MAKE_ENV) $(IMA_EVM_UTILS_MAKE_ENV) $(MAKE) \
+		DESTDIR="$(STAGING_DIR)" -C $(@D)/src install
+endef
+define IMA_EVM_UTILS_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(IMA_EVM_UTILS_MAKE_ENV) $(MAKE) \
+		DESTDIR="$(TARGET_DIR)" -C $(@D)/src install
+endef
+
+$(eval $(autotools-package))