diff options
Diffstat (limited to 'libbb/selinux_common.c')
-rw-r--r-- | libbb/selinux_common.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libbb/selinux_common.c b/libbb/selinux_common.c index ff076f6..7478cc7 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); +} + |