build fails on cross-compilation for OpenWrt
I'm trying to update audit package for OpenWrt. Since version 3.0.8, the build fails with these errors:
make[7]: Entering directory '/build/openwrtb/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/audit-userspace-4.0.1/audisp/plugins/remote'
ccache arm-openwrt-linux-muslgnueabi-gcc -DHAVE_CONFIG_H -I. -I../../.. -I../../.. -I../../../lib -I../../../common -I/build/openwrtb/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-13.2.0_musl_eabi/usr/include -I/build/openwrtb/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-13.2.0_musl_eabi/include -I/build/openwrtb
/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-13.2.0_musl_eabi/include/fortify -fPIE -DPIE -g -D_REENTRANT -D_GNU_SOURCE -Wundef -Wno-format-truncation -Wno-unused-but-set-variable -pipe -fno-caller-saves -fno-plt -pipe -fhonour-copts -mfloat-abi=hard -fmacro-prefix-map=/build/openwrtb/build_dir/target-arm_cortex
-a9+vfpv3_musl_eabi/audit-userspace-4.0.1=audit-userspace-4.0.1 -ffunction-sections -fdata-sections -flto=auto -fno-fat-lto-objects -Wformat -Werror=format-security -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -c -o audisp_remote-audisp-remote.o `test -f 'audisp-remote.c' || echo './'`audis
p-remote.c
In file included from audisp-remote.c:55:
queue.h: In function 'q_open':
queue.h:57:9: error: expected declaration specifiers before '__attribute_malloc__'
57 | __attribute_malloc__ __attr_dealloc (q_close, 1) __wur;
| ^~~~~~~~~~~~~~~~~~~~
audisp-remote.c:66:21: error: storage class specified for parameter 'stop'
66 | static volatile int stop = 0;
| ^~~~
audisp-remote.c:66:1: error: parameter 'stop' is initialized
66 | static volatile int stop = 0;
| ^~~~~~
audisp-remote.c:67:21: error: storage class specified for parameter 'hup'
67 | static volatile int hup = 0;
| ^~~
audisp-remote.c:67:1: error: parameter 'hup' is initialized
67 | static volatile int hup = 0;
| ^~~~~~
audisp-remote.c:68:21: error: storage class specified for parameter 'suspend'
68 | static volatile int suspend = 0;
| ^~~~~~~
audisp-remote.c:68:1: error: parameter 'suspend' is initialized
68 | static volatile int suspend = 0;
| ^~~~~~
[... more of the same ...]
audisp-remote.c:125:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
125 | {
| ^
audisp-remote.c:133:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
133 | {
| ^
audisp-remote.c:138:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
138 | {
| ^
[... more of the same ...]
audisp-remote.c:1695: error: expected '{' at end of input
make[7]: *** [Makefile:740: audisp_remote-audisp-remote.o] Error 1
make[7]: Leaving directory '/build/openwrtb/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/audit-userspace-4.0.1/audisp/plugins/remote'
make[6]: *** [Makefile:412: all-recursive] Error 1
Thanks.
I think that was fixed in a later release. I think a header was missing. See commit 234d25fa97a7f1a58a.
The log is from 4.0.1. I have these errors on all versions from 3.0.8 to 4.0.1.
4.0.1 should have all the fixes in it as should 3.1.3 - which is probably a better match given you started with 3.0.7. Let me review things again. This is almost certainly a missing include. The macros being included are from glibc. For any c library not defining them, it's supposed to define "dummy" macros that do nothing.
OK, I see what is happening. I missed defining an empty macro in common.h. The latest github code should build.
That was quick! Thank you! I will test tomorrow.
It still doesn't compile. New error:
make[7]: Entering directory '/build/openwrtb/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/audit-4.0.2/audisp/plugins/filter'
ccache arm-openwrt-linux-muslgnueabi-gcc -DHAVE_CONFIG_H -I. -I../../.. -I../../.. -I../../../lib -I../../../common -I../../../auparse -I/build/openwrtb/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-13.2.0_musl_eabi/usr/include -I/build/op
enwrtb/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-13.2.0_musl_eabi/include -I/build/openwrtb/staging_dir/toolchain-arm_cortex-a9+vfpv3_gcc-13.2.0_musl_eabi/include/fortify -fPIE -DPIE -g -D_GNU_SOURCE -Wundef -Wno-format-truncation -Wno
-unused-but-set-variable -pipe -g3 -fno-caller-saves -fno-plt -pipe -fhonour-copts -mfloat-abi=hard -fmacro-prefix-map=/build/openwrtb/build_dir/target-arm_cortex-a9+vfpv3_musl_eabi/audit-4.0.2=audit-4.0.2 -ffunction-sections -fdata-section
s -flto=auto -fno-fat-lto-objects -Wformat -Werror=format-security -fstack-protector-all -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -c -o audisp_filter-audisp-filter.o `test -f 'audisp-filter.c' || echo './'`audisp-filter.c
audisp-filter.c: In function 'handle_event':
audisp-filter.c:107:29: warning: implicit declaration of function 'write'; did you mean 'fwrite'? [-Wimplicit-function-declaration]
107 | if (write(pipefd[1], txt, strlen(txt)) == -1 || write(pipefd[1], "\n", 1) == -1) {
| ^~~~~
| fwrite
audisp-filter.c: In function 'load_rules':
audisp-filter.c:306:17: warning: implicit declaration of function 'close'; did you mean 'pclose'? [-Wimplicit-function-declaration]
306 | close(fd);
| ^~~~~
| pclose
audisp-filter.c: In function 'main':
audisp-filter.c:432:13: warning: implicit declaration of function 'pipe' [-Wimplicit-function-declaration]
432 | if (pipe(pipefd) == -1) {
| ^~~~
audisp-filter.c:438:16: warning: implicit declaration of function 'fork' [-Wimplicit-function-declaration]
438 | cpid = fork();
| ^~~~
audisp-filter.c:448:17: warning: implicit declaration of function 'dup2' [-Wimplicit-function-declaration]
448 | dup2(pipefd[0], STDIN_FILENO);
| ^~~~
audisp-filter.c:448:33: error: 'STDIN_FILENO' undeclared (first use in this function)
448 | dup2(pipefd[0], STDIN_FILENO);
| ^~~~~~~~~~~~
audisp-filter.c:448:33: note: each undeclared identifier is reported only once for each function it appears in
audisp-filter.c:451:17: warning: implicit declaration of function 'execve' [-Wimplicit-function-declaration]
451 | execve(config.binary, config.binary_args, NULL);
| ^~~~~~
audisp-filter.c:510:53: warning: implicit declaration of function 'read'; did you mean 'fread'? [-Wimplicit-function-declaration]
510 | while ((read_size = read(0, buffer, MAX_AUDIT_MESSAGE_LENGTH)) > 0) {
| ^~~~
| fread
make[7]: *** [Makefile:527: audisp_filter-audisp-filter.o] Error 1
Thanks for mentioning that. It was a missing include <unistd.h>. Commit pushed.
It works! Builds ok, runs ok, even on Marvell (see the other bug).
Could you make a new release? It would help with packaging for OpenWrt. I can't be sure it would get accepted by the OpenWrt devs, but an update to a released version looks better than an update a commit hash.
Thanks again!
PS: I read the changes in v4 and they mention dropping support for sysvinit? I didn't notice any problems during this short test, but could that affect OpenWrt in any way? Or other systems that don't use systemd? What should I be careful about when I test the new OpenWrt packge? Thanks.
That's good to hear. I have no idea what in v4.0.1 fixes it. There are a lot of changes. But going back to SysVinit, version 3.1.3 still has SysVinit support and many of the bug fixes from v4.0. I have applied one patch afterwards for the missing macro you discovered. It's on the audit-3.1-maint branch. If that one works, I could make a v3.1.4 and it would at least buy some time until the distro decides if they want to switch to systemd. Otherwise, they could easily cherrypick the SysVinit scripts from the init.d directory shipped in v3.1.3 and carry that as a patch.
Tested v3.1.3 (with the latest commit) and it works too. :thumbsup:
OpenWrt has its own init scripts. It's not affected, if that's the only thing removed. Then it's probably better to update directly to latest v4?
Thanks. There is one pending pull request that I want to merge and then cherrypick to this branch. After I do that, I'll do a v3.1.4 release.
Thank you.
audit-3.1.4 was just released.
I'm happy to report that v3.1.4 was accepted and merged into OpenWrt. https://github.com/openwrt/openwrt/pull/15138 Thanks!