diff options
Diffstat (limited to 'archival/libunarchive/data_extract_all.c')
-rw-r--r-- | archival/libunarchive/data_extract_all.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/archival/libunarchive/data_extract_all.c b/archival/libunarchive/data_extract_all.c index 58b05335b..cc4894229 100644 --- a/archival/libunarchive/data_extract_all.c +++ b/archival/libunarchive/data_extract_all.c | |||
@@ -12,6 +12,17 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
12 | int dst_fd; | 12 | int dst_fd; |
13 | int res; | 13 | int res; |
14 | 14 | ||
15 | #if ENABLE_FEATURE_TAR_SELINUX | ||
16 | char *sctx = archive_handle->tar__next_file_sctx; | ||
17 | if (!sctx) | ||
18 | sctx = archive_handle->tar__global_sctx; | ||
19 | if (sctx) { /* setfscreatecon is 4 syscalls, avoid if possible */ | ||
20 | setfscreatecon(sctx); | ||
21 | free(archive_handle->tar__next_file_sctx); | ||
22 | archive_handle->tar__next_file_sctx = NULL; | ||
23 | } | ||
24 | #endif | ||
25 | |||
15 | if (archive_handle->ah_flags & ARCHIVE_CREATE_LEADING_DIRS) { | 26 | if (archive_handle->ah_flags & ARCHIVE_CREATE_LEADING_DIRS) { |
16 | char *slash = strrchr(file_header->name, '/'); | 27 | char *slash = strrchr(file_header->name, '/'); |
17 | if (slash) { | 28 | if (slash) { |
@@ -45,7 +56,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
45 | "same age file exists", file_header->name); | 56 | "same age file exists", file_header->name); |
46 | } | 57 | } |
47 | data_skip(archive_handle); | 58 | data_skip(archive_handle); |
48 | return; | 59 | goto ret; |
49 | } | 60 | } |
50 | else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) { | 61 | else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) { |
51 | bb_perror_msg_and_die("can't remove old file %s", | 62 | bb_perror_msg_and_die("can't remove old file %s", |
@@ -158,4 +169,12 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle) | |||
158 | utimes(file_header->name, t); | 169 | utimes(file_header->name, t); |
159 | } | 170 | } |
160 | } | 171 | } |
172 | |||
173 | ret: ; | ||
174 | #if ENABLE_FEATURE_TAR_SELINUX | ||
175 | if (sctx) { | ||
176 | /* reset the context after creating an entry */ | ||
177 | setfscreatecon(NULL); | ||
178 | } | ||
179 | #endif | ||
161 | } | 180 | } |