sys-process/audit fails to compile with hardened/linux/musl/amd64 profile and USE="python" Reproducible: Always Steps to Reproduce: 1. Install gentoo with musl LIBC 2. Run emerge sys-process/audit Actual Results: 3. ERROR: sys-process/audit-2.6.4::gentoo failed (compile phase): emake failed Expected Results: 3. Successfully compile and install sys-process/audit package with musl LIBC # emerge --info '=sys-process/audit-2.6.4::gentoo' Portage 2.3.5 (python 2.7.12-final-0, hardened/linux/musl/amd64, gcc-5.4.0, musl-1.1.16, 4.9.24-hardened-fitlet x86_64) ================================================================= System Settings ================================================================= System uname: Linux-4.9.24-hardened-fitlet-x86_64-AMD_A10_Micro-6700T_APU+AMD_Radeon_R6_Graphics-with-gentoo-2.3 KiB Mem: 8061384 total, 143576 free KiB Swap: 0 total, 0 free Timestamp of repository gentoo: Sun, 28 May 2017 10:00:01 +0000 sh bash 4.3_p48-r1 ld GNU ld (Gentoo 2.26.1 p1.0) 2.26.1 app-shells/bash: 4.3_p48-r1::gentoo dev-lang/perl: 5.24.1-r1::gentoo dev-lang/python: 2.7.12::gentoo, 3.4.5::gentoo dev-util/cmake: 3.7.2::gentoo dev-util/pkgconfig: 0.28-r2::gentoo sys-apps/baselayout: 2.3::gentoo sys-apps/openrc: 0.26.2::gentoo sys-apps/sandbox: 2.10-r3::musl sys-devel/autoconf: 2.69::gentoo sys-devel/automake: 1.15-r2::gentoo sys-devel/binutils: 2.26.1::gentoo sys-devel/gcc: 5.4.0-r3::musl sys-devel/gcc-config: 1.7.3::gentoo sys-devel/libtool: 2.4.6-r3::gentoo sys-devel/make: 4.2.1::gentoo sys-kernel/linux-headers: 4.4::musl (virtual/os-headers) sys-libs/musl: 1.1.16::gentoo Repositories: gentoo location: /usr/portage sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 x-portage location: /usr/local/portage masters: gentoo priority: 0 musl location: /var/lib/layman/musl sync-type: laymansync sync-uri: git://anongit.gentoo.org/proj/musl.git masters: gentoo priority: 50 ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="* -@EULA" CBUILD="x86_64-gentoo-linux-musl" CFLAGS="-march=native -O2 -pipe" CHOST="x86_64-gentoo-linux-musl" CONFIG_PROTECT="/etc" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/gentoo-release /etc/php/apache2-php7.0/ext-active/ /etc/php/cgi-php7.0/ext-active/ /etc/php/cli-php7.0/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo" CXXFLAGS="-march=native -O2 -pipe" DISTDIR="/usr/portage/distfiles" EMERGE_DEFAULT_OPTS="--jobs=2 " FCFLAGS="-O2 -pipe" FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox selinux sesandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-O2 -pipe" GENTOO_MIRRORS="http://distfiles.gentoo.org" INSTALL_MASK="charset.alias" LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j4" PKGDIR="/usr/portage/packages" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" USE="acl aio amd64 bzip2 caps cli conntrack cracklib crypt cxx dane dav dav_ext dri ecdsa efi filecaps fortran gccgo gost hardened iconv idn ipv6 jemalloc leaps_timezone logrotate lz4 lzo mmx modern-top modules naxsi ncat ncurses netlink nfsv41 nping nptl nse open_perms openmp pam pax_kernel pcre pcre16 pic readline sasl seccomp secure-delete selinux session smp spdy sse sse2 ssl tcmalloc tcpd threads udev unbound unicode upload_progress xattr xfs xtpax zlib" ABI_X86="64" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="musl" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-0" PYTHON_SINGLE_TARGET="python3_4" PYTHON_TARGETS="python2_7 python3_4" QEMU_SOFTMMU_TARGETS="x86_64" QEMU_USER_TARGETS="x86_64" RUBY_TARGETS="ruby21 ruby22" USERLAND="GNU" VIDEO_CARDS="dummy fbdev v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CC, CPPFLAGS, CTARGET, CXX, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON Without sys-process/audit package with USE=python I have broken SELinux local customization feature: # semanage fcontext -a -e 'XXX' 'YYY' Traceback (most recent call last): File "/usr/lib/python-exec/python2.7/semanage", line 933, in <module> do_parser() File "/usr/lib/python-exec/python2.7/semanage", line 912, in do_parser args.func(args) File "/usr/lib/python-exec/python2.7/semanage", line 362, in handleFcontext OBJECT.add_equal(args.file_spec, args.equal) File "/usr/lib/python2.7/site-packages/seobject.py", line 1817, in add_equal self.mylog.log_change("resrc=fcontext op=add-equal %s %s" % (audit.audit_encode_nv_string("sglob", target, 0), audit.audit_encode_nv_string("tglob", substitute, 0))) NameError: global name 'audit' is not defined
Created attachment 474570 [details] sys-process/audit-2.6.4 build log
Alpine Linux has some patches addressing the problems: https://git.alpinelinux.org/cgit/aports/tree/testing/audit (See especially 0001-auditctl-include-headers-to-make-build-work-with-mus.patch.) They however do not seem submitted upstream.
(In reply to Felix Janda from comment #2) > Alpine Linux has some patches addressing the problems: > > https://git.alpinelinux.org/cgit/aports/tree/testing/audit > > (See especially > 0001-auditctl-include-headers-to-make-build-work-with-mus.patch.) I trid all the Alpine Linux patches, but I got another error related to swig.
When I apply all the Alpine Linux patches I get error: audit_wrap.c: In function 'PyInit__audit': audit_wrap.c:10104:42: warning: implicit declaration of function 'SWIG_From_wchar_t' [-Wimplicit-function-declaration] SWIG_Python_SetConstant(d, "WCHAR_MAX",SWIG_From_wchar_t((wchar_t)((0x7fffffff+\\0)))); ^ audit_wrap.c:10104:3: error: stray '\' in program SWIG_Python_SetConstant(d, "WCHAR_MAX",SWIG_From_wchar_t((wchar_t)((0x7fffffff+\\0)))); ^ audit_wrap.c:10104:3: error: stray '\' in program audit_wrap.c:10104:42: warning: passing argument 3 of 'SWIG_Python_SetConstant' makes pointer from integer without a cast [-Wint-conversion] SWIG_Python_SetConstant(d, "WCHAR_MAX",SWIG_From_wchar_t((wchar_t)((0x7fffffff+\\0)))); audit_wrap.c:10105:3: error: stray '\' in program SWIG_Python_SetConstant(d, "WCHAR_MIN",SWIG_From_wchar_t((wchar_t)((-1-0x7fffffff+\\0)))); ^ audit_wrap.c:10105:3: error: stray '\' in program audit_wrap.c:10105:42: warning: passing argument 3 of 'SWIG_Python_SetConstant' makes pointer from integer without a cast [-Wint-conversion] SWIG_Python_SetConstant(d, "WCHAR_MIN",SWIG_From_wchar_t((wchar_t)((-1-0x7fffffff+\\0)))); If I change wchar_t from "0x7fffffff+\\0" to "0x7fffffff" in the swig generateg audit_wrap.c it compiles OK. But I don't uderstand what I'm doing and why swig creates wrong code?
Even If compile OK with modified wchar_t module does not works: $ python Python 2.7.12 (default, Jan 24 2017, 16:42:00) [GCC 5.4.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import audit Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/audit.py", line 21, in <module> _audit = swig_import_helper() File "/usr/lib/python2.7/site-packages/audit.py", line 20, in swig_import_helper return importlib.import_module('_audit') File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) ImportError: Error relocating /usr/lib/python2.7/site-packages/_audit.so: SWIG_From_wchar_t: symbol not found
swig produces for some reason invalid code from the following fragment in musl's stdint.h: #if L'\0'-1 > 0 #define WCHAR_MAX (0xffffffffu+L'\0') #define WCHAR_MIN (0+L'\0') #else #define WCHAR_MAX (0x7fffffff+L'\0') #define WCHAR_MIN (-1-0x7fffffff+L'\0') #endif It still compiles after removing the line "stdint.h" in bindings/swig/src/auditswig.i. I haven't tested if it results in a working python module, though.
I have comment stdint.h in auditswig.i: diff -ur audit-2.7.2-orig/bindings/swig/src/auditswig.i audit-2.7.2-new/bindings/swig/src/auditswig.i --- audit-2.7.2-orig/bindings/swig/src/auditswig.i 2017-02-13 17:47:26.000000000 +0300 +++ audit-2.7.2-new/bindings/swig/src/auditswig.i 2017-06-19 21:09:08.127162345 +0300 @@ -41,6 +41,6 @@ typedef unsigned uid_t; %include "/usr/include/linux/audit.h" #define __extension__ /*nothing*/ -%include "/usr/include/stdint.h" +/* %include "/usr/include/stdint.h" */ %include "../lib/libaudit.h" and package compiles with no errors Python module loaded without problems: $ python Python 2.7.12 (default, Jan 24 2017, 16:42:00) [GCC 5.4.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import audit >>> semanage fcontext works too. Thank you!
Very good. I've just submitted the relevant patches upstream: https://github.com/linux-audit/audit-userspace/pull/25
Hi, I can see the sys-process/audit been added to the musl overlay. But I it stil fails to build even with audit-2.7.1-musl.patch. Swig patch required too. * python2_7: running python_compile make -j4 -C /var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64-python2_7/bindings/swig VPATH=/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64/lib LIBS=/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64/lib/libaudit.la _audit_la_LIBADD=/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64/lib/libaudit.la '_audit_la_DEPENDENCIES=/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1/lib/libaudit.h /var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64/lib/libaudit.la' HAVE_PYTHON=true make: Entering directory '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64-python2_7/bindings/swig' Making all in src make[1]: Entering directory '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64-python2_7/bindings/swig/src' make[1]: Nothing to be done for 'all'. make[1]: Leaving directory '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64-python2_7/bindings/swig/src' Making all in python make[1]: Entering directory '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64-python2_7/bindings/swig/python' swig -o audit_wrap.c -python -I. -I../../.. -I/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1/lib -I/usr/include/python2.7 /var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1/bindings/swig/python/../src/auditswig.i /var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1/bindings/swig/python/../src/auditswig.i:33: Warning 116: %except is deprecated. Use %exception instead. /usr/include/stdint.h:88: Warning 490: Fragment 'SWIG_From_wchar_t' not found. /usr/include/stdint.h:89: Warning 490: Fragment 'SWIG_From_wchar_t' not found. /bin/sh ../../../libtool --tag=CC --mode=compile x86_64-gentoo-linux-musl-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1/bindings/swig/python -I../../.. -I. -I../../.. -I/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1/lib -I/usr/include/python2.7 -shared -march=native -O2 -pipe -c -o _audit_la-audit_wrap.lo `test -f 'audit_wrap.c' || echo '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1/bindings/swig/python/'`audit_wrap.c libtool: compile: x86_64-gentoo-linux-musl-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1/bindings/swig/python -I../../.. -I. -I../../.. -I/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1/lib -I/usr/include/python2.7 -march=native -O2 -pipe -c audit_wrap.c -fPIC -DPIC -o .libs/_audit_la-audit_wrap.o audit_wrap.c: In function 'init_audit': audit_wrap.c:10084:42: warning: implicit declaration of function 'SWIG_From_wchar_t' [-Wimplicit-function-declaration] SWIG_Python_SetConstant(d, "WCHAR_MAX",SWIG_From_wchar_t((wchar_t)((0x7fffffff+L\'\\0\')))); ^~~~~~~~~~~~~~~~~ audit_wrap.c:10084:83: error: stray '\' in program SWIG_Python_SetConstant(d, "WCHAR_MAX",SWIG_From_wchar_t((wchar_t)((0x7fffffff+L\'\\0\')))); ^ audit_wrap.c:10084:84: warning: missing terminating ' character SWIG_Python_SetConstant(d, "WCHAR_MAX",SWIG_From_wchar_t((wchar_t)((0x7fffffff+L\'\\0\')))); ^ audit_wrap.c:10084:84: error: missing terminating ' character SWIG_Python_SetConstant(d, "WCHAR_MAX",SWIG_From_wchar_t((wchar_t)((0x7fffffff+L\'\\0\')))); ^~~~~~~~~~~ audit_wrap.c:10084:82: error: 'L' undeclared (first use in this function) SWIG_Python_SetConstant(d, "WCHAR_MAX",SWIG_From_wchar_t((wchar_t)((0x7fffffff+L\'\\0\')))); ^ audit_wrap.c:10084:82: note: each undeclared identifier is reported only once for each function it appears in audit_wrap.c:10085:3: error: expected ')' before 'SWIG_Python_SetConstant' SWIG_Python_SetConstant(d, "WCHAR_MIN",SWIG_From_wchar_t((wchar_t)((-1-0x7fffffff+L\'\\0\')))); ^~~~~~~~~~~~~~~~~~~~~~~ audit_wrap.c:10085:86: error: stray '\' in program SWIG_Python_SetConstant(d, "WCHAR_MIN",SWIG_From_wchar_t((wchar_t)((-1-0x7fffffff+L\'\\0\')))); ^ audit_wrap.c:10085:87: warning: missing terminating ' character SWIG_Python_SetConstant(d, "WCHAR_MIN",SWIG_From_wchar_t((wchar_t)((-1-0x7fffffff+L\'\\0\')))); ^ audit_wrap.c:10085:87: error: missing terminating ' character SWIG_Python_SetConstant(d, "WCHAR_MIN",SWIG_From_wchar_t((wchar_t)((-1-0x7fffffff+L\'\\0\')))); ^~~~~~~~~~~ audit_wrap.c:10258:1: error: expected declaration or statement at end of input } ^ make[1]: *** [Makefile:509: _audit_la-audit_wrap.lo] Error 1 make[1]: Leaving directory '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64-python2_7/bindings/swig/python' make: *** [Makefile:415: all-recursive] Error 1 make: Leaving directory '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64-python2_7/bindings/swig' * ERROR: sys-process/audit-2.7.1::musl failed (compile phase): * emake failed * * If you need support, post the output of `emerge --info '=sys-process/audit-2.7.1::musl'`, * the complete build log and the output of `emerge -pqv '=sys-process/audit-2.7.1::musl'`. * The complete build log is located at '/var/tmp/portage/sys-process/audit-2.7.1/temp/build.log'. * The ebuild environment file is located at '/var/tmp/portage/sys-process/audit-2.7.1/temp/environment'. * Working directory: '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64' * S: '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1' * Messages for package sys-process/audit-2.7.1: * ERROR: sys-process/audit-2.7.1::musl failed (compile phase): * emake failed * * If you need support, post the output of `emerge --info '=sys-process/audit-2.7.1::musl'`, * the complete build log and the output of `emerge -pqv '=sys-process/audit-2.7.1::musl'`. * The complete build log is located at '/var/tmp/portage/sys-process/audit-2.7.1/temp/build.log'. * The ebuild environment file is located at '/var/tmp/portage/sys-process/audit-2.7.1/temp/environment'. * Working directory: '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1-abi_x86_64.amd64' * S: '/var/tmp/portage/sys-process/audit-2.7.1/work/audit-2.7.1'
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/musl.git/commit/?id=071af4a636f04d9cb428f618d98f0113e71fad67 commit 071af4a636f04d9cb428f618d98f0113e71fad67 Author: Felix Janda <felix.janda@posteo.de> AuthorDate: 2017-12-29 22:06:20 +0000 Commit: Felix Janda <felix.janda@posteo.de> CommitDate: 2017-12-29 22:06:20 +0000 sys-process/audit: fix compilation of swig bindings Bug: https://bugs.gentoo.org/620006 sys-process/audit/audit-2.6.4.ebuild | 1 + sys-process/audit/audit-2.7.1.ebuild | 1 + sys-process/audit/files/audit-2.7.1-swig.patch | 11 +++++++++++ 3 files changed, 13 insertions(+)}
Latest audit ebuild from musl overlay works fine. I see only two musl related upstream commits: commit f924ce85fc2ffcee0fca1e399019d1c05afba65b commit 7d180d4dc8cf53bcf67fd07122963fa427dc61d7 Do we need to wait until all the required musl patches will be settled to the upstream repo?