From 2edbc2ab85b96fb01a3862db09df12f40d4382cd Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sat, 20 Oct 2007 02:00:49 +0000 Subject: ping: fix breakage from -I fix passwd: SELinux support by KaiGai Kohei --- libbb/selinux_common.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libbb/selinux_common.c') diff --git a/libbb/selinux_common.c b/libbb/selinux_common.c index ff076f6f0..7478cc7b5 100644 --- a/libbb/selinux_common.c +++ b/libbb/selinux_common.c @@ -38,3 +38,17 @@ void setfscreatecon_or_die(security_context_t scontext) "file creation context to %s", scontext); } } + +void selinux_preserve_fcontext(int fdesc) +{ + security_context_t context; + + if (fgetfilecon(fdesc, &context) < 0) { + if (errno == ENODATA || errno == ENOTSUP) + return; + bb_perror_msg_and_die("fgetfilecon failed"); + } + setfscreatecon_or_die(context); + freecon(context); +} + -- cgit v1.2.3