Use nftw() instead of fts()
Hello,
The recent versions of libselinux use the fts() function in src/selinux_restorecon.c. This function is BSD-only, and therefore not available in the musl C library, and only available optionally in the uClibc C library.
Would it be possible to use instead the POSIX-compliant nftw() function, which provides the same functionality?
In addition, using fts() is problematic, as on glibc versions <= 2.22, it is incompatible with large file support.
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Quoted 7 lines · Thomas Petazzoni
Hello,
The recent versions of libselinux use the
fts()function insrc/selinux_restorecon.c. This function is BSD-only, and therefore not available in the musl C library, and only available optionally in the uClibc C library.
Quoted 5 lines
Would it be possible to use instead the POSIX-compliant
nftw()function, which provides the same functionality?In addition, using
fts()is problematic, as on glibc versions <= 2.22, it is incompatible with large file support.
selinux userspace has been using fts() since 2009 (commit cce17290670ed7e1803ca6da660225ac01931d0c), when policycoreutils/setfiles was converted from nftw() to fts(). libselinux usage is newer, but src/selinux_restorecon.c is essentially a library function version of setfiles.
Not saying that it would be impossible to switch (back) to nftw(), but I guess we'd have to understand the cost/benefit tradeoff there. If fts() isn't available or well supported, why hasn't this previously been an issue for policycoreutils/setfiles?
Quoted 5 lines · Stephen Smalley
Quoted 4 lines · Thomas Petazzoni
The recent versions of libselinux use the
fts()function insrc/selinux_restorecon.c. This function is BSD-only, and therefore not available in the musl C library, and only available optionally in the uClibc C library.
[...]
Quoted 10 lines
selinux userspace has been using
fts()since 2009 (commitcce17290670ed7e1803ca6da660225ac01931d0c), when policycoreutils/setfiles was converted fromnftw()tofts(). libselinux usage is newer, butsrc/selinux_restorecon.cis essentially a library function version of setfiles.Not saying that it would be impossible to switch (back) to
nftw(), but I guess we'd have to understand the cost/benefit tradeoff there. Iffts()isn't available or well supported, why hasn't this previously been an issue for policycoreutils/setfiles?
Do you know why the code was switched from nftw() to the fts-style functions? The commit message doesn't really say so, instead focusing on the compatibility and showing that there is no performance impact associated with it.
I think the main benefit here would be to allow musl- and ucLibc systems to use libselinux. I did a quick check to see if Android's libselinux port had to work around it as well, but apparently bionic uses the fts-style functions as well.
Wkr,
Sven Vermeulen