libselinux: use /proc/thread-self when available

commit 3430519109c0423a49b9350aa8444beec798d5a7 upstream.

Linux 3.17 introduced a /proc/thread-self symlink that can be used
to reference the proc files of the current thread without needing to
use gettid(2).  Use this symlink when it exists, falling back to
using gettid(2) when it does not.  This is generally beneficial, but
was specifically motivated by https://github.com/systemd/systemd/issues/475.

[This also ports the openattr helper function from upstream commit
1d403326aecd92dfa0120cfd2e9c3c52a2a3cdf1 but does not bring in the
set*con cache.]

Change-Id: I19bd680784ce9a7e6bb6ddf4bbaa94fb664a42c7
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
1 file changed