strace/0172-tests-linkat-provide-fallback-values-for-secontext-f.patch
Eugene Syromiatnikov e80309331c Add --secontext=mismatch option support
- Add 0168-m4-fix-st_SELINUX-check.patch
   (v5.15~18 "m4: fix st_SELINUX check")
 - Add 0169-Implement-displaying-of-expected-context-upon-mismat.patch
   (v5.16~31 "Implement displaying of expected context upon mismatch")
 - Add 0170-tests-linkat-reset-errno-before-SELinux-context-mani.patch
 - Add 0171-tests-secontext-add-secontext-field-getters.patch
 - Add 0172-tests-linkat-provide-fallback-values-for-secontext-f.patch
 - Add 0173-tests-secontext-eliminate-separate-secontext_format-.patch
 - Add 0174-tests-linkat-reset-context-to-the-expected-one-if-a-.patch

* 0168-m4-fix-st_SELINUX-check.patch: New file.
* 0169-Implement-displaying-of-expected-context-upon-mismat.patch: Ditto.
* 0170-tests-linkat-reset-errno-before-SELinux-context-mani.patch: Ditto.
* 0171-tests-secontext-add-secontext-field-getters.patch: Ditto.
* 0172-tests-linkat-provide-fallback-values-for-secontext-f.patch: Ditto.
* 0173-tests-secontext-eliminate-separate-secontext_format-.patch: Ditto.
* 0174-tests-linkat-reset-context-to-the-expected-one-if-a-.patch: Ditto.
* strace.spec strace.spec (Release): Bump to 6.
(Patch168, Patch169, Patch170, Patch171, Patch172, Patch173, Patch164): New
patches.
(%prep): Apply them.
(%changelog): Mention it.

Resolves: #2038965
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
2022-01-19 21:24:28 +01:00

72 lines
1.9 KiB
Diff

From 97e2742a7f1e6e113354911d04505ada3bfb5d70 Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Tue, 18 Jan 2022 18:04:42 +0100
Subject: [PATCH 172/174] tests/linkat: provide fallback values for secontext
fields changes
* tests/linkat.c (mangle_secontext_field): New function.
(main): Replace calls to update_secontext_field
with mangle_secontext_field calls.
---
tests/linkat.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/tests/linkat.c b/tests/linkat.c
index c3e2ee4..decb736 100644
--- a/tests/linkat.c
+++ b/tests/linkat.c
@@ -21,6 +21,20 @@
#include "secontext.h"
#include "xmalloc.h"
+static void
+mangle_secontext_field(const char *path, enum secontext_field field,
+ const char *new_val, const char *fallback_val)
+{
+ char *orig = get_secontext_field_file(path, field);
+ if (!orig)
+ return;
+
+ update_secontext_field(path, field,
+ strcmp(new_val, orig) ? new_val : fallback_val);
+
+ free(orig);
+}
+
int
main(void)
{
@@ -93,7 +107,8 @@ main(void)
#ifdef PRINT_SECONTEXT_MISMATCH
errno = 0;
- update_secontext_field(sample_1, SECONTEXT_USER, "system_u");
+ mangle_secontext_field(sample_1, SECONTEXT_USER, "system_u",
+ "unconfined_u");
sample_1_secontext = SECONTEXT_FILE(sample_1);
# ifdef PRINT_SECONTEXT_FULL
@@ -115,7 +130,8 @@ main(void)
#endif
errno = 0;
- update_secontext_field(sample_1, SECONTEXT_TYPE, "default_t");
+ mangle_secontext_field(sample_1, SECONTEXT_TYPE, "default_t",
+ "unconfined_t");
sample_1_secontext = SECONTEXT_FILE(sample_1);
sample_2_secontext = sample_1_secontext;
@@ -146,7 +162,8 @@ main(void)
char *cwd = get_fd_path(dfd_old);
errno = 0;
- update_secontext_field(".", SECONTEXT_TYPE, "default_t");
+ mangle_secontext_field(".", SECONTEXT_TYPE, "default_t",
+ "unconfined_t");
char *dfd_old_secontext = SECONTEXT_FILE(".");
#ifdef PRINT_SECONTEXT_MISMATCH
--
2.1.4