Discussion:
[PATCH 2/5] libselinux: enable linking to musl-fts
Jason Zaman
2018-05-17 05:11:14 UTC
Permalink
Musl libc does not include the fts(3) functions so need to link to the
musl-fts library
https://github.com/pullmoll/musl-fts

Signed-off-by: Jason Zaman <***@perfinion.com>
---
libselinux/src/Makefile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 8af04aab..977b5c8c 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -98,6 +98,8 @@ LD_SONAME_FLAGS=-install_name,$(LIBSO)
endif

PCRE_LDLIBS ?= -lpcre
+# override with -lfts when building on Musl libc to use fts-standalone
+FTS_LDLIBS ?=

override CFLAGS += -I../include -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)

@@ -149,7 +151,7 @@ $(LIBA): $(OBJS)
$(RANLIB) $@

$(LIBSO): $(LOBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ $(PCRE_LDLIBS) -ldl -Wl,$(LD_SONAME_FLAGS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ $(PCRE_LDLIBS) $(FTS_LDLIBS) -ldl -Wl,$(LD_SONAME_FLAGS)
ln -sf $@ $(TARGET)

$(LIBPC): $(LIBPC).in ../VERSION
--
2.16.1
Jason Zaman
2018-05-18 05:03:18 UTC
Permalink
This series fixes compiling and running on musl libc.
patches 1-2 are fairly trivial.
patches 3-4 are a feature change on that platform since it does not
support GLOB_TILDE and GLOB_BRACE. tilde is coming in musl 1.1.21
according to [1]. brace support is not documented anywhere or in the
example configs so that is probably not a big problem.
patch 5 fixes a bug and it just happens that glibc returns a value for
sysconf and the error handling was wrong but never noticed.
[1]: https://wiki.musl-libc.org/roadmap.html
[PATCH 1/5] sestatus: include limits.h for PATH_MAX
[PATCH 2/5] libselinux: enable linking to musl-fts
[PATCH 3/5] setfiles: Musl compatibility for GLOB_BRACE and
[PATCH 4/5] restorecond: Musl compatibility for GLOB_BRACE and
[PATCH 5/5] genhomedircon: sysconf can return -1 without failure
Thanks! These patches look good to me and I would also appreciate if
they are merged in 2.8.
Awesome, I'll push them on monday then unless there are any issues
before then :)
Nicolas
Jason Zaman
2018-05-21 09:41:58 UTC
Permalink
Post by Jason Zaman
This series fixes compiling and running on musl libc.
patches 1-2 are fairly trivial.
patches 3-4 are a feature change on that platform since it does not
support GLOB_TILDE and GLOB_BRACE. tilde is coming in musl 1.1.21
according to [1]. brace support is not documented anywhere or in the
example configs so that is probably not a big problem.
patch 5 fixes a bug and it just happens that glibc returns a value for
sysconf and the error handling was wrong but never noticed.
[1]: https://wiki.musl-libc.org/roadmap.html
[PATCH 1/5] sestatus: include limits.h for PATH_MAX
[PATCH 2/5] libselinux: enable linking to musl-fts
[PATCH 3/5] setfiles: Musl compatibility for GLOB_BRACE and
[PATCH 4/5] restorecond: Musl compatibility for GLOB_BRACE and
[PATCH 5/5] genhomedircon: sysconf can return -1 without failure
Thanks! These patches look good to me and I would also appreciate if
they are merged in 2.8.
Awesome, I'll push them on monday then unless there are any issues
before then :)
FWIW, the patches look fine to me as well and I did a test PR to trigger travis CI testing
and they passed,
https://github.com/SELinuxProject/selinux/pull/96
One possible area for improvement (but not necessary to merge this) would be to fix the
genhomedircon code to also then handle the case where getpwnam_r/getgrnam_r returns ERANGE,
in which case we are supposed to realloc a larger buffer and try again per the man page.
Yeah i thought about that, but you're supposed to do that even when
sysconf does return a number and we've apparently never hit this before.
and the example code in the man pages doesnt really do it either. so as
small changes as possible before release is better. after release we could
think about it but probably still not really high importance.
This is all pushed to master now, travis-ci passes on master too.

-- Jason

Loading...