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 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) | |||
38 | "file creation context to %s", scontext); | 38 | "file creation context to %s", scontext); |
39 | } | 39 | } |
40 | } | 40 | } |
41 | |||
42 | void selinux_preserve_fcontext(int fdesc) | ||
43 | { | ||
44 | security_context_t context; | ||
45 | |||
46 | if (fgetfilecon(fdesc, &context) < 0) { | ||
47 | if (errno == ENODATA || errno == ENOTSUP) | ||
48 | return; | ||
49 | bb_perror_msg_and_die("fgetfilecon failed"); | ||
50 | } | ||
51 | setfscreatecon_or_die(context); | ||
52 | freecon(context); | ||
53 | } | ||
54 | |||