Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 1185266

Summary: add lzma to pkg-config
Product: [Fedora] Fedora Reporter: Karel Zak <kzak>
Component: libselinuxAssignee: Petr Lautrbach <plautrba>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 21CC: dwalsh, kzak, mgrepl, plautrba
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libselinux-2.3-9.fc21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1214494 (view as bug list) Environment:
Last Closed: 2015-04-28 13:10:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Karel Zak 2015-01-23 10:51:14 UTC
libselinux.pc is incomplete and static builds against libselinux are broken now.

Actual results:
$ pkg-config --static --libs libselinux
-lselinux -lsepol -lpcre

Expected results:
$ pkg-config --static --libs libselinux
-lselinux -lsepol -lpcre -llzma -lpthread

Additional info:

All you need is to add "liblzma" to Requires.private field.

Comment 1 Petr Lautrbach 2015-04-21 15:12:55 UTC
Could you provide a reproducer please? It seems to work for me:

$ cat test_libselinux.c 
#include <selinux/selinux.h>

int main() {
        return is_selinux_enabled();
}

$ gcc -static test_libselinux.c `pkg-config --static --libs libselinux`

$ ./a.out 

$ echo $?
1

Comment 2 Karel Zak 2015-04-21 17:07:33 UTC
git clone http://github.com/karelzak/util-linux.git
cd util-linux
./autogen.sh
./configure --enable-static-programs --with-selinux

make mount.static V=1

gcc -std=gnu99 -fsigned-char -fno-common -Wall -Werror=sequence-point -Wextra -Wmissing-declarations -Wmissing-parameter-type -Wmissing-prototypes -Wno-missing-field-initializers -Wredundant-decls -Wsign-compare -Wtype-limits -Wuninitialized -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-parameter -Wunused-result -Wunused-variable -Wnested-externs -Wpointer-arith -Wstrict-prototypes -Wimplicit-function-declaration -I./libmount/src -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fno-diagnostics-show-caret -static -o mount.static sys-utils/mount_static-mount.o  ./.libs/libcommon.a ./.libs/libmount.a /home/projects/util-linux/util-linux/.libs/libblkid.a /home/projects/util-linux/util-linux/.libs/libuuid.a -lrt -lselinux -lsepol -lpcre

...
/usr/lib/gcc/x86_64-redhat-linux/4.9.2/../../../../lib64/libselinux.a(load_policy.o): In function `selinux_mkload_policy':
(.text+0x310): undefined reference to `lzma_stream_decoder'

..etc.

I'm not sure, maybe I blame sepol/selinux incorrectly (I don't see anything related to lzma in libselinux code), but the gcc message is obvious.

If I compile --without-selinux (and gcc command line contains only -lrt) then all works as expected.

Comment 3 Karel Zak 2015-04-21 17:11:30 UTC
Note that the code uses selinux_trans_to_raw_context(), getfilecon(), security_get_initial_context(), selinux_file_context_cmp().

Comment 4 Petr Lautrbach 2015-04-22 09:13:00 UTC
It's related to this [1] commit which apparently hasn't been upstreamed.

[1] https://github.com/fedora-selinux/selinux/commit/890c74c1295ee711796781d9e11e6f7a546bda07

Comment 5 Petr Lautrbach 2015-04-22 20:50:51 UTC
http://koji.fedoraproject.org/koji/taskinfo?taskID=9540099

This is a scratch with reverted commit 90c74c1295ee711796781d9e11e6f7a546bda07. 
But static builds are still broken due to #1214494:

/usr/lib/gcc/x86_64-redhat-linux/5.0.1/../../../../lib64/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `sljit_generate_code':
(.text+0x6b1): undefined reference to `pthread_mutex_lock'
/usr/lib/gcc/x86_64-redhat-linux/5.0.1/../../../../lib64/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `sljit_generate_code':
(.text+0x7a6): undefined reference to `pthread_mutex_unlock'
/usr/lib/gcc/x86_64-redhat-linux/5.0.1/../../../../lib64/libpcre.a(libpcre_la-pcre_jit_compile.o): In function `sljit_generate_code':
(.text+0xb31): undefined reference to `pthread_mutex_unlock'
...

Comment 6 Fedora Update System 2015-04-23 09:20:43 UTC
libselinux-2.3-9.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/libselinux-2.3-9.fc22

Comment 7 Fedora Update System 2015-04-23 09:21:41 UTC
libselinux-2.3-9.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/libselinux-2.3-9.fc21

Comment 8 Fedora Update System 2015-04-24 22:47:31 UTC
Package libselinux-2.3-9.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing libselinux-2.3-9.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-6771/libselinux-2.3-9.fc21
then log in and leave karma (feedback).

Comment 9 Fedora Update System 2015-04-28 13:10:15 UTC
libselinux-2.3-9.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 10 Fedora Update System 2015-05-10 23:59:07 UTC
libselinux-2.3-9.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.